Hit rate tells you whether the right document appeared in the top 10, but it says nothing about where it appeared. Mean Reciprocal Rank, or MRR, averages 1 divided by the rank of the first correct document, so a correct answer at rank 1 scores 1.0 and at rank 10 scores 0.1. Normalised Discounted Cumulative Gain, or nDCG, goes further: it scores a whole ranked list, giving more credit to relevant results at the top. Use MRR when one right answer is enough, and nDCG when several relevant chunks should rank in order.
What you need
- A test set of questions with the known correct document for each
- The ranked results the retriever returned, in order
- A fixed top-k, for example the top 10
Step 1: Record the rank of the first correct result
For each question, note the rank where the correct document first appears. If it never appears in the top-k, the reciprocal rank for that question is zero.
Step 2: Compute MRR across the test set
Take 1 divided by the rank for each question and average the values. A published RAG benchmark used MRR alongside top-10 recall and top-1 recall, which shows the three measures answer different questions.
Step 3: Compute nDCG when several answers matter
When a question has several relevant chunks, score the whole ranked list with nDCG so a list with the best chunks at the top scores higher than the same chunks in a worse order. Compare configurations on the same test set.
Worked example: synthetic MRR for 4 questions
The table below is a synthetic example. It shows the expected result of computing MRR; no retriever was run.
| Question | Rank of first correct | Reciprocal rank |
|---|---|---|
| Refund policy | 1 | 1.00 |
| Setup steps | 3 | 0.33 |
| Pricing tiers | 2 | 0.50 |
| Support hours | Not in top 10 | 0.00 |
Expected result (UNTESTED). MRR is 0.46 across the 4 questions, with the support-hours question scoring zero because the correct document never appeared. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- MRR only looks at the first correct result, so it ignores whether other good chunks also ranked well.
- nDCG needs relevance grades for every chunk, which costs more labelling than a simple hit or miss.
- Both metrics depend on the top-k you choose; compare configurations at the same top-k.
- A high MRR with a low hit rate means the retriever is precise when it works but misses too often.
