Research

Is Contextual Retrieval worth it? Here is what each technique added.

Contextual Retrieval is one of the most recommended RAG upgrades right now. We tested how much it actually adds, side by side with BM25, similarity search, a reranker and metadata filters, on a document archive built to be hard.

Ibad ur Rehman9 min read

87.7 to 88.1%

recall@20 with Contextual Retrieval added to BM25 + similarity search.

87.7 to 94.4%

with metadata filters added to the same starting point.

87.7 to 94.6%

with all of them together, the best result in the study.

Contents

01What Contextual Retrieval is

To search long documents, you cut them into small pieces called chunks. The problem is that a chunk loses its context. A chunk that says “the fee was 8% of total development cost” no longer says which project or which document it came from.

Contextual Retrieval, published by Anthropic, fixes this before anything is searched:

  1. An AI model reads the whole document and one chunk.
  2. It writes a short sentence saying where the chunk comes from, such as “This is from the final cost report for the Oak Street project.”
  3. That sentence is added to the chunk, and the search index is built from the result.

Anthropic reported 35–67% fewer retrieval failures on its own data. We wanted to see how it does on documents that look like a real company archive, and how it compares with the other tools a team would reach for.

02The dataset, and why it is hard

287 synthetic housing-finance documents: mortgages, liens, payoff letters, grant agreements, budgets and policies. Because we generated them from a known set of facts, we know every right answer to every question. The archive was built to be hard in the same ways real ones are:

37%

of files are scans, with OCR errors in names and numbers

77%

of chunks never name the client or project they belong to

72

loan documents built from the same templates

69

right documents for the hardest question

The 77% matters most here: it is exactly the problem Contextual Retrieval is meant to solve, so the test gives it every chance. We asked 81 questions of two kinds:

  • Find one thing (60 questions): “Pull up the payoff letter for this client.” One or two right documents each.
  • Find everything (21 questions): “Show everything about this project” or “How many loans did we issue in 2021?” Often six or more right documents, up to 69.

03Keyword search

Keyword search finds chunks that contain the words in the question. We used Meilisearch, a popular open-source search engine, exactly as it comes out of the box. Its defaults are built for short queries typed into a search box, and two of them hurt on full questions:

  • It doesn’t weigh rare words. It ranks chunks by how many question words they contain, so a client name counts no more than “what” or “the”.
  • It drops words when matches run short. If too few chunks contain every word, it removes words from the end of the question. In “What developer fee was charged on [project]?”, the project name goes first.

15.9% recall@20. Its “frequency matching” setting, which drops common words first, reached 35.4%. This is a mismatch between search-box defaults and full questions, not a verdict on keyword search.

04BM25 search

BM25 is also keyword search, with a different way of ranking. It gives more weight to rare words, so a client name or a loan number counts far more than “what” or “the”.

84.3% recall@20, on the same documents and the same chunks. Only the ranking changed, and it was the biggest single improvement in the whole study.

05Similarity search

Similarity search finds chunks with a similar meaning, even when they use different words. It handles paraphrasing well, and is weaker on exact names and numbers. We used bge-m3 embeddings in Qdrant.

83.1% recall@20, close to BM25 but strong on different questions.

06BM25 + similarity search

A hybrid runs both searches and merges the two result lists, so each covers the other’s blind spot: BM25 catches exact names, similarity catches paraphrase.

87.7% recall@20, the best of the four. This is our starting point for everything that follows.

Figure 1Recall@20 by search method

No reranker, no filters, plain chunks. Every bar starts at zero, so lengths compare directly.

Recall at 20 by search method and kind of question
Kind of questionKeywordBM25SimilarityBM25 + similarity
Find one thing60 questions · 1–2 right documents18.3%93.6%96.4%97.5%
Find everything21 questions · often 6 or more9.1%57.7%45.0%59.8%

Values: recall@20 · ↑ higher is betterworsebetterBold: best in row

A good search finds single documents easily. Every method struggles when a question needs many documents at once. The next three techniques are attempts to fix that, and each is added on its own to the same starting point.

07Reranker

