deep · 6 min
Retrieval evaluation
Testing the search step of a RAG system on its own: for each test question, did the chunks that answer it come back near the top?
updated 27 Sept 2026
We've built a chat over a set of articles. Someone asks "Why does temperature 0 still give different answers?" and the answer comes back wrong. Whose fault is it?
There are two suspects. Maybe search missed: the paragraph that explains it never made it into the top results, so the model never saw it. Or maybe the model fumbled: the paragraph was right there in the prompt and it ignored it, misread it, or mixed it up with something else.
An eval that only grades the final answer can't tell them apart. It says "wrong" either way. But the fixes are completely different. A search miss needs better chunking, a different embedding model or keyword search added. A fumble needs a better prompt or a better model. So we test the search step on its own. That's retrieval evaluation, the search half of RAG checked separately from the answer.
There's no model call and no grading of prose, so it's cheap enough to run after every change.
What we need
Search engineers worked this out long before RAG, and the setup carries straight over. We need the collection (our chunks), some test questions written the way real users ask, and labels: for each question, which chunks are relevant. The labels are the answer key, often called the ground truth.
A label is usually a plain yes or no. And "relevant" means it helps with what the person wanted to know, not that it contains the words they typed. A chunk can share every word with a question and still not answer it.
| Question | Relevant chunks |
|---|---|
| Why does temperature 0 still give different answers? | sampling#tricky-1 |
| What does BM25 add on top of embeddings? | hybrid-search#why-2 |
| How big should a chunk be? | chunking#size-1 |
That's the whole dataset. (The ids are made up for the example.)
How many questions? The long-standing rule of thumb in search is 50 as a minimum. Scores swing a lot from one question to the next, often more than between two systems on the same question, so the average needs enough questions behind it to mean anything.
Scoring it
Search returns a ranked list and we keep the top k, since that's what goes into the prompt. Say k is 5 and we run our three questions:
| Question | Labelled chunk landed at | In top 5? | 1 / rank |
|---|---|---|---|
| Temperature 0 | rank 1 | yes | 1 |
| What BM25 adds | rank 3 | yes | 1/3 |
| Chunk size | rank 8 | no | 0 |
| Average | 0.67 | 0.44 |
The middle column is recall@k: of the chunks that should come back, what share made the top k? For RAG that's the main question, because it asks whether the model got to see the right text. The last column is MRR, which rewards getting the first right chunk to the top. (There are others, like nDCG, which handles graded labels such as "very relevant" and "a bit relevant".)
Match k to your system. If you send 20 chunks, measure recall@20. Anthropic did exactly this in their 2024 retrieval work, reported as a failure rate: the share of relevant chunks that missed the top 20. Every change they tried got scored by how much it cut that number.
Where the labels come from
This is the expensive part. There are three ways in, and you can mix them.
By hand. Someone who knows the content writes questions and marks the chunks that answer each. Nobody reads every chunk for every question, so the usual shortcut is pooling: run a few search methods, judge only their top results, and assume anything outside the pool isn't relevant. Hold on to that assumption. It bites later.
Generated from your chunks. For each chunk, ask an LLM to write a question that chunk answers. Now you have a question and its label for free. Search for each one and see if its chunk comes back. Jason Liu ran this on issues from a code repository and got keyword search at about 55% recall and embeddings at about 65%. On a set of essays the two were about equal, and keyword search was about ten times faster. You can't know which case you're in until you measure.
The catch: generated questions can be easier to find than what real users type, so search looks better than it is. Chroma tested this against real questions from a documentation chatbot. Questions generated with no guidance kept the models in the right order but scored too high. What helped was telling the LLM about the users, giving it a few real questions to copy the style of, and first dropping documents nobody would ask about.
Real questions, labelled. Once people use the system, log what they ask and label a sample. It's the closest to real use, and it's work. In that same study, 693 real questions were checked. 133 had no answer in the docs at all. And for 76 of the ones that did, the answer was in a document none of the four models tested had put in its top 10.
(Why not a public benchmark like BEIR? It's fine for a shortlist of embedding models, but the BEIR authors found many models that beat BM25 on familiar data did worse than it on new domains. The ranking depends on the data, and only yours matters.)
Traps
Unlabelled isn't the same as irrelevant. Remember pooling? A new search method that finds different, perfectly good chunks gets marked wrong for them. BEIR measured this on one dataset whose labels came from many teams' systems and still leaned toward keyword matching. A dense retriever had 14.4% of its top 10 never judged, against 6.4% for BM25. When those gaps were judged by hand, the dense retriever went from slightly worse than BM25 to clearly better. The same happens in a small way with generated questions: each has one labelled chunk, but a second might answer it too. So before trusting a drop in recall, read the misses. Some are label errors.
Some questions have no right chunk. Recall doesn't work when nothing is relevant, so those questions quietly drop out of the score. But they're exactly where a system should decline instead of making something up. That needs its own test (saying "I don't know").
An LLM judge measures something else. Tools like Ragas skip labels: an LLM reads what came back and scores how much of it helps. That answers "is what came back focused?", not "did we find the right chunk?", since a chunk we never retrieved can't be judged.
And a high recall only means the model had what it needed. Whether it used it well is the other half, which still needs an eval on the answers.
A few habits
Label the source passage, an article and section say, rather than a chunk id, and count any chunk that overlaps it. Chunk ids change every time you change the chunk size, and you'll want to change it.
Keep a separate set for trying changes and use the test set only to report. Tune on the test set and the score overstates how search will do on new questions.
Write the target down before you start, something like "recall@20 above some number on these 50 questions". That's a success criterion, and it turns every change to chunking, hybrid search or reranking from a guess into a number.
So, back to the temperature question. Next time its answer comes back
wrong, the first thing to check is where sampling#tricky-1 ranked. If it
wasn't in the top k, no prompt was going to save it.
Further reading
- Evaluation in information retrieval, Manning, Raghavan and Schütze, Introduction to Information Retrieval, 2008. The textbook setup: labels, pooling, how much people agree, and why not to tune on the test set.
- BEIR: A Heterogeneous Benchmark for Zero-shot Evaluation of Information Retrieval Models, Thakur et al., 2021. Read section 6 for how pooled labels punish new methods.
- Introducing Contextual Retrieval, Anthropic, 2024. A good example of measuring retrieval on its own and scoring every change against it.
- Generative Benchmarking, Hong, Troynikov, Huber and McGuire (Chroma), 2025. How to generate test questions that behave like real ones.
- Systematically Improving Your RAG, Jason Liu, 2024. The practical recipe: a question per chunk, measure recall first. Quick to read.
- Ragas: Automated Evaluation of Retrieval Augmented Generation, Es et al., 2023, revised 2025. The label-free alternative, if you want to see how it works.