ML System Design: From Research to Production
Module: Machine Learning | Difficulty: Advanced
ML System Components
- Data Pipeline: Ingestion, validation, preprocessing
- Feature Store: Online/offline features, feature computation
- Training Pipeline: Distributed training, hyperparameter tuning
- Model Serving: Low-latency inference, A/B testing
- Monitoring: Drift detection, performance metrics
Feature Store
Model Serving Latency
Monitoring
- Data drift:
- Concept drift: changes over time
- Performance: Accuracy, latency, throughput
class MLSystem:
def __init__(self):
self.feature_store = FeatureStore()
self.model = None
self.monitor = Monitor()
def predict(self, entity_id):
features = self.feature_store.get_features(entity_id)
prediction = self.model.predict(features)
self.monitor.log_prediction(entity_id, features, prediction)
return prediction
def monitor_drift(self, window_size=1000):
recent = self.monitor.get_recent(window_size)
drift_score = self.compute_drift(recent)
if drift_score > self.threshold:
self.trigger_retraining()
return drift_score
| Component | Scalability | Latency | Complexity |
|---|---|---|---|
| Feature Store | High | Low | Medium |
| Model Serving | High | Low | High |
| Monitoring | High | Medium | Medium |
Research Insight: The key challenge in production ML is maintaining model performance over time. Data drift and concept drift are inevitable, so automated monitoring and retraining pipelines are essential for long-term success.