ML System Design

Online vs Offline Evaluation

Why a model with stellar offline AUC can fail completely when deployed to real production users.

🟡 intermediate5 min readevaluationmust-know
Evaluating ML systems requires a two-stage process: Offline Evaluation on historical datasets (ROC-AUC, NDCG, RMSE) and Online Evaluation on live production traffic (A/B testing, CTR, Conversion Rate, Latency). A major challenge in applied ML is offline-online metric misalignment, caused by position bias, selection bias, feedback loops, and static offline data failing to capture dynamic user behavioral reactions.

Comparison Matrix

       HISTORICAL LOGGED DATA                         LIVE PRODUCTION USERS
 ┌─────────────────────────────────┐           ┌─────────────────────────────────┐
 │       OFFLINE EVALUATION        │           │        ONLINE EVALUATION        │
 │  - ROC-AUC, PR-AUC, NDCG@k      │   ─────►  │  - A/B Testing, Interleaving   │
 │  - Fast, cheap, repeatable      │           │  - CTR, Conversion, Latency     │
 │  - Prone to offline-online gap  │           │  - Slow, expensive, real risk   │
 └─────────────────────────────────┘           └─────────────────────────────────┘
DimensionOffline EvaluationOnline Evaluation
Data SourceStatic historical benchmark logsLive production user interaction stream
Primary MetricsROC-AUC, PR-AUC, NDCG, MRR, RMSECTR, Conversion Rate, Retention, ARPU, Latency
Execution CostNegligible (Minutes on GPU/CPU)Expensive (Requires live user traffic & infrastructure)
Safety & RiskZero risk to live businessRisk of revenue loss, bad UX, or customer churn
Primary GoalFilter out weak models quicklyConfirm true business ROI and user experience

Why the Offline-Online Gap Happens

  1. Position & Logging Bias: Offline data records clicks on items recommended by the previous model. Items never shown have zero logs, even if users would have loved them.
  2. Static vs Dynamic Distribution: Offline data assumes user behavior is static. Online, showing new recommendations changes user exploration and long-term engagement.
  3. Goodhart's Law: "When a measure becomes a target, it ceases to be a good measure." Over-optimizing an offline metric (e.g. optimizing pure CTR) leads to clickbait, degrading online long-term retention.

Bridge Techniques: IPS & Interleaving

1. Inverse Propensity Scoring (IPS) for Counterfactual Offline Eval

Reweights logged interactions by the inverse probability that the old logging policy $\pi_0$ displayed action $a$ in context $x$:

$$\hat{V}{IPS}(\pi{\text{new}}) = \frac{1}{N} \sum_{i=1}^N \frac{\pi_{\text{new}}(a_i | x_i)}{\pi_0(a_i | x_i)} \cdot r_i$$

Corrects historical logging bias, providing unbiased offline estimates of new policies!

2. Team Draft Interleaving

Instead of 50/50 user splitting in A/B testing:

Say this out loud

"Offline evaluation filters weak models quickly using historical logs and metrics like NDCG and AUC. Online evaluation validates business ROI using live A/B testing and metrics like CTR and conversion. The offline-online gap occurs due to position bias and logging bias in static data. We bridge this gap using Inverse Propensity Scoring for counterfactual offline evaluation and Interleaving for rapid online pre-testing."

Follow-ups to expect

Check yourself

Question 1 of 3

Why can an offline metric gain (e.g. offline NDCG increases by +2%) fail to translate into an online business win (A/B test CTR is flat or negative)?

More in ML System Design

See all →
A Framework for Any ML Design Round5 minFraming a Business Problem as ML5 minBatch vs Real-Time Inference5 min