After the search returns its top 30 results, a second AI model reads the question and each result together and re-orders them, keeping the best 20. It can lift a good document from 25th place to 5th. It cannot rescue one the search never returned. We used Voyage rerank-2.5-lite, at about $0.0001 per search.

87.7% → 92.1% recall@20. That is +4.4 points.

08Filtering

Filtering puts context back as structured tags instead of text. Most archives hold a limited set of document types with predictable fields: a mortgage has a borrower, a lender, an amount and a date.

  • When a document is added, an AI model reads it once and tags it with facts such as client, project, year and document type.
  • When a question comes in, one short AI call turns it into filters. “Every loan issued in 2021” becomes type = loan and year = 2021, and the search only looks at documents that match.
  • If a filter is wrong, it loosens step by step, and an ordinary search fills any empty places, so a mistake costs ranking, not the answer.

87.7% → 94.4% recall@20. That is +6.7 points, the largest gain of any single technique.

09Contextual chunking

This is Contextual Retrieval itself: every chunk gets its AI-written sentence of context before indexing. For this archive that took 5,171 AI calls, with 59% of the prompt text served from cache.

87.7% → 88.1% recall@20. That is +0.4 points.

One likely reason the gain is smaller than Anthropic’s: our documents already carry strong clues such as names, loan numbers and addresses, so a sentence of context has less to add. It should do better on documents where a chunk means nothing on its own, like manuals, contracts with numbered clauses, and code.

10What if we use all of them together?

Contextual chunking, a reranker and filters, all on top of BM25 + similarity search:

Figure 2Recall@20, one technique at a time and then all together

Each “+” row adds one technique to BM25 + similarity search; they are not stacked. Filters are the first, untuned version.

All together reached 94.6%, the best result. Each technique fixes a different gap: filters narrow the search to the right documents, the reranker puts the best of them first, and contextual chunking gives each chunk back the context it lost when the document was split. On an archive whose documents already name their clients and loans, filters and the reranker carried most of the gain.

Recall at 20 by kind of question, one technique at a time
Kind of questionStarting point+ Contextual+ Reranker+ FiltersAll together
Find one thing60 questions · 1–2 right documents97.5%97.5%98.0%97.2%95.8%
Find everything21 questions · often 6 or more59.8%61.3%75.0%86.3%91.1%

Values: recall@20 · ↑ higher is betterworsebetterBold: best in row

  • “Find everything” questions are where the gains are: from 59.8% to 91.1% with everything on. Filtering did most of that work.
  • “Find one thing” questions were already above 97%. Filters added a few small mistakes there, from 97.5% to 95.8% with everything on.

11What each one costs

Cost of contextual chunking and filtering for 287 documents
For 287 documentsContextual chunkingFiltering
AI calls to build the indexone per chunk · two per document5,171508
Cost to build59% of contextual prompts served from cache$2.61$0.65
AI calls per searchcontextual chunking adds nothing at search time01
Scales withhow each cost grows as the archive growschunksdocuments

The two make different trade-offs. Contextual chunking does all its work once, when the index is built, and costs nothing per search. Filtering is lighter to build but adds one short AI call to every question. The reranker needs no work at indexing and costs about $0.0001 per search.

12What we would recommend

  1. Check how your keyword search ranks. If it is a search-box engine at default settings, switch to BM25 ranking.
  2. Combine BM25 with similarity search, and add a reranker. That reached 92.1% here with no AI work at indexing.
  3. Add filtering if people ask “everything about…” or “how many…” questions. It is the technique that moved them most.
  4. Test Contextual Retrieval on your own documents, especially if your chunks mean little without their source. Measure recall before and after.

13Limitations and method

  • The documents are synthetic. They were generated from the same facts the filters look for, which favours filtering. Real archives contain documents that fit no template, and fields that are missing or wrong.
  • 81 questions is a small set. Differences under about 1.5 points are noise.
  • Tuned filters are left out of the comparison. A tuned version reached 96.5% recall@20 with BM25 + similarity, but its fixes were found by reading failures on these same questions, so the number is optimistic.
  • Only search was scored, not the quality of the final answers.
  • One of each. One similarity model, one AI model for context sentences and filters, Meilisearch at default and frequency settings only, and a simple BM25 with no stemming.
