Precision and recall, cut at k
Precision at 5 asks how many of the five results were useful. Recall at 5 asks how many of the useful documents made it into five.
Recall at a small has a ceiling below 1 whenever there are more relevant documents than slots, which is why the two are always read together.
Neither notices order. A relevant document at position 1 and at position 5 score identically, and for a system feeding a model that is a real omission.
MRR, for when there is one right answer
- : the position of the first relevant result for query .
First place scores 1, second scores 0.5, third 0.33, and a query with nothing relevant scores 0.
It is the right metric for question answering and navigational search, where the user wants one answer and will not read past it.
It ignores everything after the first hit, so a system that returns one good result and four terrible ones scores perfectly.
nDCG, which uses the order and the grades
- : the graded relevance of the result at position , often 0 to 3.
The numerator rewards higher grades exponentially, so one excellent result outweighs several mediocre ones.
The denominator discounts by position, so the same document is worth less the further down it appears.
Dividing by the best possible ordering normalises it to the range 0 to 1, which makes queries with different numbers of relevant documents comparable.
One evaluation, in order
- Fix a query set that reflects real traffic, not invented questions.
- Label the relevance of the pooled results from every system being compared.
- Compute the metrics per query.
- Average across queries, and report the spread as well as the mean.
- Fix to what the downstream stage actually consumes.
Pooling matters. Labelling only one system's results and evaluating another against those labels counts its unlabelled correct answers as wrong.
Choosing which one to report
Measure the retrieval stage by recall at .
The first stage's job is not to miss anything, because nothing downstream can recover a document that was never returned.
Measure the rerank stage by nDCG at or by MRR.
The reranker's job is order, so it should be measured by a metric that knows about order.
For RAG, measure recall at , where is the context budget.
For retrieval feeding a model, recall at the number of chunks that fit is the number that predicts answer quality.
Precision matters too, because irrelevant context measurably degrades the generation.