What You'll Learn
- 1Compute PSI and a KS statistic and map the value to a drift threshold with a worked example
- 2Size a detection window so a 3 point accuracy drop is found within a stated time budget
- 3Control false alerts across hundreds of monitored features with an alpha correction
- 4Design an error budget and alert ladder from a stated availability SLO
Why This Matters
ML models degrade silently in production. Data drift, concept drift, and infrastructure failures can reduce accuracy without triggering traditional alerts. A robust monitoring system detects issues early, enables root cause analysis, and ensures model reliability at scale.
Silence is expensive because the failure is invisible to the metrics teams already watch. A fraud model whose recall slips from 0.90 to 0.87 loses 30,000 true fraud catches per 10 million scored transactions while error rate and latency stay perfectly flat. Monitoring has to test the model's statistics directly, and that means knowing how many observations each test needs before it can see a real change.
System Architecture Overview
Drift Detection Implementation
Drift detection uses statistical tests to identify distribution shifts. The Population Stability Index (PSI) bins reference and current data into deciles and and compares them:
The convention is: PSI below 0.10 means no meaningful drift, 0.10 to 0.20 means investigate, above 0.20 means retrain. A worked example makes the scale concrete. Take a reference split of 10 percent per decile and a current split of 14, 13, 12, 11, 10, 9, 8, 7, 4, and 2 percent. The tail deciles dominate: the last bin alone contributes (0.02 - 0.10) x ln(0.02 / 0.10) = 0.129, and the ninth adds 0.055, so the sum is 0.226, which is past the 0.20 retrain threshold even though nine of ten deciles barely moved.
Kolmogorov-Smirnov test compares two distributions using the maximum cumulative difference, with p-value below 0.05 indicating significant drift, and unlike PSI it needs no binning, so it works on continuous features with few observations. Concept drift detection compares recent accuracy windows against historical baselines, which requires labels; when labels arrive days late, most teams monitor prediction distribution and confidence as proxies and run the accuracy test on a delayed schedule.
| Signal | Test | Warn | Critical | Typical check window |
|---|---|---|---|---|
| Input feature | PSI on deciles | 0.10 | 0.20 | Hourly on 50K rows |
| Input feature | KS two-sample | p below 0.01 | p below 0.001 | Hourly on 50K rows |
| Prediction distribution | PSI on score bins | 0.10 | 0.20 | Every 15 minutes |
| Accuracy with labels | Two-proportion z-test | 1 point drop | 3 point drop | Daily, label delay dependent |
| Infrastructure | Threshold | p99 above 500 ms | p99 above 1,000 ms | Every minute |
Performance Monitoring
Model monitoring logs predictions, input features, latency, and ground truth (when available) to a metrics store. Threshold-based alerts trigger when latency exceeds limits (e.g., 500ms) or prediction distributions shift. A metrics summary computes total predictions, average/p95/p99 latency, and accuracy over configurable time windows.
Dashboard Design
Monitoring dashboards provide time-series views of model accuracy, latency histograms, feature drift heatmaps (PSI scores), prediction distributions, and throughput. Each panel includes alert conditions (for example, accuracy below 0.85 is critical, p99 above 500 ms is a warning, and PSI above 0.2 is a warning). Dashboards refresh every minute with a 24-hour default time range, and every panel links to the runbook section naming the first three commands to run.
Detection Window Sizing
A drift test is only as useful as its window. To catch accuracy dropping from 0.90 to 0.87 at alpha 0.05 with 80 percent power, a two-proportion test needs:
With and , the sum gives labeled predictions per window. At 100 predictions per second that window fills in 18 seconds; at 1 prediction per second it takes 30 minutes; and with a 3-day label delay the honest wall-clock detection time is 3 days and 30 minutes. In practice the bottleneck is almost never the test, it is the label path, which is why teams monitor prediction distribution and confidence on a live schedule while accuracy is checked on a delayed one.
Monitoring cost is dominated by false alerts, not by compute. Testing every feature independently at alpha = 0.01 fires at a predictable rate:
At m = 200 features that is 2 spurious alerts per run, forever. The Bonferroni correction sets alpha to 5e-5 and drives expected false alerts to 0.002, but it also raises from 1.96 to 4.06, which inflates the required window from 1,773 labels to 5,431 for the same 3-point drop, roughly a 3x cost in detection latency. The cheaper alternative is to group the 200 features into about 10 semantic families and test family aggregates, keeping the test count low without paying the full Bonferroni penalty on every individual feature.
SLOs and Error Budgets
An availability SLO converts directly into a budget of allowed failures over the month:
At 99.9 percent availability over 30 days of 1 million requests per day, is 30,000,000 and the budget is 30,000 errors. The alert ladder is then a statement about how fast the budget is being consumed, not about how bad a single spike looks:
| Tier | Burn rate | Lookback | Budget consumed | Route |
|---|---|---|---|---|
| Page | 14.4x | 1 hour | 2% | On-call phone |
| Ticket | 6x | 6 hours | 5% | Ticket queue |
| Warning | 3x | 24 hours | 10% | Chat channel |
The math behind the ladder is burn rate times window divided by the 30-day window: 14.4 x 1/720 = 2 percent, 6 x 6/720 = 5 percent, and 3 x 24/720 = 10 percent. Paging on a raw error-rate threshold produces false pages during a traffic trough; paging on budget burn rate only fires when the trend, if continued, would exhaust the month's allowance.
Common Mistakes
Alerting on raw thresholds like error rate above 1 percent
Fix: Alert on error budget burn rate over a window, so a 14.4x burn over 1 hour pages while a quiet-hours dip does not
Testing 200 features independently at alpha = 0.01
Fix: Expect 2 false alarms per run; group features into about 10 families or apply alpha' = alpha / m and accept the 3x larger window
Treating PSI thresholds as universal constants
Fix: Calibrate against a backtest of known-good weeks, because a feature with a heavy tail breaches PSI 0.2 on normal noise
Best Practices
- Split monitoring into a live track for prediction distribution and latency, and a delayed track for accuracy once labels land
- Attach a runbook link and the first three commands to every alert so the responder does not search at 3am
- Record the reference window and binning scheme next to every PSI score so two dashboards cannot disagree
Key Takeaways
- PSI on deciles sums (p_i - q_i) times ln(p_i / q_i); below 0.10 is stable, above 0.20 is retrain, and the tail deciles dominate the value
- Detecting a 3-point accuracy drop at alpha 0.05 and power 0.80 needs 1,773 labeled predictions, so label delay, not compute, sets detection time
- Expected false alerts equal features times alpha, which is 2 per run at 200 features and alpha 0.01
- A 99.9 percent SLO over 30M monthly requests is a 30,000 error budget, and alerts should fire on burn rate, not on raw thresholds
Frequently Asked Questions
What is the difference between data drift and concept drift?
Data drift is a change in the input distribution, P(X), while the mapping to the label stays fixed; it usually calls for retraining on fresh data. Concept drift is a change in the mapping itself, P(Y|X), so the old relationship no longer holds and retraining on more of the same distribution will not help. Concept drift is harder to see because inputs can look perfectly normal while the labels have moved.
Which PSI threshold indicates significant drift?
Below 0.10 is stable, 0.10 to 0.20 warrants investigation, and above 0.20 is significant. These are starting points rather than laws: calibrate them against a backtest of known-good weeks and a deliberately degraded model, and pick the threshold that separates the two with acceptable false alarm rate. A feature with a heavy tail will breach 0.20 on ordinary sampling noise, so per-feature thresholds are normal.
How should monitoring differ for LLM applications?
The signals change shape rather than the architecture. Score toxicity and harmfulness on sampled outputs, run fact-checking against retrieved sources to estimate hallucination rate, detect prompt injection in the input, and track output quality metrics such as relevance and coherence. On the serving side, time-to-first-token and tokens-per-request become the latency and cost guardrails, and streaming responses make p99 of the last token as important as p99 of the first.
Interview Questions
Q1: How do you detect silent model failures?
Watch signals that do not need labels: prediction distribution shifts, confidence collapse, feature importance changes, and proxy business metrics such as engagement. Pair them with delayed label evaluation when ground truth arrives days later, and use canary deployments plus a shadow model to compare old and new behavior on identical traffic before anything changes.
Q2: Design a monitoring system that auto-triggers retraining.
Run a pipeline: detect drift with PSI or KS tests, confirm ground truth labels are available for the candidate window, trigger retraining, evaluate the candidate against the production model on a held-out set, then deploy behind a canary with automatic rollback. A human approves any change to a model that touches revenue or safety, because a drift detector that fires on noise would otherwise retrain you into instability.
Q3: How do you choose the monitoring window and evaluation frequency?
Two constraints: the window must hold enough observations to reach power for the smallest drop you care about, and the schedule must fit inside the label delay. For a 3-point accuracy drop that is 1,773 labels, so a high-traffic model can be checked every 15 minutes while a low-traffic one checks hourly. Inputs and predictions are checked live at 15-minute granularity; accuracy is checked daily on a window shifted back by the label delay.