Skip to content
RED SAGSkills
hardMachine Learning Engineer interview question

A model performs much worse in production than in offline tests. How do you find and prevent training-serving skew?

What the interviewer wants to hear

  • Log served features and predictions; replay offline
  • Compare feature distributions between training and serving
  • Common causes: different code paths, time travel leakage, defaults for missing values
  • Prevent with shared feature logic and point-in-time joins
  • Add tests and monitoring for skew

Model answer

First I make sure I can see what production sees: log the exact feature vectors and predictions for a sample of requests. Then I recompute the same rows with the offline pipeline and compare feature by feature. Large differences point to the cause. Typical causes are separate code for training and serving, such as SQL versus a Java service, different handling of missing values, unit or timezone differences, and stale caches. Another cause is leakage offline: training features built with data from after the prediction time, which makes offline scores too good. To prevent it, I use one feature definition for both paths, often through a feature store, and build training data from logged features or point-in-time joins. I add unit tests that compare both paths on fixed examples, and monitoring that alerts when serving feature distributions move away from training.

Can you answer it under time pressure?

Take a timed hard round and get scored on every answer.

Start mock interview

More hard Machine Learning Engineer questions