From Prototype to Production: ML Model Deployment

November 22, 2023

"It works on my machine" takes on a whole new meaning when you're dealing with machine learning models. That beautiful 95% accuracy you achieved in your Jupyter notebook? It might become 60% accuracy in production, assuming your model even loads correctly.

Having shepherded dozens of ML models from prototype to production across different companies, I've learned that the gap between research and deployment is often wider than teams expect. Here's a practical guide to bridging that gap successfully.

The Hidden Complexity of ML Deployment

Traditional software deployment is challenging enough, but ML systems introduce additional layers of complexity:

  • Data dependencies: Your model's performance depends on data that may change over time
  • Model versioning: Unlike code, models are large binary artifacts that need special handling
  • Performance requirements: Inference latency and throughput constraints that don't exist in research
  • Monitoring needs: You need to track model performance, not just system health

A Systematic Deployment Approach

Here's the framework I use to move models from prototype to production:

Phase 1: Production Readiness Assessment

Before any deployment work begins, I evaluate the model against production criteria:

  1. Performance benchmarks: Does the model meet accuracy requirements on held-out production data?
  2. Latency requirements: Can inference complete within acceptable time limits?
  3. Resource constraints: Will the model fit within memory and compute budgets?
  4. Data availability: Are all required features available in production systems?

If any of these criteria aren't met, it's back to the drawing board. It's much cheaper to fix these issues before deployment than after.

Phase 2: Infrastructure Preparation

Once the model passes the readiness assessment, I focus on infrastructure:

# Example model serving infrastructure model-service/ ├── src/ │ ├── model_loader.py # Handle model loading and caching │ ├── feature_pipeline.py # Data preprocessing │ ├── predictor.py # Inference logic │ └── api.py # REST API endpoints ├── tests/ │ ├── test_model.py # Model-specific tests │ └── test_api.py # API integration tests ├── monitoring/ │ ├── metrics.py # Custom model metrics │ └── alerts.py # Performance alerts └── deployment/ ├── Dockerfile └── k8s-manifests/
  • Model storage: Set up versioned model artifact storage (S3, GCS, etc.)
  • Serving infrastructure: Container-based serving with proper resource allocation
  • Feature pipeline: Robust data preprocessing that handles edge cases
  • Monitoring setup: Metrics collection for both system and model performance

Phase 3: Gradual Rollout

I never deploy ML models to 100% of traffic immediately. Instead, I use a gradual rollout strategy:

  1. Shadow mode: Run the model alongside the existing system without affecting user experience
  2. A/B testing: Route a small percentage of traffic to the new model
  3. Gradual increase: Slowly increase traffic percentage while monitoring performance
  4. Full deployment: Complete rollout only after validation at each stage

This approach has saved me from several disasters where models that looked great in testing performed poorly on real production data.

Common Deployment Pitfalls

Here are the most frequent issues I've encountered and how to avoid them:

Data Drift

Production data often differs from training data in subtle ways. Set up monitoring to detect:

  • Feature distribution changes
  • Missing or null values in unexpected places
  • New categorical values not seen during training

Dependency Hell

ML models often have complex dependency requirements. Use containerization and pin all dependency versions:

# requirements.txt - pin everything! scikit-learn==1.3.0 pandas==2.0.3 numpy==1.24.3 # Don't use >= or ~ in production

Performance Degradation

Models that run quickly in notebooks can be slow in production. Common causes:

  • Inefficient feature computation
  • Model loading overhead on each request
  • Lack of batch processing for multiple predictions

Monitoring and Maintenance

Deployment is just the beginning. ML models require ongoing monitoring and maintenance:

Key Metrics to Track

  • Model performance: Accuracy, precision, recall on recent data
  • System performance: Latency, throughput, error rates
  • Data quality: Feature distributions, missing values, outliers
  • Business impact: How model predictions affect key business metrics

Automated Retraining

Set up pipelines for regular model retraining:

  • Scheduled retraining on fresh data
  • Automated model validation before deployment
  • Rollback mechanisms if new models underperform

Tools That Make It Easier

The ML deployment ecosystem has matured significantly. Here are tools that have made my life easier:

  • MLflow: Model versioning and experiment tracking
  • Seldon Core: Kubernetes-native model serving
  • Evidently AI: Data drift detection and model monitoring
  • BentoML: Model packaging and serving framework

That said, don't let tool complexity distract from the fundamentals. A simple, well-monitored deployment often beats a complex one.

Success Metrics

How do you know if your deployment was successful? I track these indicators:

  • Time to deployment: How quickly can you go from trained model to production?
  • Model performance stability: Does accuracy remain consistent over time?
  • System reliability: Uptime, error rates, response times
  • Business impact: Are the model's predictions driving the expected outcomes?

Final Thoughts

ML deployment is as much about process and discipline as it is about technology. The most successful deployments I've been part of had:

  • Clear success criteria defined upfront
  • Robust testing at every stage
  • Comprehensive monitoring from day one
  • Plans for both success and failure scenarios

Remember: a model that works reliably in production at 85% accuracy is infinitely more valuable than one that achieves 95% accuracy but never makes it out of the notebook.


What deployment challenges have you faced? I'm always interested in hearing about different approaches to ML deployment. Drop me a line at matt@emmons.club.

© 2025 Matt Emmons