SD System Design In Depth
0%
lesson system-designsearch

Search evaluation metrics

Module 5.4: Information Retrieval & Search Engines Updated Sep 17, 2026
📄 Cheat Sheet
Every Ranking Metric : MRR, MAP, NDCG
ritvikmath Every Ranking Metric : MRR, MAP, NDCG Watch on YouTube ↗

Works through MRR, MAP and NDCG on the same example ranking so the differences are obvious, exactly what this unit teaches.

0:00 / --:--

Under the Hood: Quantifying Search Quality

You cannot improve search relevance without rigorous mathematical evaluation metrics. In information retrieval, search quality is evaluated using both offline benchmark datasets (judged by human evaluators) and online user telemetry.

The Core IR Evaluation Metrics

MetricFormula & FocusWhen to Use
Precision@K(Relevant in top K) / K. Focuses on purity of the first page.E-commerce product search where top 10 items must be accurate.
Recall@K(Relevant in top K) / (Total relevant in corpus). Focuses on completeness.Legal discovery, patent search, and medical research.
MAP (Mean Average Precision)Average of precision scores at each relevant document rank across queries.Binary relevance evaluations across diverse query sets.
NDCG@KDCG_K / IDCG_K where DCG = Σ (2^relᵢ - 1) / log₂(i + 1).The Gold Standard: Evaluates graded relevance (0-4 stars) with position discounting.

Under the Hood: Interleaving A/B Testing

flowchart TD subgraph TraditionalAB ["Traditional A/B Test (High Variance: large samples needed)"] U1["50% Users -> Model A"] U2["50% Users -> Model B"] end subgraph Interleaving ["Team-Draft Interleaving (roughly 10x to 100x+ fewer users, setting-dependent)"] Q["User Query"] --> Interleaver["Team-Draft Interleaver"] Interleaver --> Combined["Rank 1: Model A #1
Rank 2: Model B #1
Rank 3: Model A #2
Rank 4: Model B #2"] Combined --> ClickTelemetry["Detect which algorithm's items won the user's click!"] end

Interleaving blends the top results of Model A and Model B into a single merged result list presented to every user. Because every user sees both rankers, between-user variance largely cancels out, and published results (Netflix, Bing, Airbnb) report detecting ranker preferences with roughly 10x to over 100x less traffic, depending on the setting.

Worked example: scoring one ranking five ways

A query returns five results with graded relevance (0 to 3) of [3, 2, 3, 0, 1]. Assume these four relevant documents are all the relevant ones that exist.

MetricComputationValue
Precision@5, relevant = grade 1 or more4 relevant out of 50.80
Recall@54 of 4 relevant found1.00
Reciprocal rankFirst relevant at position 11.00
Average precisionMean of P@1, P@2, P@3, P@5 = 1, 1, 1, 0.80.95
NDCG@5DCG 12.78 divided by ideal DCG 13.350.96

DCG uses gain 2 to the power rel minus 1, divided by log2 of position plus 1: 7/1 + 3/1.585 + 7/2 + 0 + 1/2.585 = 12.78. The ideal order [3, 3, 2, 1, 0] gives 7 + 4.42 + 1.5 + 0.43 = 13.35. The only loss is that a grade-3 document sits at position 3 instead of 2, so NDCG is high but not perfect.

Online vs offline evaluation

MethodNeedsStrengthWeakness
Offline judged setHuman labels for a few thousand queriesFast iteration, repeatableLabels age; misses user behaviour
A/B testTraffic split, business metricMeasures real outcomesNeeds large samples, takes days or weeks
InterleavingMerged result listsDetects ranking preference with far less trafficTells you which ranker users prefer, not by how much revenue

Netflix and Microsoft Bing have both published results showing interleaving detects ranker differences with one to two orders of magnitude less traffic than a conventional A/B test, which is why teams use it as a fast pre-screen before a full A/B launch.

Choosing a metric

Use NDCG@10 when you have graded labels and care about the first page; MRR for navigational queries where one right answer exists, such as "gmail login"; Recall@1000 to evaluate the first retrieval stage of a two-stage system, since the re-ranker cannot fix documents that were never retrieved; and business metrics such as conversion or successful sessions to decide launches. Report confidence intervals: a 0.5 point NDCG gain on 200 queries is often noise.

Check yourself Question 1 of 3
Recall in web search recall
From: The Core IR Evaluation Metrics

Why is Recall@K rarely reported as a headline metric for open web or large product search, even though it appears in every IR textbook?

Key Takeaways

NDCG (Normalized Discounted Cumulative Gain) is the gold standard metric for graded relevance rankings.
Precision@K measures top-slot purity; Recall@K measures corpus coverage.
Interleaved A/B testing blends candidate rankings to detect statistically significant user preference with far fewer queries than traditional A/B testing (see: Radlinski & Craswell, 'Comparing the Sensitivity of Information Retrieval Metrics', SIGIR 2010).
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue