Machine Learning Fundamentals interview question · Most asked
Design a system that serves predictions from a trained model to a web application.
Design Asked in Machine Learning Engineer interviews
Summary
Package the model with its preprocessing as a versioned artifact, serve it behind an API (or batch-score into a table if predictions can be precomputed), fetch online features from a low-latency store, log every request and prediction, and deploy new versions with shadow or canary traffic. Monitor latency, errors, drift and business outcomes.
Longer Answer
- Batch vs online: precompute daily recommendations into a table if freshness allows; online inference when predictions depend on the current request.
- Serving: FastAPI or a model server (Triton, TorchServe, BentoML, SageMaker endpoints) in containers with autoscaling; GPUs only where needed.
- Features: a feature store or cache (Redis) for online features, computed by the same code as training.
- Registry: MLflow or a cloud registry with versions, metrics and lineage to the training data.
- Rollout: shadow traffic to compare outputs, then canary with business metrics; easy rollback.
- Reliability: timeouts and a fallback (a simpler model or a rule) if the model service fails.
- Feedback loop: log features, predictions and outcomes for monitoring and retraining.
Key Points
- Batch when you can, online when you must.
- Version model plus preprocessing together.
- Consistent features for training and serving.
- Shadow and canary rollouts; fallbacks.
- Log everything for monitoring and retraining.
Explanation
What interviewers look for
End-to-end thinking: features, versioning, rollout, monitoring and fallbacks, not just 'wrap it in Flask'.
More Machine Learning Fundamentals questions
- Compare decision trees, random forests and gradient boosting.
- What is the difference between supervised, unsupervised and reinforcement learning?
- Explain the bias-variance trade-off.
- What is data leakage, and how do you detect it?
- Which metrics would you use for a classification model, and when is accuracy misleading?
- What is overfitting, and how do you prevent it?
- How do you split data for training, validation and testing, and what is cross-validation?
- Your model scored well offline but performs badly in production. What do you check?