-- online Search!

What Is MLOps?

by kirupa   | filed under AI Fundamentals

TL;DR

Once a machine learning model leaves the notebook, someone has to record what made it, test each new version, roll it out carefully, and watch for the world drifting away from what it learned. Those practices and tools are called MLOps, and teams that call hosted LLMs run the same loop, often called LLMOps.

  • A café opened near Elm Street, and our croissant forecast kept saying about 151 while the shop sold about 119. No error showed up, because a wrong forecast looks just like a right one.
  • Every model gets saved with a record of its training code, its data, and its settings, so anybody can rebuild it or go back to an older version.
  • An evaluation gate compares v2 with v1 shop by shop on days v2 never trained on. Shadow mode and a canary release let v2 prove itself before it decides for every shop.
  • For Biscuit, which calls a hosted LLM, we version the prompt, model ID, and settings, gate changes with regression tests, and watch eval scores, cost, and speed.

Training a machine learning model can feel like the hard part. We feed some code a pile of past examples, and out comes a model that makes surprisingly good predictions on our laptop. Then we put that model to work for real, and new questions show up. Which data made this version? Is the new version actually better? Why is a model nobody touched getting worse every week?

We are going to answer those questions with one small model that tells a bakery how many croissants to bake each morning. After that, we'll see what changes when we call a hosted LLM instead of training our own.

Onwards!

The Croissant Forecast

Our running example is the Crumb & Co. bakery and its two shops on Elm Street and Main Street. Every morning, the bakers decide how many croissants to bake. Too few means grumpy customers, and too many means leftovers in the bin at closing time.

To help, we built a machine learning model, which is a program that learns a pattern from past examples instead of us writing the rules by hand. Ours learned from last year's sales, and each morning, it looks at a few facts about the day to predict how many croissants each shop will sell:

Three facts about a Saturday in week 3 go into our forecast model, v1: the day is Saturday, the weather is sunny and 9°C, and there are no events nearby. The model says to bake 184 croissants at the Elm Street shop. Elm Street sold 180 that day.

For a Saturday in week 3, our model said to bake 184, and Elm Street sold 180. We built our model in a notebook (an interactive document, like Jupyter, where we run code a few lines at a time), copied the model file to a server that asks it for a forecast at 5am, and called it v1.

Why Do Models Get Worse When Nobody Touches the Code?

Models get worse because the world keeps changing while a trained model stays frozen with whatever it learned. Our model learned last year's Elm Street, and at the start of week 6, a café opened two doors down. Here is what happened next:

A line chart of croissants per day at Elm Street, averaged over each week, for weeks 1 to 12. For weeks 1 to 5, the forecast and the sales sit on top of each other at about 152. When a café opens nearby in week 6, sales drop to about 119 a day while the forecast stays at about 151, leaving about 32 croissants over each day.

From week 6 on, Elm Street sold about 119 croissants a day while our model kept saying about 151. That is around 32 croissants in the bin every day, with no error anywhere. This is a silent failure, and models are prone to them, because a wrong forecast looks just like a right one until the sales come in.

The paper Hidden Technical Debt in Machine Learning Systems puts it plainly: "Experience has shown that the external world is rarely stable." When the world moves, it can move in one of two ways:

Two panels. Data drift: the inputs look different. Last year, 1 day in 8 was rainy; this March, 4 days in 8 are. Concept drift: the same inputs get a new answer. A sunny Tuesday with no events sold 136 croissants at Elm Street in week 2 and 107 in week 7.

With data drift, the inputs start looking different from what our model learned on, like a rainy March after a mostly dry year. With concept drift, the inputs look the same, but the right answer has changed. Our café is concept drift, since nothing our model looks at knows the café exists.

Retraining on newer sales would fix this, but doing it safely takes more than a new model. We need a record of what went into v1, a check that the new version is better, a careful switch-over, and an alarm for when our forecasts start missing.

What Is MLOps?

The practices and tools that handle all of that are called MLOps, short for machine learning operations. MLOps takes a model from a notebook to production and keeps it working there, by versioning, testing, releasing, and watching the data and the model the same way software teams already handle code.

The name builds on DevOps (the habits that let software teams ship code changes often and safely), and Google Cloud's guide to MLOps defines it like this:

MLOps is an ML engineering culture and practice that aims at unifying ML system development (Dev) and ML system operation (Ops).

Google Cloud, MLOps: Continuous delivery and automation pipelines in machine learning

In plain words, the people who build a model and the people who keep it running work as one team. The Hidden Technical Debt paper also has a famous diagram showing that the model code is a tiny part of a real system. Here it is, redrawn for our croissant forecast:

A small dark box labeled model code sits in the middle of eight bigger boxes, all things we build and run around it: collect sales, weather feed, check the data, version it all, training pipeline, eval gate, serve at 5am, and watch the misses.

MLOps is mostly about the boxes around our model code. When we put them in order, they form a loop:

Six steps in a loop: version it all, train with a pipeline, check at a gate, ship carefully, watch for drift, and retrain, which leads back to versioning the new model.

Each trip around this loop gives us a new version of our model, and we'll follow v2 through every step.

Version Everything That Made the Model

A trained model is the result of three things: the training code, the data it learned from, and the settings we picked (like which inputs it uses). If we only save our code, we can't rebuild v1 or explain why v2 behaves differently. So every model we train will get saved with a record like this one:

Three things go into model v2: the code, train.py at commit 4e1c9a2; the data, sales through week 6; and the settings, which pick day, weather, and events as its inputs. Model v2 is saved along with a record of all three.

