Retrieval Metrics: Recall@k, MRR, nDCG?
How recall@k, MRR and nDCG score a RAG search, with a worked bank example and the trade-offs, for your AI interview.
In short
Recall@k asks how many of the right pieces of text (chunks) appear in the top k results. MRR asks how high the first right chunk sits, and nDCG rewards right chunks that sit near the top. All three need a test set where someone has marked which chunks are correct.
12 min readIntermediateVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Retrieval metrics score the search step of a RAG app before the model writes anything. I start with real questions where someone has marked the correct chunks. Recall at k counts how many of those correct chunks land in the top k results. MRR looks at how high the first correct one sits. nDCG gives credit to every correct chunk, more when it sits near the top. I read them together, because a search can score well on one and badly on another.
A RAG app answers from the chunks its search returns, so the search has to be right before the model sees anything. To measure it, I build a test set of real questions. For each one, a person marks which chunks hold the answer. Those marks are the ground truth, and every score depends on them.
Recall at k is the simplest. Take the top k results, usually 3, 5 or 10, and count how many of the marked chunks appear. If the answer needs two chunks and one of them is in the top 3, recall at 3 is one half. MRR, mean reciprocal rank, is 1 divided by the position of the first correct chunk, averaged over the questions. It cares about getting one good hit near the top. nDCG, normalised discounted cumulative gain, handles several correct chunks. Each hit counts for more the higher it sits, and the total is compared with the best possible order.
I read the three numbers together. A high MRR with low recall means the search finds one good chunk quickly but misses the others the answer needs. In a bank's policy assistant, that can mean the right fee clause never reaches the model. Recall at k is the number I watch first, and nDCG and MRR tell me about the order. Retrieval scores don't prove the final answer is right, so I also score the answers themselves.
What are recall@k, MRR and nDCG, in plain words?
A RAG app (retrieval-augmented generation: it searches your documents first, then has the model answer from what it found) takes chunks, which are short pieces of text, from a search and hands the best ones to the model. Retrieval metrics score that search step on its own. They answer two questions: did the search return the right text, and in what order?
Picture a paralegal at a law firm asked for every liability clause across 40,000 supplier contracts. They hand the lawyer a short stack of pages. The lawyer can judge that stack three ways: were the right pages in it, how soon did the first good page appear, and were the best pages on top. The three numbers are those checks, scored.
Key words
- Chunk
- A short piece of a document, cut so it fits in a prompt.
- Top k
- The first k results the search returns, for example the top 3.
- Ground truth
- The chunks a person has marked as holding the answer.
- Hit
- A returned chunk that is in the ground truth.
All three metrics need a test set first: real questions, with the correct chunks marked by a person. Without the marks, there is nothing to measure against.
How do the three metrics differ?
All three read the same ranked list, but each looks at it from a different angle. Recall ignores the order inside the top k. MRR looks only at the first hit. nDCG counts every hit and gives more weight to hits near the top.
Three scores from one ranked list
Test question
a real question from the logs
Retriever
returns its top k results
Labelled answers
chunks a person marked correct
Hit or miss per slot
compares each slot with the labels
Three scores
Recall@k
how many correct chunks were found
MRR
how soon the first hit shows
nDCG
hits, weighted by their position
- 1The test question goes to the retriever.
- 2Its ranked list of top k results goes on to the check.
- 3The labelled answers go to the same check.
- 4Recall counts the hits found in the top k.
- 5MRR reads the position of the first hit.
- 6nDCG weighs every hit by how high it sits.
- Recall@k
How many correct chunks made the top k
The share of the marked chunks that appear in the first k results. Order inside the top k does not matter.
- MRR
How soon the first hit appears
1 divided by the position of the first hit, averaged over the questions. A hit at position 1 scores 1, and at position 2 it scores 0.5.
- nDCG
Every hit, weighted by position
Each hit counts for less the lower it sits. The total is divided by the best possible total, so 1 is perfect.
“MRR ranges from 0 to 1, where 1 is perfect (correct answer always first).”
Anthropic
The standard form of this measure uses a logarithmic discount, so later positions count for less. The ML.NET reference defines DCG as a sum of gains by position, where each gain is a relevance score. That is what lets nDCG handle hits of different value, where one correct chunk can matter more than another.
Tip
In an interview, say the three in one breath: recall for coverage, MRR for the first hit, nDCG for the whole order. Then add that all three need labels.
How do you score a retriever with a worked example?
A bank's support assistant answers from about 3,000 pages of policy. The team's test set holds 200 real customer questions, each with its correct chunks marked by a person. Here are four rows from that set, each with the top 3 results. A slot is a hit (1) when its chunk is marked correct, and a miss (0) otherwise.
# Scores a bank's policy search on 4 labelled test questions. Each slot is a hit (1) or a miss (0).
import math
TESTS = [
(["c07", "c03", "c12"], {"c12"}),
(["c31", "c18", "c33"], {"c31", "c33"}),
(["c09", "c21", "c17"], {"c44"}),
(["c56", "c55", "c60"], {"c55", "c56"}),
]
def scores(ranked, correct, k=3):
hits = [1 if c in correct else 0 for c in ranked[:k]]
recall = sum(hits) / len(correct)
first = next((i + 1 for i, h in enumerate(hits) if h), None)
mrr = 1 / first if first else 0
# the log base cancels in dcg / ideal, so log2 gives the same nDCG as ln
dcg = sum(h / math.log2(i + 2) for i, h in enumerate(hits))
ideal = sum(1 / math.log2(i + 2) for i in range(min(k, len(correct))))
return recall, mrr, dcg / ideal
for n, (ranked, correct) in enumerate(TESTS, 1):
recall, mrr, ndcg = scores(ranked, correct)
print(f"Q{n}: recall@3 {recall:.2f} MRR {mrr:.2f} nDCG@3 {ndcg:.2f}")
rows = [scores(r, c) for r, c in TESTS]
avg = [sum(row[i] for row in rows) / len(rows) for i in range(3)]
print(f"Average: recall@3 {avg[0]:.2f} MRR {avg[1]:.2f} nDCG@3 {avg[2]:.2f}")Output
Q1: recall@3 1.00 MRR 0.33 nDCG@3 0.50 Q2: recall@3 1.00 MRR 1.00 nDCG@3 0.92 Q3: recall@3 0.00 MRR 0.00 nDCG@3 0.00 Q4: recall@3 1.00 MRR 1.00 nDCG@3 1.00 Average: recall@3 0.75 MRR 0.58 nDCG@3 0.60
Read the individual rows as well as the averages. Q1 found its only correct chunk at position 3, so recall is full while MRR drops to 0.33. Q2 has two correct chunks, both in the top 3. MRR says 1.00, but nDCG says 0.92, because the second hit sits lower. Q3 is the real failure: the clause that answers the question is outside the top 3, so every score is zero. Raising k to 10 might catch it, but the model then reads more text. Q4 is the goal. Across the four, recall at 3 averages 0.75, MRR 0.58 and nDCG 0.60.
Tip
Four rows are only a demo. A real test set has hundreds of questions, so check the averages and read the zeros. The zeros show exactly what the search misses.
What do the numbers miss, and what do you tune?
A bigger k never lowers recall, but it feeds the model more text, including weaker chunks. Precision is the share of returned chunks that are correct. Anthropic's cookbook says the balance between precision and recall depends on the use case, and that high recall is often prioritised, because the model can filter out weak chunks. Recall is only as trustworthy as the labels, so the labels must mark every correct chunk.
“Computing recall requires your ground-truth to contain all relevant items.”
Databricks on Microsoft Learn
“In many RAG systems, high recall is often prioritized, as LLMs can filter out less relevant information during generation.”
Anthropic
Retrieval scores also stop short of the answer. A RAG app can respond poorly even after retrieving the correct context, and it can respond well after a weak retrieval. So I measure the final answers too, for accuracy and for whether they stay grounded in the chunks they were given.
- 1
Label first
Mark the correct chunks for each test question. Without the marks, recall has nothing to count against.
- 2
Fix what is missing
Raise k, or improve the chunking and the search, until the correct chunks reach the top k.
- 3
Then fix the order
Add a reranker (a second pass that re-sorts the results), then watch MRR and nDCG move.
- 4
Then check the answers
Score the final answers too, since a good search does not guarantee a good answer.
Tip
Keep the test set fixed. Change one thing, re-run the same questions, and compare the same three numbers.
How would you measure a search over 40,000 contracts?
A legal team searches 40,000 supplier contracts. Lawyers ask two kinds of question. A lookup needs one clause, so one good hit is enough. A sweep, such as every contract with an uncapped liability clause, needs every match. One average would hide the difference, so I score the two kinds apart.
Lookups: MRR
MRR shows how fast the right clause reaches the top, which is what a lawyer needs for a single answer.
Sweeps: recall at k
Recall at the k that lawyers would actually read shows whether all the matches are in the list.
Ordering: nDCG
nDCG shows whether the most relevant matches come first when several clauses count.
Misses: read them
Read the questions that score zero. They show which contract layouts the chunking breaks, such as scanned pages.
Then I change one thing at a time, re-run the same labelled set, and report the three numbers for each kind of question.
What does the interviewer want to hear?
A strong answer covers
- Recall@k: the share of the marked correct chunks found in the top k.
- MRR: it scores the first hit only, so one good hit near the top counts.
- nDCG: it weighs every hit by position and scores against the best order.
- All three need labelled test questions, with the correct chunks marked.
- A bigger k can raise recall, but it adds weaker text, and retrieval scores don't prove the answer is right.
- You would also score the final answers as well as the search.
Common traps
Trap"A high MRR means the retriever finds everything."
BetterMRR only looks at the first hit. Recall at k tells you how much of the answer set was found.
Trap"nDCG and recall are the same thing with a different name."
BetterRecall ignores order inside the top k. nDCG weighs each hit by its position.
Trap"We can score retrieval without labels."
BetterRecall needs the full set of correct chunks marked. Without labels there is nothing to count against.
Can you spot the mistake?
Spot the mistake
A teammate says the search is fine, because its MRR is 0.91. What is missing from that claim?
Quick check
In the bank's policy search (top 3), a wrong chunk sits at position 1 and the correct clause at position 2. The clause moves up to position 1, and the wrong chunk drops to position 2. Which score changes?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Building a search that your team needs to measure?
I design and build AI products and agents, the screens and the system behind them. Book a short call and tell me what your search needs to find.