Define NDCG@k, MAP and MRR. Why might a model that wins on offline NDCG lose in an online A/B test?
Answer
Model answer, written in a candidate's voice
In short
- NDCG@k: graded gains, log2(i+1) discount, DCG/IDCG per query with IDCG from the ideal ordering of all judged items, averaged over queries
- MAP: per-query average precision over relevant items, averaged over queries
- MRR: per-query reciprocal rank of first relevant item, averaged over queries
- Offline NDCG can be biased by old-policy exposure and position bias
- Offline metrics miss diversity, novelty, latency, and long-term satisfaction
- Fixes: IPS/counterfactual evaluation, interleaving, guardrails, longer-horizon metrics
In full
NDCG@k is the discounted gain of a ranked list divided by the ideal discounted gain: for query q, DCG@k = sum_{i=1..k} gain_i / log2(i+1), IDCG@k is the same sum for the ideal ordering of all judged items for that query (not just the items the model happened to retrieve), and NDCG@k = DCG@k / IDCG@k, then averaged over queries. MAP is the mean over queries of average precision, where per-query AP sums precision at each relevant position (classic MAP uses binary relevance; graded variants exist) and divides by the number of relevant items. MRR is the mean over queries of 1 / rank of the first relevant item. A model can win offline NDCG yet lose online because offline labels are usually collected under the old policy, so exposure and position bias make high-ranked items look better than they are, and the metric only rewards top-k relevance, not diversity, novelty, latency, clicks, retention, or long-term satisfaction. The practical fix is to validate with counterfactual or IPS-style evaluation, interleaving or randomised tests, guardrails for safety and business metrics, and longer-horizon outcomes rather than trusting offline NDCG alone.
What a strong answer covers
- Correct definitions (graded gains and log discount; per-query averages).
- Offline labels are biased by the old policy (exposure/position bias).
- Offline metrics miss diversity, novelty, latency and long-term satisfaction.
- Fixes: counterfactual or IPS evaluation, interleaving, guardrails, longer-horizon metrics.
Common mistakes
- computing the ideal DCG from the model’s own ranking
- ignoring position bias in click labels.