Q&A-1Design an automated retraining pipeline for a production model.
Answer
Clarify first. Two facts decide the design: how fast labels arrive, and what a bad model costs versus a stale one. If labels land in minutes (click-through, ad CTR), retrain daily and gate on live metrics. If they land in 60–90 days (chargebacks, loan default), you cannot wait for labels: you gate on feature drift and offline replay, and you keep a human in the loop. I'll assume a tabular risk model, labels at ~7 days, ~2M predictions/day, and a bad model costing more than a week of staleness.
The pipeline. Trigger → snapshot → validate → train → evaluate → gate → canary → promote or roll back.
Triggers. Scheduled (weekly), drift (PSI > 0.2 on the top-20 features), performance (AUC drop > 2 points on a rolling 7-day window), and data volume (new labeled rows > 20% of the training set). Dedup by hashing (snapshot id, code commit, config) so a flapping drift alert doesn't launch 24 identical runs.
Snapshot. Point-in-time join: for each training row, take feature values as of the prediction timestamp, not as of now. This is the most common leakage source: a "current balance" feature that includes post-outcome updates routinely inflates offline AUC by several points and collapses in production.
Validate. Schema, null rate, range, plus a leakage check: any feature with |correlation| to the label > 0.9, or a timestamp after the label event. Great Expectations or TFX Data Validation for schema; a custom query for the point-in-time check.
Train. Same transform code as serving: a shared feature library (Feast, or a versioned dbt/Spark module), not a re-implementation. Containerize with pinned dependencies; MLflow or SageMaker/Vertex for lineage.
Evaluate. Champion vs challenger on a held-out time slice (last 2 weeks, not a random split), plus slices: new users, top region, low-volume segment. Business baseline: the current rule-based policy.
Gate. Risk-based. Low-risk (no user-visible change, metric parity) auto-promotes; high-risk (pricing, credit, safety) needs a named approver.
Canary. 5% traffic, shadow first. Sample size matters: to detect a 1-point absolute drop from a 5% baseline at 80% power you need ~8,000 per arm. At 2M/day that's minutes of predictions, but if the guardrail metric is a 7-day label, the canary runs 7 days. Pin the model version and the feature-transform version together.
Failure modes.
- Training/serving skew: offline feature computed in Spark, online in Java. Detect by logging online feature vectors and comparing per-entity distributions against the offline table. Silent 3–8 point AUC loss.
- Feedback loop: you only observe outcomes for approved applications. Detect by label coverage per predicted-positive bucket; if coverage in the top decile drops below ~30%, the model is training on its own decisions.
- Trigger storm: dedup hash missing → 24 runs/day, GPU bill spikes, no new data. Detect: runs per distinct snapshot id.
- Rollback that doesn't roll back: model reverted, feature transform already deployed. Version both.
When not to automate. If labels take 90 days and the model is retrained quarterly under regulatory sign-off, automation adds risk without speed. If the model is a lookup table, or the drift is a known seasonal pattern, a scheduled retrain with human review is cheaper and safer. Continuous online learning is the third option: worth it only when drift is fast and the blast radius is small.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.