How do you evaluate the retriever in a RAG (retrieval-augmented generation) system separately from the generator? Suppose three queries have relevant chunk IDs , and , and the retriever returns top-5 lists , and . What are the recall@5, precision@5, hit rate@5 and MRR (mean reciprocal rank), and how does scoring both retrieval and generation let you separate a retrieval miss from a generation error?
ML systems and evaluation, Retrieval evaluation
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can decouple retrieval quality from LLM (large language model) generation quality in a RAG (retrieval-augmented generation) pipeline and compute standard top- retrieval metrics.
Key idea
Evaluating a RAG system end to end hides where errors happen, so you score the retriever against ground-truth relevant chunks and the generator against both the retrieved context and the reference answer. Recall@5 measures coverage of relevant chunks, precision@5 measures how clean the top 5 are, hit rate@5 checks whether at least one relevant chunk appeared, and MRR (mean reciprocal rank) averages the inverse rank of the first hit.
Steps
- Define the four top- retrieval metrics for across queries: for query with relevant set and retrieved top-5 list , , , if else , and reciprocal rank where is the rank of the first relevant chunk (or if none is retrieved).
- Score query 1 (, ): two relevant chunks appear at ranks 2 and 4, so , , , and .
- Score query 2 (, ): only appears (at rank 1), so , , , and .
- Score query 3 (, ): no relevant chunk appears, so , , , and .
- Average across the three queries: , , , and .
- Evaluate the generator separately using two checks: faithfulness (groundedness, whether every claim in the answer is supported by the retrieved chunks rather than hallucinated) and answer correctness (whether the answer matches the ground-truth answer). Scoring both sides isolates failures: low recall@5 with a wrong answer points to a retrieval miss (as in query 3), whereas high recall@5 with low faithfulness or low answer correctness points to a generation or prompting error.
Common mistakes
- Evaluating only final answer accuracy; when answers are wrong, you cannot tell whether to fix chunking and embeddings or change the prompt and LLM.
- Optimising precision@5 at the expense of recall@5; for multi-fact questions, missing even one required chunk prevents a grounded generator from answering completely.
- Assuming high faithfulness means the answer is correct; a generator can faithfully summarise irrelevant retrieved chunks and still produce a wrong answer.
How long your answer should be
About 3–4 minutes: per-query numbers, four averages, and two sentences on generator metrics and error attribution.
Read this
Previous in ML systems and evaluation: A classifier on 1,000 test examples has TP = 10, FN = 10, FP = 5 and TN = 975. Compute the accuracy, the F1 score and the Matthews correlation coefficient, . What do these give for a model that always predicts negative?
Next in ML systems and evaluation: How do you monitor a deployed ML (machine learning) model when ground-truth labels arrive weeks late or never arrive at all?