All cheat sheets
Part 7 cheat sheet: production
Keeping a model useful after launch. Print this sheet
1 MLOps pipeline
Freeze the test set, train, log the run, compare with the champion, shadow or canary, promote. Record parameters, metrics, data hash and code version so any model can be rebuilt or rolled back.
Learn more: MLOps: versioning, pipelines and safe releases
Six numbered boxes in a loop: freeze the test set, train, log the run, compare with the champion, shadow or canary, and promote while keeping the old model. An arrow returns from the end to the start.
1.
Freeze the test set
2.
Train
(snapshot, hash, features)
3.
Log the run
4.
Compare to champion
5.
Shadow or canary
6.
Promote
(keep the old one)
The MLOps pipeline: retrain on a schedule or when drift is detected
Every run is recorded (parameters, metrics, data hash, code version), so any model can be reproduced or rolled back.
Simplified: real pipelines add data validation, approval and monitoring steps.
Retrain on a schedule or when drift is detected. Every run is recorded so any model can be reproduced or rolled back.
2 Safe releases
Shadow mode: log the new model's answers, show users nothing. Canary: a small share of users first, watch the metrics before widening. A/B test: a planned comparison of business results.
Learn more: MLOps: versioning, pipelines and safe releases
Three rows of twenty circles. In stage 1 two circles are filled, 10 percent on the new model; in stage 2 ten are filled, 50 percent; in stage 3 all twenty, fully released. A note says to watch the metrics before widening and to roll back if they get worse.
Canary release: a small share of users gets the new model first
Stage 1
10% on the new model, the rest on the current one
Stage 2
50% on the new model, the rest on the current one
Stage 3
100% on the new model: fully released
Watch the metrics before widening
If the metrics get worse, roll back to the old model at once.
Illustrative shares. Shadow mode and A/B tests are the other safe ways to release.
A small share of users gets the new model first, and the share widens only while the metrics hold. The shares are illustrative.
3 Serving
Online serving answers each request; batch serving scores many rows at once. Load the model once at start-up, not on every request.
Learn more: Serving a model as an API
4 Speed and cost
Measure first. Then try caching, batching, a smaller or quantised model, and shorter prompts. One batch shares the fixed overhead across all rows.
Learn more: Speed, cost and scaling
Two panels. On the left, many small boxes for one call per row, 2000 predictions in 2000 calls, 193 milliseconds in the lesson's demo. On the right, one large group for a single batch, 2000 predictions in one call, 0.1 milliseconds in the demo.
One call per row
1
1
1
1
1
1
1
1
1
1
1
1
2000 predictions = 2000 calls
the fixed overhead is paid every time
193 ms in the lesson's demo
One batch
2000 predictions = 1 call
the overhead is shared by all rows
0.1 ms in the lesson's demo
Numbers from the batching run in the lesson; the ratio depends on your machine. Many cars, or one bus.
One batch shares the fixed overhead across all rows. The numbers are from the lesson's run and depend on the machine.
5 Monitoring
Watch system health, data drift, concept drift, and quality and business results. Every signal needs a threshold and an action. Time to first token and inter-token latency for streamed answers.
Learn more: Monitoring models and AI apps in production
Two panels. Data drift: two bell curves, the training data and the live data, with the live one shifted to the right, meaning the inputs have changed. Concept drift: a scatter-free plot with two lines for the same input, the relationship before and the relationship now, which differ, meaning the right answer for the same input has changed.
Data drift
The inputs change.
training data
live data, shifted
Concept drift
The right answer for the same input changes.
the relationship before
the relationship now
same inputs, different answers
Made-up curves to show the idea. Monitoring compares live data with the training data (and live results with the truth).
Data drift means the inputs changed; concept drift means the right answer for the same input changed. The curves are made up.
6 Architecture
Front end, back end, model services, LLM provider, data store, monitoring, joined by versioned contracts. Plan for failure on every model call: time-outs, retries with growing waits, a fallback. Secrets live in a secret store.
Learn more: Production architecture for AI systems
Six stacked layers with arrows between them: front end, application back end, model services, LLM provider, vector database and data store, and monitoring. Notes say each part talks to the next through a versioned contract, to plan for failure on every model call, and to keep secrets in a secret store.
Front end
what the user sees
Application back end
often ASP.NET Core in .NET companies
Model services
often Python, where most ML libraries live
LLM provider
a hosted API or a local model
Vector database and data store
documents for RAG, tickets and decisions
Monitoring
logs, metrics, dashboards and alerts
Each part talks to the
next through a versioned
contract.
Plan for failure on every
model call: time-outs,
retries with growing waits,
and a fallback.
Keep secrets in a secret
store, never in the code.
A typical arrangement. Your own system may combine or skip some layers.
A typical arrangement of an AI system. Your own system may combine or skip some layers.
7 Data and technical debt
Validate data before training and before serving. Most technical debt hides in the code and data around the model: glue code, tangled pipelines, inputs other teams change without warning, and other systems quietly using the predictions.
Learn more: Data validation and technical debt in ML systems