# 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. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/retrieval-evaluation
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/ai-engineer/reranking)

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

- [Ragas documentation](https://docs.ragas.io/) (Ragas)
- [Evaluation measures in information retrieval](https://en.wikipedia.org/wiki/Evaluation_measures_%28information_retrieval%29) (Wikipedia)

Previous: [Citations and Grounded Answers](https://www.internhack.in/roadmaps/tracks/ai-engineer/citations-grounding) · Next: [Advanced RAG Patterns](https://www.internhack.in/roadmaps/tracks/ai-engineer/advanced-rag)

## More in Retrieval-Augmented Generation

- [RAG Fundamentals](https://www.internhack.in/roadmaps/tracks/ai-engineer/rag-basics)
- [Document Ingestion and Parsing](https://www.internhack.in/roadmaps/tracks/ai-engineer/document-ingestion)
- [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search)
- [Reranking Retrieved Results](https://www.internhack.in/roadmaps/tracks/ai-engineer/reranking)
- [Citations and Grounded Answers](https://www.internhack.in/roadmaps/tracks/ai-engineer/citations-grounding)
- [Evaluating Retrieval Quality](https://www.internhack.in/roadmaps/tracks/ai-engineer/retrieval-evaluation)
- [Advanced RAG Patterns](https://www.internhack.in/roadmaps/tracks/ai-engineer/advanced-rag)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
