Set Metrics: Precision, Recall, MAP, and MRR as Estimators
The published stack measured recall@k everywhere and never defined it; here the whole set-metric family is defined over real rankings — precision and recall at a cutoff, the precision–recall curve and Average Precision as the area beneath it, MAP and MRR — and then reframed as what they actually are: sample means with standard error, so a reported gap is not a real one until it clears sampling noise
Overview & motivation
The retrieval problem ended with a ranking: a query , a score on every document , and the top- returned as a set. Everything the curriculum built afterward — BM25, dense dual encoders, IVF and product quantization, late interaction served by PLAID, reciprocal-rank fusion — was judged by a single recurring number, recall@k. The capstone reported it a dozen times. Not once did we say what it means.
That is the gap this topic closes. An evaluation metric is a functional that takes a ranking and a set of relevance judgments and returns a number. Write the judgments as a qrel set : the documents a competent analyst would mark relevant to query . Because we want every number on this page to be a measurement rather than an illustration, we do not invent rankings — we score three real retrievers over a shared finance corpus. The lexical leg is BM25, the dense leg is a pooled dual encoder, and the strongest leg is late interaction, each producing a full ranking of documents for each of queries. The relevance judgments are the top- documents under exact MaxSim, a neutral oracle: no single leg is the ground truth, so the three genuinely differ in quality, and “relevance” is a fixed target they all approximate.
Slide k right: recall never falls (each new relevant doc can only add coverage), while precision wobbles — it jumps up when slot k is relevant and decays when it is not. Recall reaches 1.0 once all 10 relevant docs are passed; precision at that point is only 10/(last relevant rank).
120 synthetic finance documents, 40 queries; relevance is the top-10 exact-MaxSim neighbor set (a neutral oracle). Numbers mirror set_metrics_precision_recall_map_mrr.py; the lab recomputes precision, recall, the PR/AP area, the mean, and the CI in closed form.
The lab above is the topic in miniature, and we will return to each of its four panels in turn. The arc is short: define the metrics on one ranking, integrate them into a curve, average them across queries — and then admit that every resulting number is a noisy estimate.
Set metrics at a cutoff: precision and recall
Fix a query and a cutoff . Of the top documents the system returned, write for the number that are relevant (true positives). The two foundational metrics divide this count two ways.
Definition 1 (Precision and recall at a cutoff).
For a ranking with qrel set (with ) and a cutoff ,
Precision is the purity of the cutoff — what fraction of what you returned is relevant — and recall is the coverage of the relevant set — what fraction of what you should have returned you did. Their harmonic mean is the score, .
The denominator of recall is , the size of the relevant set. This is the textbook convention, and it is worth a word because it differs from the one the capstone used: there, recall divided by , a cascade-retention reading (“of the slots, how many true neighbors survived”). The two agree exactly at , the capstone’s only operating point, so this topic defines precisely the recall@10 the capstone reported; the form is what generalizes the curve, because it makes the next proposition true.
Proposition 1 (Recall climbs, precision wobbles).
As the cutoff increases, is non-decreasing, and . Precision is not monotone.
Proof. The set contains , so is non-decreasing in ; dividing by the constant preserves this. At every document is returned, so and . For precision, rises by one exactly when document is relevant, while the denominator rises by one every step; so exceeds when the new document is relevant and falls when it is not.
Panel A makes the asymmetry tactile. Drag the cutoff across the worked query’s ranking: each slot is a true positive (relevant and retrieved), a false positive (retrieved, not relevant), or — beyond the cutoff — a false negative (relevant, missed). Recall only ever rises as the line moves right; precision jumps up on a relevant slot and decays on an irrelevant one. A single pair is a point on a plane; the whole topic is what happens when we let run.
The precision–recall curve and Average Precision
Sweeping from to traces a path in the precision–recall plane. Because recall only changes when a relevant document is hit, the informative points are exactly those hits. Let the relevant documents sit at ranks (with ); at the -th hit, recall is and precision is . Connecting these corners gives the familiar sawtooth — and the single most useful summary of a ranking is the area beneath it.
Theorem 1 (Average Precision is the area under the PR curve).
Define Average Precision as the mean of precision at the relevant ranks,
Then equals the area under the (raw) precision–recall curve,
Proof. At rank exactly relevant documents have been retrieved, so recall steps from to — an increment — and precision there is . Between consecutive relevant ranks recall is constant, so those stretches add nothing to a recall-integrated sum. Hence .
This is a Riemann sum over the recall axis: the relevant documents partition into equal increments of width , and AP is the sum of precision times those widths — the area-as-a-limit-of-sums construction applied to a step function. The proof also explains the denominator rather than “number of documents retrieved”: a relevant document that never surfaces contributes a missing recall step, i.e. a term of zero, which correctly drags AP down. Dividing by the count actually found would give a ranking that retrieves one of ten relevant documents (at rank 1) an AP of — exactly wrong.
Panel B draws this. The shaded bars are the recall steps; their total area is AP. Toggle the interpolated envelope and a second, larger area appears.
Mean Average Precision
A single query’s AP is a property of one ranking. To score a system we average over a query set.
Definition 2 (Mean Average Precision).
For a set of queries, , the sample mean of per-query Average Precision.
Over our three legs the MAP values are a clean quality ladder: lexical , dense , late interaction . Panel C shows why an average is the right summary — the per-query AP scatter widely (the late-interaction leg ranges from below to a perfect ), and only their mean is stable. That scatter is not noise to be ignored; it is the metric’s variance, and we return to it.
Reciprocal rank and known-item retrieval
Some queries have one right answer — the filing that announced a merger, the slide that stated a guidance number. There, what matters is not coverage of a set but how high the one answer ranks.
Definition 3 (Reciprocal rank and MRR).
The reciprocal rank of a query is , where is the rank of the first relevant document (and if none appears). The Mean Reciprocal Rank is .
MRR is built for the known-item regime, where each query has exactly one relevant document — and there it is not a different animal from AP at all.
Proposition 2 (MAP equals MRR in the known-item regime).
If every query has exactly one relevant document ( for all ), then for every query, and hence .
Proof. With , the single relevant document sits at some rank . Average Precision has one term: . The first (and only) relevant document is at rank , so too. The per-query metrics coincide, and so do their means.
This is the topic’s collapse anchor: at the whole apparatus of precision, recall, and the PR curve degenerates to a single reciprocal rank. Panel C makes it visible — switch to the known-item regime and the per-query AP strip lands exactly on the reciprocal-rank strip, mean line and all. Because MRR is degenerate when relevant sets are large (with ten relevant documents some leg almost always lands one near the top, so reciprocal rank says little), we score it in the regime it was built for: relevance is the single top-1 oracle document.
Holding both metrics in view exposes something the quality ladder hid. The MAP ranking is lexical dense late interaction; the MRR ranking is dense lexical late interaction.
Proposition 3 (Metric choice can reverse the verdict (demonstrated)).
On this corpus, dense beats lexical on MAP ( vs ) but lexical beats dense on MRR ( vs ). The verdict between two systems reverses depending on the metric.
The mechanism is structural: MAP rewards ranking the whole relevant set high, and the dense leg does that better on average; MRR rewards getting one relevant document to the very top, and the lexical leg’s exact-match behavior more often plants a relevant document at rank 1. This is a demonstrated proposition on one corpus, not a theorem — but it is built and run before it is stated, and it makes the lesson concrete: “system A is better” is meaningless without naming the metric.
Metrics as estimators
Here is the move the rest of the evaluation layer rests on. A MAP of is not a property of the dense retriever; it is the sample mean of forty per-query AP values, and a different forty queries would give a different number. Every metric on this page is an estimator of an unknown population quantity, and estimators have variance.
Definition 4 (MAP as an estimator with standard error).
Treat the per-query Average Precisions as a sample with mean and sample standard deviation . The standard error of the MAP estimate is
and the standard error shrinks like : quadrupling the query count halves the interval.
That rate is not a heuristic; it is a concentration inequality. The per-query AP are bounded in , so Chebyshev’s inequality already gives a confidence interval from the variance alone, and the sub-Gaussian (Hoeffding) bound sharpens it — the sample mean concentrates around its expectation at a rate controlled by the query count. The companion notebook verifies the rate empirically: resampling the per-query AP at growing , the measured standard error tracks , and holds essentially constant.
Panel D is the payoff. It plots two legs — dense and late interaction — with their 95% intervals, and a slider for the query count . The gap in MAP is real (), but at few queries the intervals overlap: you cannot tell the systems apart. They separate only at . Below that, the honest report is “indistinguishable on this query set,” not “late interaction wins.”
Connections
- that topic established retrieval as ranking by a relevance functional and returned a top-k set; this one defines how to SCORE that returned set against relevance judgments, turning the qualitative 'return the relevant documents' into the precision, recall, AP, MAP, and MRR the rest of the evaluation layer is built on the-retrieval-problem
- the lexical leg whose ranking we score: BM25 over the quantized token vocabulary is one of the three real retrievers whose precision–recall curves, AP, and MAP this topic measures against the shared ground truth bm25-binary-independence-model
- the dense MIPS leg whose ranking we score: its pooled-vector dual-encoder scores produce one of the three real rankings, and it is half of the dense-versus-late-interaction comparison whose confidence intervals overlap until twelve queries dense-retrieval-dual-encoders
- the late-interaction leg whose ranking we score: its MaxSim signal (served centroid-style) is the strongest of the three legs by MAP, and the exact-MaxSim version of it is the neutral oracle that defines relevance here late-interaction-learned-sparse
- the capstone measured recall@k a dozen times without ever defining it; this topic defines exactly that recall@k (and its whole family) over the same legs, corpus, and exact-MaxSim ground truth, so it retroactively grounds every recall number the capstone reported capstone-multimodal-financial-rag
References & Further Reading
- book Introduction to Information Retrieval — Manning, Raghavan & Schütze (2008) Chapter 8: evaluation in information retrieval — precision, recall, the precision–recall curve, interpolated precision, MAP, and the eleven-point interpolated average precision
- paper Evaluating Evaluation Measure Stability — Buckley & Voorhees (2000) The empirical case that retrieval metrics are noisy estimators: how many queries (and what error rate) it takes before a measured difference between two systems is reliable — the motivation for treating MAP as an estimate with variance; SIGIR 2000
- book Test Collection Based Evaluation of Information Retrieval Systems — Sanderson (2010) A survey of the Cranfield evaluation paradigm: qrels, pooling, the metric family, and the reliability and significance of measured differences; Foundations and Trends in Information Retrieval 4(4)
- book An Introduction to the Bootstrap — Efron & Tibshirani (1994) The resampling estimate of a statistic's standard error and confidence interval used here to cross-check the analytic SE = std/sqrt(n) of MAP, since the per-query AP are bounded and skewed
- documentation ir_measures — a single interface to the IR evaluation measure zoo — MacAvaney et al. Documentation for the conventions behind AP, MAP, MRR, and the interpolation variants — concrete evidence that 'AP' names a family of conventions, not one number