Show method details
Documents
287 files (247 PDF, 37 Word, 3 text) generated from a seeded set of facts: 32 fictional clients, 58 loans, 19 home sales and 8 payoffs, plus projects, grants and policies. 106 files were turned into scan-like PDFs with typos; 33 are duplicates filed in a second folder.
Chunks
1,000 characters with a 200-character overlap: 5,856 chunks.
Questions
27 information needs, each phrased three ways: 81 questions and 329 right documents.
Keyword search
Meilisearch 1.54 at default settings, and with frequency matching.
BM25
Okapi BM25 (k1 1.2, b 0.75), no stemming.
Similarity search
bge-m3 embeddings (1,024 dimensions) in Qdrant.
Hybrids
The two result lists merged with reciprocal rank fusion (k = 60).
Reranker
Voyage rerank-2.5-lite, re-ordering the top 30 files and keeping 20. NVIDIA’s open Nemotron 1B reranker, run on 8 setups, scored within 0.6 points of it.
Contextual chunking
One call per chunk to Qwen3.8-27B; 59% of prompt tokens served from cache.
Filtering
Each file sorted into one of 11 document families, then 9 fields extracted. Filters loosen step by step if they leave fewer than 3 files, and unfiltered search fills any empty places. 286 of 287 files were classified correctly.
Scoring
Recall@20: the share of right documents in the top 20 files. Duplicate copies count as one document. Questions with more than 20 right documents are capped at 20.
Setups
7 search methods × 2 chunk types × 3 filter settings × reranker on or off = 84, plus 4 single-idea runs.

14All 88 setups

Want a different combination? Filter by search method, filtering, chunking or reranker. Sorted best first; the outlined row is the starting point.

Search
Filtering
Chunks
Reranker

Showing 88 of 88 setups

