AI BENCHNOTES
EmbeddingsBENCH NOTE 004RAGTool calls
AI BENCHNOTES
THE COMPLETE WORKBENCHPick a machine part.
12 NOTES / 12 LABS / ZERO INCENSE

Start anywhere. The numbers are a useful route, not homework police.

00Animated bench map
CONCEPT 004library-card spicy

RAG:give the modelan open book.

Retrieval-augmented generation builds a tiny, query-specific reading packet before the model answers. The model is not retrained. It gets evidence—assuming your retrieval system found the right pages.

  • RETRIEVEcandidate evidence
  • AUGMENTthe model context
  • GENERATEa fresh answer
EVIDENCE_DESK / CASE 004● OPEN
INCOMING QUESTION“Can I expense a standing desk?”
SEARCHABLE ARCHIVEchunked · embedded · indexed
SELECTED PASSAGES3 useful clippingsthe model sees these—not the whole archive
E-01Equipment policy · v3

Adjustable desks: reimbursable up to $600 with manager approval.

E-02Remote-work handbook

Ergonomic furniture is eligible for the home-office benefit.

E-03Expense FAQ

File under Home Office Furniture; attach the receipt.

ANSWER WIRE / FRESHLY GENERATED

Yes. Current policy covers an adjustable desk up to $600 with manager approval. Submit it as Home Office Furniture. [E-01] [E-03]

Grounded, not guaranteed. Check the clippings.
01 / THE SHORT VERSION

The model takes the exam. Retrieval packs the open book.

RAG is a pipeline, not a special kind of database or a magic model mode. Its answer can only be grounded in evidence the pipeline actually retrieves.

01 / RRetrieve

Search an external corpus for passages that might answer this particular query.

02 / AAugment

Place the selected passages, their provenance, and clear instructions into the model’s context.

03 / GGenerate

Ask the model to compose a fresh answer from that evidence—and admit when the packet is insufficient.

What changes

The context assembled for this request. New or private knowledge can be supplied at inference time.

What does not

The model’s weights. RAG is not training, and retrieved text does not become permanent model memory.

What is not promised

Truth. A stale source, missed passage, or poorly grounded generation can still produce a confident wrong answer.

THE BOUNDARY

Retrieval decides what evidence enters the room. Generation decides what to say about it.

02 / INTERACTIVE EVIDENCE DESK

How picky should the retriever be?

Lower the threshold to admit more candidates. Raise it to demand a stronger relevance score. The scores and documents here are illustrative; the trade-off is real.

Retrieval quality is not one number. This lab isolates one knob so you can see its causal effect.

CASE QUESTION / FIXEDCan I expense a standing desk?
65%
more recall / more noisestricter / easier to miss
CANDIDATE CHUNKS3 of 6 admitted
scores are illustrative
E-0193
Equipment policy · v3APR 2026 · CURRENT

Adjustable desks may be reimbursed up to $600 with manager approval.

IN PACKET
E-0282
Remote-work handbookMAR 2026 · CURRENT

Ergonomic furniture is eligible under the home-office benefit.

IN PACKET
E-0369
Expense FAQFEB 2026 · CURRENT

Submit furniture under Home Office Furniture and attach the receipt.

IN PACKET
E-0457
Equipment policy · v1AUG 2022 · SUPERSEDED

Home-office furniture reimbursements are capped at $250.

CUT
E-0547
People team blogJUN 2024 · EDITORIAL

Five ways to improve posture while working from home.

CUT
E-0639
Travel policyJAN 2026 · CURRENT

Hotel workspaces should include a desk and suitable lighting.

CUT

The lesson: retrieval needs enough recall to include the decisive passage, then enough filtering and ranking to keep stale or distracting passages out. “Stuff in more chunks” is not a quality strategy.

03 / TWO LOOPS, ONE ANSWER

Stock the archive offline. Search it at request time.

Production RAG has a preparation loop and a serving loop. If you only diagram “question → vector DB → answer,” the important engineering disappears in the arrow labels.

LOOP APrepare the shelves
on ingest, update, and delete
01
Ingest sources

Load the documents you are allowed to search. Preserve source IDs, versions, owners, and effective dates.

02
Cut useful chunks

Split at boundaries that preserve a complete idea. The retriever returns chunks, not mystical whole-document understanding.

03
Embed + index

Represent passages for semantic similarity, often alongside keyword search. Store enough metadata to filter safely.

LOOP BAnswer this request
every question
  1. 01
    Query

    Start with the user’s information need. Rewrite or expand only when it improves retrieval.

  2. 02
    Retrieve

    Fetch a broad candidate set using semantic, keyword, or hybrid search.

  3. 03
    Filter + rerank

    Enforce permissions and freshness, then select the passages most useful for this question.

  4. 04
    Pack the prompt

    Attach evidence, provenance, and rules for answering or abstaining.

  5. 05
    Generate + cite

    Compose a fresh answer and map its citations back to the exact supplied passages.

CHUNKING NOTE

A chunk is the unit of evidence.

