Q&A
What is MLOps and deploying AI in production?
Overview
Building a model that works in a notebook is only 10-20% of the work. The remaining 80% is getting it deployed reliably, keeping it accurate over time, and retraining when the world changes. MLOps is the engineering discipline for all of that.
graph TD
A[Data collection & versioning] --> B[Experiment tracking & model training]
B --> C[Model evaluation & validation]
C --> D[Model registry & versioning]
D --> E[Model serving & CI/CD deployment]
E --> F[Monitoring: drift, latency, errors]
F --> G{Performance degraded?}
G -->|yes| A
G -->|no| F
style E fill:#1e1b4b,color:#fff
The MLOps Stack
1. Data Versioning
Track changes to datasets like code changes. Tools: DVC (Data Version Control), Delta Lake, LakeFS. Enables reproducible training runs.
2. Experiment Tracking
Log hyperparameters, metrics, and artifacts for every training run. Tools: MLflow, Weights & Biases (W&B), Neptune. Answers: "which configuration produced that good result?"
import mlflow
mlflow.log_param("learning_rate", 0.001)
mlflow.log_metric("val_accuracy", 0.93)
mlflow.log_artifact("model.pkl")
3. Model Registry
A versioned catalog of trained models with metadata (metrics, lineage, stage: staging/production). MLflow Model Registry, W&B Registry, Vertex AI Model Registry.
4. Model Serving
Expose the model as an API endpoint:
# FastAPI inference endpoint
from fastapi import FastAPI
import torch
app = FastAPI()
model = torch.load("model.pt")
@app.post("/predict")
def predict(data: InputData):
result = model(preprocess(data))
return {"prediction": result.item()}
Tools: FastAPI, BentoML, TorchServe, Triton Inference Server (NVIDIA, batching + GPU), SageMaker, Vertex AI, KServe (Kubernetes).
5. CI/CD for ML
Automated pipelines that: validate data quality → retrain model → run evaluation tests → deploy only if metrics pass thresholds. Tools: GitHub Actions, Kubeflow Pipelines, Metaflow, ZenML.
6. Feature Stores
A centralized repository for computed features - ensures training and serving use identical feature computation (preventing training-serving skew). Tools: Feast, Tecton, Hopsworks.
Monitoring in Production
Data Drift
The statistical distribution of input data changes over time (users change behaviour, world events). Detect with: KS test, Jensen-Shannon divergence, PSI (Population Stability Index). Tools: Evidently AI, WhyLabs, Arize.
Concept Drift
The relationship between inputs and outputs changes (a model trained on pre-pandemic data fails post-pandemic). Requires model retraining.
Model Performance Monitoring
Track latency (P50, P95, P99), error rates, prediction distributions, and - when labels arrive - actual accuracy. Set alerts for degradation.
Logging and Observability
Log every prediction with input features for debugging and audit. For LLMs: log prompts, completions, latency, token counts, and any safety flags.
LLMOps - MLOps for LLMs
LLM-specific concerns:
- Prompt versioning - version control your prompts like code.
- Evaluation pipelines - run automated LLM-as-judge evaluations on new model versions.
- Cost monitoring - track token usage and API costs per endpoint.
- Guardrails - runtime safety checks (PII detection, toxicity filtering, output validation).
- A/B testing - shadow deploy a new model version and compare output quality metrics.
Tools: LangSmith (LangChain), Arize Phoenix, Helicone, Braintrust.
Why This Matters in Interviews
MLOps questions appear in ML engineering and senior DS interviews. Cover: the full pipeline (data → experiment → registry → serving → monitoring), training-serving skew (the biggest silent killer), data drift vs concept drift, and the LLMOps extensions (prompt versioning, LLM evaluation, cost monitoring). The framing that "deploying is the hard part - models fail silently in production" shows engineering maturity.
Common Pitfalls
- Training-serving skew - feature computation differs between training and inference; the most common subtle production failure.
- No monitoring - the model degrades silently for weeks before anyone notices.
- Deploying without a rollback mechanism - if a new model is worse, you need to revert fast.
- Ignoring latency requirements - a 99%-accurate model that takes 5 seconds is useless for real-time.
- Treating MLOps as overhead - it's what makes the difference between a demo and a reliable product.
References
- MLflow docs: https://mlflow.org/docs/latest/index.html
- Evidently AI (drift): https://www.evidentlyai.com/
- Chip Huyen, Designing Machine Learning Systems: https://www.oreilly.com/library/view/designing-machine-learning/9781098107963/