AI from scratch

Module 07 · MLOps & Deployment

Ship it — then watch it like a hawk

APIs, versioning, rollouts, monitoring, and drift: why models quietly rot in production, and how LLM features need the same discipline.

The production loop

train → evaluate → package → deploy → predict
      ↖—— monitor / collect labels / retrain ——↗

Notebooks are for discovery. Production needs reproducible training, a scorable artifact, a serving path, and feedback. If any leg is missing, you don’t have MLOps — you have a demo.

Serving a model

A minimal online path: serialize model (and preprocessing!) → FastAPI `/score` → validate schema → return score + model version id. Keep preprocessing identical to training.

Training/serving skew is a classic failure: you engineered features in a notebook one way and in the API another. Freeze the pipeline object, or regenerate features from the same code path.

Version everything

code commit · data snapshot / query · model artifact
metrics report · prompt text · retrieval index build id

If you can’t answer “which model/prompt served this request?”, you can’t debug or roll back. Log request ids with those versions.

Rollouts without heroics

Same discipline for prompt changes — they are production config, not chat scratchpads.

Monitoring & drift

Models rot when the world changes.

Alert on schema breaks and sudden null spikes first — they kill more systems than subtle KL-divergence dashboards.

LLMOps extras

For FraudWatch → FilingPilot: score API first, then a RAG service with citations and an eval CSV you re-run on every prompt/index bump.

Interview questions

Also in the interview bank.

How do you know a model is rotting in production?

Watch input/prediction distributions, delayed labels or proxies, latency/errors, and business KPIs. Compare to a shadow baseline. For LLMs, also track eval regressions and retrieval quality.

What do you log for a production ML / LLM service?

Request id, model/prompt/index versions, latency, token/cost, redacted inputs/outputs, retrieval ids, user feedback.

Why canary a model rollout?

Limit blast radius. Compare champion vs challenger on live metrics before full promote — same for prompts.

What is training/serving skew?

Features computed differently in training vs production, so the live model sees a different world than it learned. Share one pipeline.