What is training-serving skew? How do you detect it and how do you design it out?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Training-serving skew is when the features a model sees at inference differ from the ones it was trained on, so it is scoring a distribution it never fitted. Offline metrics look fine, production quietly underperforms, and nothing throws an exception. That silence is what makes it the most expensive class of ML bug.
Full worked answer with diagram
Training-serving skew is when the features a model sees at inference differ from the ones it was trained on, so it is scoring a distribution it never fitted. Offline metrics look fine, production quietly underperforms, and nothing throws an exception. That silence is what makes it the most expensive class of ML bug.
Causes, roughly in order of how often I have actually seen them:
- Two implementations. Training features come from a Spark or SQL batch job; serving features come from request-path code in another language. They diverge the moment either side changes.
- Time travel. A training row for an event at time
tgets joined against a feature snapshot that already contains data from aftert. Training saw a value serving can never have. - Different null handling. Training imputes the training-set median; serving sends 0.
- Freshness skew. Training used a feature aggregated over a complete day; serving reads a partially materialized one.
- Preprocessing version drift. Scaler statistics, vocabulary, or tokenizer out of sync with the checkpoint.
Designing it out:
- One definition per feature, consumed by both paths. This is the real reason feature stores (Feast, Tecton) exist; the storage is incidental.
- Point-in-time correct joins when assembling training sets, so a row only ever sees what was knowable then.
- Ship preprocessing inside the artifact (a sklearn Pipeline, a torch module, the serving graph) so nobody can reimplement it.
- Log the exact served feature vector and reuse those logs as the next round's training data. For logged features, skew becomes structurally impossible.
Detection, because prevention is never complete: compare distributions of served vectors against the training set per feature (PSI or KL against a reference window) and alert. Better, run a shadow job that replays logged requests through the training pipeline and diffs feature values. Any nonzero diff rate is a bug. I would much rather read "5% of rows disagree on feature X" than spend a week hunting a mysterious AUC drop.
Worth sketching. Two boxes computing the same feature is the bug; the replay arrow underneath is the only thing that proves you do not have it.
flowchart TD
A["One feature definition"] --> B["Batch path:<br/>Spark or SQL job"]
A --> C["Serving path:<br/>request-time code"]
B --> D["Training rows"]
C --> E["Served feature vectors"]
D --> F["Model"]
E --> F
E -->|"log, then replay through<br/>the training pipeline"| G["Diff the values:<br/>any nonzero rate is a bug"]
D --> G
What a good answer covers
- Training-serving skew is when the features a model sees at inference differ from the ones it was trained…
- Offline metrics look fine, production quietly underperforms, and nothing throws an exception
- That silence is what makes it the most expensive class of ML bug
- Two implementations
- Time travel
Key terms: Two implementations · Time travel · Different null handling · Freshness skew · Preprocessing version drift · One definition per feature · Point-in-time correct joins · Ship preprocessing inside the artifact
Interviewer follow-ups to expect
Give me a concrete point-in-time join and show me where the naive version leaks. Your PSI alert fires on one feature. How do you tell a real upstream change from a broken pipeline?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep