Precision is the share of retrieved chunks that are relevant, and recall is the share of relevant chunks that were retrieved. A retriever can score well on one and badly on the other: returning everything gives perfect recall and terrible precision, while returning one perfect chunk gives perfect precision and terrible recall. Measure both on a labelled test set, so a change to chunking, the embedding model or the search mode is judged on numbers, not on a feeling.
What you need
- A test set of questions with the known correct chunks for each
- The retriever configuration you want to measure
- A fixed top-k, for example the top 10 results per question
Step 1: Fix the test set and the top-k
Write down the questions, the correct chunk for each, and the number of results the retriever returns. Do not change the test set between runs, or the numbers cannot be compared.
Step 2: Run the retriever and record the hits
For each question, run the retriever and record which of the returned chunks are correct. A chunk counts as a hit only if it contains the answer, not if it merely mentions the topic.
Step 3: Compute precision and recall per question
Precision is correct chunks returned divided by chunks returned; recall is correct chunks returned divided by correct chunks that exist. Average both across the test set, and look at the worst questions, not just the average.
Worked example: synthetic precision and recall for 4 questions
The table below is a synthetic example. It shows the expected result of measuring a retriever; no retriever was run.
| Question | Correct returned | Precision / Recall |
|---|---|---|
| Refund policy | 2 of 3 returned | 0.67 / 1.00 |
| Setup steps | 1 of 2 returned | 0.50 / 0.50 |
| Pricing tiers | 2 of 2 returned | 1.00 / 1.00 |
| Support hours | 0 of 1 returned | 0.00 / 0.00 |
Expected result (UNTESTED). precision averages 0.54 and recall averages 0.63 across the 4 questions, with the support-hours question failing outright. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Precision and recall need ground truth: without a labelled test set you cannot compute either.
- The numbers depend on the top-k you choose; a larger top-k raises recall and lowers precision.
- A published benchmark used top-10 recall, or hit rate, as its main metric, with MRR as a second measure.
- Chunk-level precision is not the same as document-level recall; decide which level your test set measures before you start.