Too large, and the relevant sentence swims in unrelated text. Too small, and the sentence loses its qualifier, table header, or section meaning. Overlap can help at boundaries; it cannot repair thoughtless splitting.

EMBEDDING NOTE

An embedding is a search coordinate, not compressed truth.

It makes semantic neighbors easier to find—even when wording differs. Exact names, IDs, dates, and rare terms often benefit from keyword or hybrid retrieval too.

CITATION NOTE

Provenance must survive every handoff.

Carry stable chunk and source IDs from index to prompt to response. A decorative footnote generated from memory is not a citation system.

04 / RETRIEVAL CRAFT

The glamorous part is mostly document hygiene.

Model choice matters. But many RAG failures are mundane: bad boundaries, stale indexes, missing permissions, weak queries, and no test set for the retriever.

RECALLDid the useful passage make the candidate set?
PRECISION / SIGNALHow much distractor text came along for the ride?

First retrieve broadly enough to avoid missing evidence. Then filter, rerank, and budget context so the final packet stays useful. The best settings depend on your corpus and questions—measure them.

01

Write retrieval evals first

For a set of real questions, label which passages are sufficient. Measure whether those passages appear in the candidate set before grading eloquence.

02

Filter before the prompt

Tenant, role, geography, effective date, and document status belong in retrieval filters. Do not retrieve forbidden text and ask the model to politely ignore it.

03

Make freshness operational

Updates and deletions must propagate into the index. Track source version, indexed-at time, and failure state so “current” means something inspectable.

04

Let the model abstain

Tell it what counts as sufficient evidence and what to do when sources conflict or the answer is absent. Then test that behavior.

05 / SIX WAYS THE CLIPPINGS LIE

A citation is a trail, not a force field.

Citations make answers inspectable when they point to the passages actually used. They do not prove the source is current, the passage supports the claim, or the model read it faithfully.

MISS

The answer exists. Retrieval misses it.

The query uses different language, the chunk boundary hid the meaning, or the correct source was never indexed.

FIELD TESTInspect recall on labeled question → supporting-passage pairs.
STALE

The archive remembers an obsolete world.

An old policy outranks its replacement, or a deleted page survives in the index.

FIELD TESTLog versions and effective dates; test updates and deletes end to end.
LEAK

A great semantic match is not permission.

Similarity search crosses tenant, team, region, or role boundaries and hands private text to the generator.

FIELD TESTApply authorization filters before retrieval results enter model context.
NOISE

Too many clippings blur the answer.

A large top-k fills the context with near-matches, duplicate passages, and contradictory versions.

FIELD TESTCompare candidate recall with final-packet usefulness and answer quality.
DRIFT

The model answers beyond the evidence.

The right passage arrives, but the generator adds unsupported details, ignores a qualifier, or attaches the wrong citation.

FIELD TESTGrade claim-level support and citation entailment—not just answer similarity.
TRAP

Retrieved text contains instructions.

Documents are untrusted input. A malicious passage can try to override rules or trigger actions if your system treats it as authority.

FIELD TESTDelimit evidence as data, constrain tools, sanitize risky formats, and red-team the corpus.
Security dispatch

Retrieval expands the model’s input surface. Apply least privilege in the search layer, treat retrieved content as untrusted data, and keep consequential actions behind explicit authorization and validation.

06 / PRESCRIPTION PAD

Use RAG for missing knowledge—not every missing capability.

RAG is a strong fit when the answer lives in external text and the right text varies by question. It is an awkward substitute for a calculator, database query, workflow tool, or behavior change.

RX / RETRIEVALGood indications
  • Answers depend on a large private or domain-specific corpus.
  • Knowledge changes often enough that retraining would be clumsy.
  • Readers need to inspect sources or citations.
  • Only a small slice of the corpus is relevant to each request.

Typical cases: internal handbooks, support knowledge, research libraries, technical documentation, contracts, and case archives.

SYMPTOMBETTER FIRST MOVE
Tiny, stable reference

Put the whole thing in context.

Exact live value or calculation

Query the database or call a tool.

Teach style or repeated behavior

Use prompting or consider fine-tuning.

No trustworthy source corpus

Fix the knowledge supply first.

07 / THE ENGINEERING RECEIPT

A minimum viable loop with places to inspect.

Keep the seams visible. You want to know whether a bad answer came from search, filtering, context assembly, generation, or citation mapping.

rag-loop.ts · provider-neutral sketch
// 1. Search broadly, inside the user’s permissions
const candidates = await search({
  query,
  filter: {tenantId, roles, status: "current"},
  topK: 20,
});

// 2. Select a small, useful evidence packet
const evidence = (await rerank(query, candidates))
  .filter(isRelevant)
  .slice(0, 5);

// 3. Generate from passages with stable IDs
const answer = await generate({
  instructions: "Use only EVIDENCE. Cite [chunk_id]. Abstain if missing.",
  input: formatQuestion(query, evidence),
});

return {
  answer,
  citations: verifyCitations(answer, evidence),
  trace: {query, candidates, evidence},
};
THE FIELD RULE

Retrieve evidence, not vibes. Keep provenance attached, permissions enforced, stale pages out, and “I don’t know” available.