Sort
All 88 retrieval setups with recall at 20 and recall at 10
#SearchRecall@20 (higher is better)Recall@10 (higher is better)ChunksFilteringReranker
48Similarity97.0%94.7%ContextualtunedOn
41Similarity96.9%95.2%Plaintuned—
60Meilisearch + similarity96.6%95.6%ContextualtunedOn
77BM25 + similarity96.5%94.9%Plaintuned—
47Similarity96.2%92.7%Contextualtuned—
66Meilisearch (freq.) + similarity96.1%95.7%PlaintunedOn
42Similarity95.9%95.1%PlaintunedOn
87Meilisearch + similarity95.8%94.7%ContextualroutedOn
36BM2595.7%95.4%ContextualtunedOn
34BM2595.6%86.7%ContextualuntunedOn
86Meilisearch + similarity95.4%93.5%PlainroutedOn
53Meilisearch + similarity95.3%93.1%Plaintuned—
58Meilisearch + similarity95.3%86.9%ContextualuntunedOn
78BM25 + similarity95.3%94.6%PlaintunedOn
70Meilisearch (freq.) + similarity95.2%86.8%ContextualuntunedOn
72Meilisearch (freq.) + similarity95.2%94.2%ContextualtunedOn
84BM25 + similarity95.2%94.5%ContextualtunedOn
40Similarity95.1%86.5%PlainuntunedOn
46Similarity95.1%87.3%ContextualuntunedOn
54Meilisearch + similarity95.0%94.3%PlaintunedOn
64Meilisearch (freq.) + similarity94.8%87.1%PlainuntunedOn
65Meilisearch (freq.) + similarity94.8%94.3%Plaintuned—
83BM25 + similarity94.8%94.2%Contextualtuned—
30BM2594.7%94.5%PlaintunedOn
76BM25 + similarity94.6%86.0%PlainuntunedOn
82BM25 + similarity94.6%85.9%ContextualuntunedOn
75BM25 + similarity94.4%87.5%Plainuntuned—
28BM2594.0%85.9%PlainuntunedOn
39Similarity94.0%85.8%Plainuntuned—
59Meilisearch + similarity94.0%91.9%Contextualtuned—
52Meilisearch + similarity93.7%86.3%PlainuntunedOn
71Meilisearch (freq.) + similarity93.3%91.9%Contextualtuned—
29BM2593.2%93.0%Plaintuned—
45Similarity93.2%85.7%Contextualuntuned—
63Meilisearch (freq.) + similarity92.9%86.6%Plainuntuned—
44Similarity92.7%89.1%Contextual—On
35BM2592.6%93.6%Contextualtuned—
27BM2592.4%85.5%Plainuntuned—
81BM25 + similarity92.3%87.9%Contextualuntuned—
74BM25 + similarity92.1%87.8%Plain—On
32BM2591.8%89.0%Contextual—On
51Meilisearch + similarity91.8%83.7%Plainuntuned—
80BM25 + similarity91.7%87.7%Contextual—On
69Meilisearch (freq.) + similarity90.7%85.5%Contextualuntuned—
38Similarity89.9%85.5%Plain—On
33BM2589.7%85.6%Contextualuntuned—
68Meilisearch (freq.) + similarity89.5%88.5%Contextual—On
57Meilisearch + similarity89.4%81.9%Contextualuntuned—
26BM2589.2%86.9%Plain—On
62Meilisearch (freq.) + similarity88.5%87.1%Plain—On
56Meilisearch + similarity88.3%87.4%Contextual—On
79BM25 + similarity88.1%88.6%Contextual——
73BM25 + similaritystarting point87.7%86.1%Plain——
88Meilisearch + similarity86.1%84.7%Plain—On, duplicates merged
50Meilisearch + similarity85.9%84.7%Plain—On
43Similarity84.5%82.3%Contextual——
25BM2584.3%83.4%Plain——
31BM2584.0%83.6%Contextual——
37Similarity83.1%81.8%Plain——
61Meilisearch (freq.) + similarity82.5%80.0%Plain——
67Meilisearch (freq.) + similarity80.9%80.0%Contextual——
55Meilisearch + similarity78.6%76.7%Contextual——
49Meilisearch + similarity78.3%74.8%Plain——
85Meilisearch + similarity78.3%75.9%Ctx. embeddings only——
18Keyword (Meilisearch, frequency)39.6%40.0%PlaintunedOn
22Keyword (Meilisearch, frequency)39.6%38.8%ContextualuntunedOn
23Keyword (Meilisearch, frequency)39.6%40.0%Contextualtuned—
24Keyword (Meilisearch, frequency)39.6%40.0%ContextualtunedOn
17Keyword (Meilisearch, frequency)39.4%39.4%Plaintuned—
16Keyword (Meilisearch, frequency)38.3%38.8%PlainuntunedOn
15Keyword (Meilisearch, frequency)38.0%37.2%Plainuntuned—
20Keyword (Meilisearch, frequency)37.7%37.6%Contextual—On
14Keyword (Meilisearch, frequency)37.6%37.4%Plain—On
21Keyword (Meilisearch, frequency)36.6%36.4%Contextualuntuned—
13Keyword (Meilisearch, frequency)35.4%35.5%Plain——
19Keyword (Meilisearch, frequency)33.7%34.0%Contextual——
12Keyword (Meilisearch)29.5%29.4%ContextualtunedOn
10Keyword (Meilisearch)29.4%27.0%ContextualuntunedOn
11Keyword (Meilisearch)28.8%25.0%Contextualtuned—
6Keyword (Meilisearch)27.5%27.5%PlaintunedOn
4Keyword (Meilisearch)26.9%25.0%PlainuntunedOn
9Keyword (Meilisearch)25.9%24.1%Contextualuntuned—
8Keyword (Meilisearch)24.1%23.7%Contextual—On
5Keyword (Meilisearch)23.7%23.7%Plaintuned—
2Keyword (Meilisearch)20.7%20.9%Plain—On
3Keyword (Meilisearch)20.7%19.5%Plainuntuned—
7Keyword (Meilisearch)18.9%16.9%Contextual——
1Keyword (Meilisearch)15.9%16.0%Plain——

Score cellsworsebetterRecall: share of the right documents found in the top 20 (or top 10) results · ↑ higher is better

Synthetic documents, questions and answer key. Search: Meilisearch 1.54, BM25, and Qdrant with bge-m3 for similarity. AI model for context sentences and filters: Qwen3.8-27B. Reranker: Voyage rerank-2.5-lite.

Search missing the documents that matter?

We measure first, then build. Bring your questions and your documents.