Evaluating Retrieval Quality

Measure the retriever on its own with labelled questions and metrics like recall at k and MRR, before judging the generated answers.

Intermediate · about 4 hours · difficulty 3/5

Learn first: Reranking Retrieved Results

If you only evaluate final answers, you cannot tell whether a failure came from retrieval or generation. Evaluate the retriever separately.

Build a retrieval test set

  • Collect 50 to 200 realistic questions (from users, support logs, or written by domain experts).
  • For each, label the chunk or document IDs that contain the answer.
  • You can bootstrap with an LLM generating questions from chunks, but review them: synthetic questions tend to copy the chunk's wording and make retrieval look easier than it is.

Metrics

  • Recall at k (hit rate): did any relevant chunk appear in the top k? The most important metric for RAG.
  • Precision at k: how much of the top k is relevant.
  • MRR (mean reciprocal rank): how high the first relevant result appears.
  • nDCG: rank-aware metric when relevance has grades.

Using it

Every change (chunk size, embedding model, hybrid weights, reranker) gets a before-and-after run. Keep results in a table so decisions are data-driven. Frameworks like Ragas and others also offer LLM-judged context relevance metrics when you lack labels.

Pitfalls

Tiny test sets swing wildly. Label enough questions, include hard ones, and refresh the set as the corpus changes.

Good enough to move on

You have a labelled retrieval set, a script that computes recall at 5 and MRR, and you have used it to choose between at least two configurations.

Key concepts

  • Labelled question-to-chunk sets
  • Recall at k / hit rate
  • Precision at k and MRR
  • nDCG
  • Synthetic question generation: Review before trusting
  • Ragas context metrics

Mini project

Create a 60-question labelled set for your RAG corpus and a script that reports recall at 5 and MRR for four configurations (two chunk sizes, with and without reranking).

Check yourself

Recall at 5 is 95% but users still get wrong answers. Where do you look next?

Free resources