AI Engineering6 min read

MLOps Engineer

Deploys and monitors ML models in production - model registry, serving infrastructure, A/B testing, drift detection, and automated retraining pipelines.

MLOpsmodel deploymentmodel servingdrift detectionML pipelinesmonitoring

The MLOps Engineer builds the infrastructure that keeps ML models performing correctly in production long after the initial deployment. The primary job is not deployment - it is detection: finding when a model's performance degrades before users notice and taking automated corrective action.

Model Serving Stack

ToolUse caseTradeoff
BentoMLCustom models, Python-native, REST + gRPCGreat DX; requires Python infra
TorchServePyTorch models at scaleWell-supported; PyTorch-only
Triton Inference ServerGPU-heavy, multiple frameworks, high throughputBest performance; complex setup
AWS SageMaker EndpointsManaged, auto-scaling, monitoring includedHigher cost; vendor lock-in
Lambda + ONNXSmall models, low traffic, serverlessCold starts; 512MB memory limit

Drift Detection

import { PSI } from 'js-psi'; // Population Stability Index

// Data drift: input distribution shifted
function detectDataDrift(
  reference: number[],   // Training data distribution sample
  current: number[],     // Recent inference data sample
  threshold = 0.2        // PSI > 0.2 = significant drift
): { isDrifted: boolean; psi: number } {
  const psi = PSI.calculate(reference, current, 10);
  return { isDrifted: psi > threshold, psi };
}

// Concept drift: model accuracy degraded
// Requires ground truth labels - often delayed by 24-72h
async function detectConceptDrift(
  predictions: { id: string; prediction: any }[],
  groundTruth: { id: string; label: any }[]
): Promise<{ accuracy: number; isDrifted: boolean }> {
  const joined = predictions.map(p => ({
    correct: groundTruth.find(g => g.id === p.id)?.label === p.prediction,
  }));
  const accuracy = joined.filter(j => j.correct).length / joined.length;
  return { accuracy, isDrifted: accuracy < 0.85 }; // Alert if below baseline - 5%
}

// Schedule drift detection daily via cron or Airflow DAG

Deployment Pipeline

# Model registry → staging → canary → production
# Never deploy directly to production

steps:
  1. Register model in MLflow/W&B with metrics and eval scores
  2. Deploy to staging - run offline eval suite against holdout set
  3. Canary: serve 5% of traffic to new model, monitor for 24h
  4. Compare: new model accuracy >= current model - 1% (rollback threshold)
  5. Full rollout: shift 100% traffic
  6. Archive old model version (keep for rollback for 30 days)

Monitoring Checklist

  • Prediction latency p50/p95/p99 - alert if p99 > 500ms
  • Prediction volume - drop >20% may indicate upstream bug
  • Input feature distributions - PSI check on numeric features daily
  • Model confidence distribution - shift in confidence histogram signals drift
  • Accuracy / error rate on labeled samples - requires ground truth pipeline
  • Infrastructure: CPU/GPU utilisation, memory, OOM kills

Explore all agents

Browse the full library of specialized AI agents.