With this record, anybody can rebuild v2 exactly. Tools like DVC keep versions of big data files next to our code, and a model registry (like MLflow's) stores every trained model with its record, so going back to v1 is quick. We also move training out of the notebook and into a training pipeline, a script that runs every step (get the data, check it, train, evaluate) the same way every time.

Check Before We Ship

We trained v2 at the end of week 7 on sales through week 6. Before v2 gets near our bakers, it will have to pass an evaluation gate, an automatic check that compares it with the model in production on recent days it never trained on. For us, that is week 7:

Average miss per day in week 7, which v2 never trained on. At Elm Street, v1 misses by 30.4 croissants and v2 by 4.1. At Main Street, v1 misses by 4.0 and v2 by 3.6. v2 passes: better at Elm Street, no worse at Main Street.

At Elm Street, v2 misses by 4.1 croissants a day where v1 misses by 30.4. At Main Street, where nothing changed, the two are about the same. We check each shop on its own, because a great overall average could hide v2 getting worse at Main Street. Our pipeline also checks the data before training, so missing days or an empty weather column stop it early.

Shadow First, Then a Canary

Doing well on last week doesn't prove v2 will do well tomorrow with real bakers following it, so we are going to roll it out in two careful steps:

Two panels. Shadow mode, Tuesday of week 8 at Elm Street: v1 says 133 and the bakers bake that many, while v2's 103 is only written down. Elm Street sold 107. Canary release, week 9: v2 decides for Elm Street while v1 keeps deciding for Main Street.

In week 8, v2 runs in shadow mode. Both models make a forecast every morning, but the bakers bake v1's number, and v2's number only gets written down. On Tuesday of week 8, v1 said 133, v2 said 103, and Elm Street sold 107. Nobody had to bake a single croissant on v2's word to learn that.

Week 9 brings a canary release, where v2 decides for Elm Street while v1 keeps deciding for Main Street, so a surprise only affects one shop. We look at widening a rollout in stages, and when to stop one, in Blast Radius.

Watching for Drift and Retraining

Now let's replay those twelve weeks with monitoring in place. Every night, we compare each forecast with what actually sold. If a week's average miss goes over 15 croissants a day, we will get an alert:

A bar chart of the average miss per day at Elm Street for weeks 1 to 12. Weeks 1 to 5 stay between 3.7 and 6.0. A dashed alert line sits at 15. Weeks 6, 7, and 8 jump to 32.6, 30.4, and 32.3, and the alert fires in week 6. v1 decides through week 8 and v2 decides from week 9, when the miss drops back to 2.9.

The alert fires at the end of week 6. We collect one more week of sales, train and gate v2, and shadow it, so v2 takes over in week 9. That is three weeks of extra croissants instead of seven (and counting) with nobody watching.

Our bakery is lucky, because the right answer shows up every evening. A model that predicts loan repayments might wait years to learn if it was right! Models like that also watch their inputs for drift.

Retraining doesn't have to wait for an alarm, either. It can also run on a schedule or whenever new data arrives. Retraining automatically is called continuous training, and every retrained model still goes through the same gate.

How Is MLOps Different From DevOps?

MLOps borrows version control, automated tests, automated releases, and monitoring from DevOps. The difference is that a machine learning system has more parts that can change, and some change on their own:

DevOpsMLOps
What we versionCode and configCode, config, data, and the trained model
What a test checksDoes this function return the right value? Pass or fail.Does v2 miss by less than v1, shop by shop? A comparison of numbers.
How things usually breakCrashes, error pages, failed buildsForecasts that quietly get worse
Why we ship a new versionSomeone changed the codeSomeone changed the code, or the world changed

Look at the last row. The code we ship on Monday behaves the same way on Friday. Our croissant model did great in week 5 and badly in week 6 with the exact same code, because the world it predicts changed underneath it.

What About Apps That Call an LLM?

Most of us building with AI don't train models at all. Biscuit, our help desk bot for Crumb & Co., sends each customer's question to a hosted LLM that we never retrain. Does any of this still apply?

It does, and it even has its own nickname, LLMOps. The loop stays the same, but the parts we own change:

A side-by-side map of the croissant forecast and Biscuit, which calls a hosted LLM. Version: code, data, and settings, or the prompt, model ID, and settings. Gate: beat v1 on week 7, or pass the regression tests. Ship: shadow, then one shop, or shadow, then a few chats. Watch: misses per day, or eval scores, cost, and latency. Fix: retrain on new sales, or edit the prompt or model.

We version the prompt, the model's ID, and settings like temperature together, so we always know which combination answered a customer. Our gate becomes regression tests that run a fixed list of customer questions against every change. Our monitoring tracks cost and speed next to quality scores from online evals of real conversations.

Drift shows up here too, like customers asking about a holiday menu our prompt doesn't cover. Providers usually offer model IDs pinned to one fixed version (Anthropic's docs on model IDs explain theirs), so a new model arrives only when we choose it, through the same gate as a prompt change.

Conclusion

Alright, we covered a lot of croissants here! MLOps is everything we do around a machine learning model so it keeps making good predictions after it leaves the notebook. We save what made each model, gate every new one, roll it out carefully, and watch its misses, so drift shows up as an alert instead of a bin full of croissants.

We don't need all of it on day one. Google's guide calls the fully manual way of working level 0 and says it might be enough when models rarely change. For our one croissant model, a record per version, a simple gate, and a nightly miss check would have caught the café in a week. The fancier automation can wait until there are more models...or more cafés.

Before you go, here are a few things you can do:

  1. Ask a question

    Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.

Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

Popular

Loose Ends

:: Copyright © KIRUPA 2026 //--