ML Systems Lab Open interactive version →
Advanced 24 min read RecSysNDCGA/B testoffline-online gapevaluation

Offline vs Online Evaluation

Why NDCG/recall diverge from CTR/retention — the offline-online gap and A/B tests

You can compute a beautiful NDCG@10 on last month's logs, ship the model, and watch engagement *drop*. This isn't a bug in your metric — it's the structural gap between what offline evaluation can measure and what the live system actually does. Understanding *why* the two diverge is what separates a metric-chaser from someone who can be trusted to ship.


Offline metrics score a ranking against logged relevance; each measures something narrower than "good recommendations." Recall@k — did the relevant items make the shortlist (retrieval's metric). NDCG@k — are relevant items ordered near the top, position-discounted (ranking's metric). MAP — mean average precision across the ranked list. AUC — probability a random relevant item outranks a random irrelevant one. All are computed on *historical* logs, and that's the catch.


Why offline and online diverge — four structural reasons

- Logs are biased: offline "relevance" is what the *old* model exposed, so a new model that surfaces different-but-good items is *penalized* offline for disagreeing with the old model's choices. - Counterfactual blindness: offline metrics can only score items that were logged; a genuinely better item the old system never showed has no label, so its win is invisible. - Metric ≠ objective: NDCG on clicks rewards clickbait; the business cares about dwell, retention, revenue, and harm — offline click-NDCG can rise while long-term value falls. - No system effects: offline eval can't see diversity, freshness, feedback loops, or how the recommendation changes future behavior.


Online evaluation measures the objective directly, via A/B tests. Split traffic, ship the candidate to one arm, and measure CTR, dwell, session length, retention, revenue — the things offline metrics only proxy. The discipline: offline metrics are a cheap *filter* (kill obviously worse models before they touch users), never the *decision* (the A/B test decides). Watch for the traps — novelty effects (a new model gets a temporary bump), delayed metrics (retention takes weeks), guardrail metrics (don't win CTR by raising a harm metric), and sample-ratio mismatch (SRM: the observed control/treatment traffic split doesn't match the intended ratio — e.g. 48/52 instead of 50/50 — a sign the randomization or logging pipeline itself is broken, which invalidates trust in the whole test's readout, not just one metric). The offline-online gap is not eliminated; it's *managed*: use offline to filter, online to decide, and treat a persistent gap as a signal that your offline proxy or your logs are broken.

Key points

Takeaway

Offline metrics (recall@k, NDCG@k, MAP, AUC) are cheap proxies on biased historical logs; online metrics (CTR, dwell, retention, revenue) measure the real objective on live traffic. They diverge structurally — biased logs, counterfactual blindness, metric≠objective, and unseen system effects — so the discipline is offline-to-filter, online-A/B-to-decide, treating a persistent gap as a broken-proxy alarm rather than noise.

Recap

Check your understanding

Q1. A new ranker has clearly higher NDCG@10 offline than the incumbent, but in an A/B test its engagement is *lower*. Which explanation is most consistent with how offline evaluation works?

Q2. Why can't offline evaluation reliably credit a model that recommends genuinely great items the old system *never showed*?

Q3. Your candidate ranker wins CTR in an A/B test. Before shipping, select the *two* most important additional checks.

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →