MRR and nDCG
Ranking-quality metrics that reward putting relevant docs earlier in the list.
In plain words
They give higher scores when the right answers show up near the top of the results, not just somewhere in the list.
Think of it like…
Search engine results: finding the answer at the top of page one is far better than on page three, even though both "found" it. These metrics are the grade that rewards putting the best result first.
Where you’ve seen it
Before reranking, hybrid retrieval has recall@10 of 0.94 but MRR@10 of 0.58, since the first relevant chunk averages around rank 2 to 3. After adding a cross-encoder, recall@10 is still 0.94 but MRR@10 rises to 0.79 and nDCG@10 from 0.61 to 0.78. Answer accuracy improves by 8 points because the LLM now gets the best chunk first, even though the candidate set didn't change.
Words you’ll hear
- Reciprocal rank
- 1 divided by the position of the first relevant result (0 if none in the list).
- Graded relevance
- Labels with levels (0 irrelevant … 3 perfect) rather than yes/no.
- Discount
- Reducing the value of a result the further down it appears, via log₂(rank + 1).
- Ideal DCG (IDCG)
- The DCG of the perfect ordering, used to normalise to 0–1.
Visual diagram
Theory & deep dive
MRR and nDCG with worked numbers
MRR: for each query take 1 / rank of the first relevant result (0 if there is none in the list), then average. Query 1: first relevant at rank 1 → 1.0; query 2: rank 3 → 0.333; query 3: none → 0. MRR = (1 + 0.333 + 0) / 3 = 0.444. It's easy to read ("on average the first good chunk is around rank 2"), but ignores everything after the first hit.
nDCG@k: with graded labels, gain for a result with relevance r is 2^r − 1, discounted by log₂(rank + 1). Results at ranks 1 to 3 with relevance (3, 0, 2): DCG = 7/1 + 0/1.585 + 3/2 = 8.5. The ideal order (3, 2, 0) gives 7 + 3/1.585 + 0 = 8.893, so nDCG@3 = 8.5 / 8.893 ≈ 0.956. Putting the 2 before the 0 would raise it to 1.0. Because it normalises per query, scores are comparable across queries with different numbers of relevant items.
Top-5 before: relevance (0, 2, 0, 3, 0) → DCG = 0 + 3/1.585 + 0 + 7/2.322 + 0 ≈ 1.893 + 3.015 = 4.908; ideal = 7 + 3/1.585 = 8.893; nDCG ≈ 0.552. After reranking: (3, 2, 0, 0, 0) → nDCG = 1.0, and RR rises from 0.5 to 1.0.
Choosing metrics and interpreting them
Choose by task. For question answering where one passage usually suffices, MRR@k and hit rate are natural. For tasks where several passages feed a summary or multi-part answer, or where relevance has levels (perfect, partial, tangential), nDCG@k fits better. Report the cutoff (nDCG@10, MRR@10) and compare systems at the same cutoff and on the same queries; a metric without @k is ambiguous.
Interpretation tips: nDCG labels must be consistent, so write labelling guidelines and measure annotator agreement (LLM judges can help but should be calibrated against humans); use paired significance tests or bootstrap confidence intervals, since differences of 1 to 2 points on 150 queries can be noise; segment by query type; and remember these are retrieval metrics. A system with better MRR may still not give better answers if the extra relevance doesn't change what the LLM sees. Always connect them to end-to-end measures (answer correctness, citation accuracy) and to user outcomes.
nDCG@10 improves from 0.71 to 0.74 on 150 queries. A bootstrap over queries gives a 95% interval of −0.01 to +0.07 for the difference, so the gain isn't established. With 400 queries the interval becomes +0.01 to +0.05.
How it works, step by step
Step 1 of 41. Define relevance labels
Choose binary or graded labels, write guidelines and label candidates for each query.
- Agree
- on guidelines
When to use it & trade-offs
What it is
Recall@k only asks whether relevant documents appear in the top k. Rank-aware metrics also ask where. MRR (Mean Reciprocal Rank) averages 1 / (rank of the first relevant result): first place scores 1, second 0.5, fifth 0.2. nDCG (normalised Discounted Cumulative Gain) handles graded relevance (for example 0 to 3) and discounts gains by position: DCG@k = Σ (2^relᵢ − 1) / log₂(i + 1), then divides by the best possible DCG (the ideal ordering) so scores fall between 0 and 1. Use MRR when one good answer matters; use nDCG when several results matter and some are better than others.
Why it matters: Position matters twice in RAG: LLMs weigh early context more heavily, and prompt budgets mean only the top few chunks are used. A retriever whose right chunk is ranked 1st and one that ranks it 9th have identical recall@10 but very different answer quality. MRR and nDCG measure the ordering that rerankers, hybrid fusion and score tuning are meant to improve, and they're standard in search benchmarks like BEIR and MTEB.
When to reach for it
- Evaluating rerankers and fusion methods
- Comparing embedding models on ranking quality
- Public benchmark comparisons (BEIR, MTEB)
When to avoid or be careful
- Reporting MRR or nDCG without the cutoff
- Concluding from small differences without significance tests
- Using ranking metrics as a substitute for end-to-end answer evaluation
Ranking metrics compared
Strengths: Simple; independent of order.
Watch out: Ignores position within the top k.
Strengths: Easy to interpret; needs only first-hit labels.
Watch out: Ignores later relevant results.
Strengths: Position-aware, graded and normalised.
Watch out: Needs graded labels; harder to explain.
Interview signals & numbers to know
When this topic comes up
- “What's the difference between MRR and nDCG?”
- “Recall is high but answers are poor”
- “How do you evaluate a reranker?”
- BEIR and MTEB
- Graded relevance labels
Benchmarks & rules of thumb
- 1, 0.5, 0.33
- reciprocal ranks for positions 1, 2, 3
- log₂(rank + 1)
- the nDCG position discount
- 0 – 1
- range of normalised nDCG
Common mistakes & follow-ups
Common interview mistakes
- Using MRR on tasks that need several relevant passages, and ignoring everything after the first hit.
- Comparing nDCG@5 for one system with nDCG@10 for another.
- Celebrating a 0.02 nDCG gain measured on 40 queries.
Likely interviewer follow-ups
- When would you prefer nDCG to MRR?
- Why can two systems with equal recall@10 have different MRR?
- How do you know a metric difference is statistically meaningful?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply MRR and nDCG with generative AI interview Q&A and hands-on practice.