# Most RAG problems are search problems

> When a RAG system gives a bad answer, the passage that held the answer often never reached the model. Score retrieval on its own, keep keyword search, rerank, and give chunks their context before touching the prompt.

Generative AI · Field note · October 26, 2026 · 7 minute read · By Nabil Ahmed
Canonical: https://farside.works/insights/most-rag-problems-are-search-problems/

![Thousands of distant galaxies scattered across a dark patch of sky in the Hubble Ultra Deep Field](https://farside.works/content/images/2026/10/hubble-ultra-deep-field.jpg)

When a retrieval-augmented assistant gives a bad answer, the first instinct is to fix the part that wrote it. Someone rewrites the prompt or tries a bigger model. More often, in the systems we're asked to look at, the passage that held the answer never reached the model at all. No prompt can fix that.

A RAG system is a search engine with a language model on the end. If the search half is weak, the generation half is guessing. So the first thing we do on these projects is score the two halves separately, and most of the time the search half is where the work is.

## Two questions, two scores

Every wrong answer comes from one of two places. Either the right material wasn't retrieved, or it was retrieved and the model didn't use it well. An end-to-end score blends the two, so a team can spend a month on prompts while the real problem sits in the index.

Scoring retrieval on its own needs a labeled set. Take 100 to 300 questions people actually asked, from search logs, support tickets or chat transcripts, and for each one record which documents or chunks contain the answer. A subject-matter expert usually has to do the labeling, and it's slower than anyone expects.

```json
{"id": "q-0217", "question": "What's the warranty on the X200 compressor if it was installed by a third party?",
 "relevant": ["policy/warranty-2025.pdf#sec-4.2", "kb/KB-1183"], "tags": ["warranty", "exact-model-number"], "source": "tickets-2026-08"}
```

With that set, three numbers cover most of what you need:

- **Hit rate at k.** The share of questions where at least one relevant chunk shows up in the top k results.
- **Recall at k.** The share of all relevant chunks that show up in the top k. It matters when an answer needs two or three pieces, such as a policy and its exception.
- **Mean reciprocal rank (MRR).** One divided by the position of the first relevant result, averaged over all questions. It tells you whether the right chunk is near the top or buried at position 18.

Set k to the number of chunks you actually pass to the model. If you send the top 10, recall at 50 is a nice number that doesn't describe your system. Run the set on every change to chunking, embeddings or index settings, the same way you'd run the end-to-end evaluation we describe in [The test set that runs every night](https://farside.works/notes/the-test-set-that-runs-every-night/). Use the tags to break the results down, because retrieval rarely fails evenly. It fails on part numbers, on acronyms, or on one document type.

## Keep the keyword search

Many RAG builds start and end with a vector database. Embeddings are good at matching meaning, but they can miss exact strings. Anthropic's write-up on contextual retrieval uses the example of a user searching for "Error code TS-999". An embedding model might return content about error codes in general and miss the one document with that exact code. BM25, an older lexical ranking method, looks for that exact string and finds it.

The BEIR benchmark is the most widely cited evidence that lexical search is a serious baseline, not a fallback. Its authors evaluated 10 retrieval systems across 18 public datasets from different domains. They found that BM25 is "a robust baseline." On MS MARCO, the dataset most neural models were trained on, BM25 trailed the neural approaches by 7 to 18 points. On the other datasets, it generally outperformed many of the more complex approaches. Dense retrievers did well on some datasets and much worse than BM25 on others, especially where the domain shifted away from their training data. The authors' summary is that in-domain performance "is not a good indicator for out-of-domain generalization."

BEIR's authors also flag a caveat: many of its datasets carry a lexical bias, because keyword systems were used when the relevance labels were created. That can understate dense models. But it points to the same lesson. A public benchmark isn't your corpus, and your own labeled set is the only score that settles it.

Enterprise content is full of things embeddings handle poorly: SKUs, contract numbers, error codes, internal acronyms, people's names. So we run both. A query goes to a BM25 index and a vector index, and the two ranked lists are merged. The usual merge is reciprocal rank fusion, from a 2009 paper by Cormack, Clarke and Büttcher. Each document scores the sum of 1 / (k + rank) across the lists. The authors fixed k at 60 in a pilot, found it "near-optimal," and noted that the choice "was not critical." It needs no training data. Anthropic's tests found the same thing at a higher level: embeddings plus BM25 beat embeddings alone.

## Cast a wide net, then rerank

First-stage retrieval has to be fast, so it compares the query and each document separately. A reranker reads the query and a candidate together and scores how well they match. That's slower, so you only run it on a shortlist.

In BEIR, the strongest system was BM25 followed by a cross-encoder reranker. It beat BM25 alone on 16 of the 18 datasets. In Anthropic's setup, initial retrieval returned the top 150 chunks and a reranker picked the top 20 to pass to the model. The trade-off is latency and cost, which Anthropic notes grow with the number of chunks you rerank. Tune that against your labeled set.

## Chunks need to know where they came from

Most RAG pipelines split documents into chunks of a few hundred tokens. The trouble is that a chunk often doesn't make sense on its own. Anthropic's example is a chunk from an SEC filing that says "The company's revenue grew by 3% over the previous quarter." It doesn't name the company or the quarter, so a search for a specific company's Q2 revenue has little reason to find it.

Their fix, which they call contextual retrieval, uses a model to write a short note for each chunk, usually 50 to 100 tokens, that places it within the whole document. The note is added to the front of the chunk before it's embedded and before the BM25 index is built. Across codebases, fiction, arXiv papers and science papers, measured as the share of relevant chunks missing from the top 20:

- Contextual embeddings alone cut the failure rate by 35%, from 5.7% to 3.7%.
- Contextual embeddings plus contextual BM25 cut it by 49%, to 2.9%.
- Adding a reranker on top cut it by 67%, to 1.9%.

Those are Anthropic's datasets, not yours, but every gain came from fixing what gets indexed and how it's ranked, not from the model that writes the answer. The same post makes a point that's easy to skip. If your knowledge base is under about 200,000 tokens, roughly 500 pages, you may not need retrieval at all and can put the whole thing in the prompt.

![Technicians behind a glass cabinet pour lunar soil into a stack of sieves in the Lunar Receiving Laboratory](https://farside.works/content/images/2026/10/apollo14-lunar-receiving-lab.jpg)
*Technicians sieve freshly opened Apollo 14 lunar samples in the Lunar Receiving Laboratory at the Manned Spacecraft Center, February 18, 1971. Every sample was split, sorted and catalogued before anyone studied it. NASA photo S71-19489, via Wikimedia Commons. Photo: NASA.*

Chunking and metadata are data engineering, and they deserve the same care as a warehouse model:

- **Split on structure, not character counts.** Headings, sections, table rows and FAQ entries are natural boundaries.
- **Carry the title and path with every chunk.** Even without a model-written note, prepending the document title and section heading gives both indexes something to match.
- **Store metadata as fields, not prose.** Product, region, effective date, version and access group should be filterable. A superseded policy can match a question perfectly and still be wrong.
- **Apply permissions at retrieval time.** If a user can't open the source document, its chunks shouldn't reach the prompt.

## More context isn't a fix

When recall is low, it's tempting to pass more chunks and let the model sort it out. The "Lost in the Middle" paper by Liu and colleagues shows the limit. Models did best when the relevant passage was at the beginning or end of the input and significantly worse when it was in the middle. In one setting, GPT-3.5-Turbo with the answer in the middle of its context did worse than with no documents at all, which scored 56.1%. In an open-domain test, using 50 retrieved documents instead of 20 improved accuracy by only about 1.5% for GPT-3.5-Turbo and about 1% for Claude 1.3. The authors found that model performance "saturates long before retriever recall."

Anthropic's results point the same way from the other side. They found 20 chunks worked better than 5 or 10, but noted that more information can distract a model, so there's a limit. Both papers favor good ranking over volume: get the right chunks in, and get them near the top.

## Before you change the prompt

If a RAG system gives answers people don't trust, check these first:

- Is there a labeled set of real questions with the chunks that answer them, and do you know its hit rate and recall at the k you actually use?
- For the failing questions, was the right chunk retrieved at all? If not, stop tuning the prompt.
- Is there a keyword index next to the vector index, and do queries with IDs, codes or names go through it?
- Is there a reranker over a wider candidate set, and has anyone measured what it costs in latency?
- Do chunks carry their document title, section and effective date, and are outdated versions filtered out?
- Are access permissions enforced before retrieval results reach the model?
- Has anyone compared the current setup against plain BM25 on your own questions?

That last one takes an afternoon. If plain BM25 comes out close, the time is better spent on chunking, metadata and ranking than on a new model.

---

**Sources**

- Anthropic, ["Introducing Contextual Retrieval"](https://www.anthropic.com/engineering/contextual-retrieval), September 19, 2024.
- Thakur et al., ["BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models"](https://arxiv.org/abs/2104.08663), NeurIPS 2021 Datasets and Benchmarks Track, revised October 21, 2021.
- Liu et al., ["Lost in the Middle: How Language Models Use Long Contexts"](https://arxiv.org/abs/2307.03172), Transactions of the Association for Computational Linguistics, 2023 (arXiv revised November 20, 2023).
- Cormack, Clarke and Büttcher, ["Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods"](https://plg.uwaterloo.ca/~gvcormac/cormacksigir09-rrf.pdf), SIGIR 2009.
