← All 96 breakdowns
CONTEXT

Why your AI search quotes the wrong report (and the one-line fix)

A short breakdown, in plain words.

What's happening

Most "AI search over your docs" (RAG) works like this: every document is cut into small chunks, each chunk is turned into a vector (an "embedding") on its own, and when someone asks a question, the system fetches the chunks whose vectors are closest to the question and hands them to the model.

The problem is the cutting. A chunk like "The company's revenue grew by 3% over the previous quarter" has lost the two things that matter: which company and which quarter. Cut out of its report, it looks almost the same as every other quarter's revenue sentence, so search can fetch the wrong one, and the model answers confidently from it.

We built a tiny test to see it: four short quarterly reports (made-up companies), one question, "How much did Kestrel Air's revenue grow in Q2 2024?" With plain chunks, the right chunk ranked 5th. Above it were the Q1 chunk ("grew by 5%") and another company's chunk ("grew by 11%"). Hand the top results to a model and "5%" is the likely answer: the wrong quarter.

The fix: Contextual Retrieval

Anthropic published this in September 2024. Before you embed each chunk, ask a model to write one short line that puts the chunk back in its document, and glue that line to the front of the chunk:

This chunk gives Kestrel Air's Q2 2024 revenue: up 3% on the previous quarter to £212 million. The company's revenue grew by 3% over the previous quarter, to £212 million.

In our test, with those lines added, the right chunk ranked 1st.

Anthropic's prompt is simple: give the model the whole document and the chunk, and ask for "a short succinct context to situate this chunk within the overall document for the purposes of improving search retrieval of the chunk", answering "only with the succinct context and nothing else". The line is usually 50-100 tokens.

Why it matters (Anthropic's numbers)

Measured as the share of searches where the right chunk was not in the top 20 results:

Setup Failed retrievals Reduction
Plain embeddings 5.7% -
+ context lines (contextual embeddings) 3.7% 35% fewer
+ keyword search on the same chunks (BM25) 2.9% 49% fewer
+ a reranker on top 1.9% 67% fewer

What to do

  1. Write a context line for every chunk when you index (not at question time). Use a small, cheap model; send it the whole document plus the chunk.
  2. Embed the line together with the chunk, and put the same text into a keyword index (BM25), which catches exact names, IDs and numbers that embeddings miss.
  3. Rerank: fetch a wider set (Anthropic used 150), let a reranking model pick the best 20.
  4. Watch the cost: it's one extra model call per chunk, paid once at indexing. With prompt caching (the document is cached and reused for all its chunks), Anthropic estimated about $1.02 per million document tokens.
  5. Maybe skip RAG entirely: if your whole knowledge base is under about 200,000 tokens (around 500 pages), you can often just put it all in the prompt.

The short version

Chunks don't remember where they came from. Tell them, in one line, before you index.


Source: Anthropic, "Introducing Contextual Retrieval" (19 September 2024). Our test: four made-up reports, the all-MiniLM-L6-v2 embedding model, context lines written by Claude Haiku, run on 23 November 2026.

FREE ONE-TIME UNLOCK

Unlock the full CONTEXT breakdown

Drop your email once to read the complete step-by-step guide, grab the files, and unlock all 96 Reel breakdowns on this device forever.

✓ Instant reveal right here✓ No spam, unsubscribe any time