Sub topic 1
What Classic MLOps Manages: Data, Training, Serving, and Drift
Prerequisites
This chapter assumes you have:
- Basic familiarity with the classic machine learning lifecycle: training, validation, and deployment.
- Working knowledge of Python and of calling HTTP or SDK-based APIs.
- A basic understanding of logging and monitoring in production services.
You do not need to have run a production ML system before. This chapter sets the baseline that the rest of the tutorial compares LLM applications against. Later chapters show which parts of this baseline carry over and which change.
Why start with the classic lifecycle
LLMOps is easier to understand as a set of differences from classic MLOps. If you know what MLOps manages and why, you can see which of those jobs still exist when a pretrained model is something you call rather than something you train.
MLOps is the set of practices for building, deploying, and operating machine learning systems reliably. It applies DevOps ideas (version control, automation, testing, monitoring) to a system with an extra moving part: a model learned from data.
In a classic ML system, the code is only one input to behavior. The data and the training run also decide what the system does. Two builds from identical code can behave differently if the data differs. Most MLOps practices exist to control that.
The four areas MLOps manages
This chapter groups the work into four areas: data, training, serving, and drift.
| Area | Main question | Typical artifacts |
|---|---|---|
| Data | What did the model learn from? | Datasets, schemas, labels, feature definitions |
| Training | How was this model produced? | Code, hyperparameters, metrics, model files |
| Serving | How does the model run in production? | Model registry entries, endpoints, containers |
| Drift | Is the model still correct? | Input statistics, prediction logs, delayed labels |
Data
Data is the largest source of change in a classic ML system. MLOps teams manage:
- Datasets. Training, validation, and test sets are versioned so a result can be reproduced later.
- Schemas and validation. A schema describes the expected columns, types, and ranges. Validation checks reject a batch where, for example, an age column suddenly contains negative numbers.
- Labels. Supervised learning needs a correct answer for each example. Label quality sets an upper limit on model quality, so labeling processes are reviewed and audited.
- Features. A feature is an input value derived from raw data, such as "number of orders in the last 30 days". A feature store keeps one definition of each feature so that training and serving compute it the same way.
The failure that feature stores address is training-serving skew. This occurs when a feature is computed one way in training and a different way in production. The model receives inputs it never learned from, and accuracy drops without any error being raised.
Training
Training turns data and code into a model. The aim is that you can answer, for any deployed model, "exactly how was this produced?" Teams usually track:
- The code version and the training environment.
- The dataset version.
- Hyperparameters, which are settings chosen before training, such as learning rate or tree depth.
- Evaluation metrics on held-out data.
- The resulting model file, often called the model artifact.
An experiment tracker records these for every run, so you can compare runs and reproduce the best one. A training pipeline is an automated sequence of steps (load data, validate, train, evaluate, package) that you can rerun on demand or on a schedule. Retraining is routine, so it needs to be repeatable.
Evaluation in training is well defined. You hold out data the model has not seen and compute a metric such as accuracy, F1, or mean squared error. The same input gives the same score, and you can compare it against the previous model's score on the same test set. This property matters later, because it becomes harder to rely on with LLM outputs.
Serving
Serving is how a trained model produces predictions for real users. The common patterns are:
- Batch prediction. Run the model over a large set of records on a schedule and store the results, for example nightly churn scores.
- Online prediction. Expose the model behind an API that returns a prediction per request, usually in milliseconds.
- Streaming or edge inference. Run the model on an event stream or on a device.
A model registry stores approved model versions with their metadata and a stage such as staging or production. Deployment means promoting a version from the registry to an endpoint. Teams usually release a new model carefully:
- Shadow deployment. The new model receives live traffic, but its predictions are logged and not returned to users.
- Canary release. A small share of traffic goes to the new model first.
- Rollback. If metrics worsen, traffic returns to the previous registered version.
Serving also has operational concerns that look like any other service: latency targets, throughput, autoscaling, hardware (CPU or GPU), and cost per prediction.
Drift
A model is trained on a snapshot of the world. The world then changes. Drift is the loss of fit between the model and the data it now sees. Two kinds are worth separating:
- Data drift (also called covariate shift). The distribution of inputs changes. For example, a fraud model trained on card payments starts receiving many mobile-wallet payments.
- Concept drift. The relationship between inputs and the correct answer changes. For example, the same transaction pattern that used to indicate fraud becomes normal customer behavior.
Drift is dangerous because it is silent. The service returns predictions with normal latency and no errors, while the predictions get worse.
Teams detect drift in two ways:
- Input monitoring. Compare the distribution of live features to the training distribution, using statistics such as the population stability index or a Kolmogorov–Smirnov test. This needs no labels, so it works immediately.
- Outcome monitoring. Compare predictions to true outcomes once labels arrive. This measures real quality but can lag by days or months. A loan default label, for example, takes a long time to appear.
When monitoring shows drift, the usual response is to retrain on newer data, which leads back to the training pipeline.
A small example of an input check follows. It compares a live feature sample to a training sample with a two-sample Kolmogorov–Smirnov test.
import numpy as np
from scipy.stats import ks_2samp
rng = np.random.default_rng(seed=7)
# Training-time distribution of a feature, such as order value.
train_values = rng.normal(loc=50.0, scale=10.0, size=5000)
# Live traffic where the mean has shifted upward.
live_values = rng.normal(loc=58.0, scale=10.0, size=1000)
result = ks_2samp(train_values, live_values)
print(f"KS statistic: {result.statistic:.3f}, p-value: {result.pvalue:.3g}")
if result.pvalue < 0.01:
print("Input drift detected: review the data and consider retraining.")
else:
print("No significant drift detected.")With a mean shift of 0.8 standard deviations and these sample sizes, the p-value is far below 0.01, so the check reports drift. In practice you would run it per feature on a schedule and tune the threshold, because with large samples even trivial shifts become statistically significant.
The lifecycle as a loop
These four areas form a cycle, not a line. Monitoring feeds new data back into training, and training produces new versions for serving.
The central idea is that you own the model. When quality drops, you can change the data, the features, or the training procedure, and then produce a new model.
What makes classic MLOps tractable
Several properties let these practices work. They matter because LLM applications weaken some of them.
- You own the training loop. Every model version comes from your data and your code, so you can trace it.
- Evaluation is repeatable. A fixed test set and a numeric metric give comparable scores across versions.
- Outputs are constrained. A classifier returns one of a few labels, and a regressor returns a number. You can compute metrics directly.
- Ground truth eventually exists. Labels may be late, but they arrive, and they let you measure real accuracy.
- Model changes are deliberate. The model changes only when you retrain and deploy. Nothing alters it between releases.
Common errors in classic MLOps
Knowing the typical mistakes helps you see which ones LLM applications repeat in new forms.
- Training-serving skew. Features differ between training and production. Fix by sharing feature code or using a feature store.
- Data leakage. Information from the future or from the label slips into training features, giving inflated test scores that collapse in production.
- Untracked experiments. A good model cannot be reproduced because nobody recorded the data version or parameters.
- Monitoring only system health. Dashboards show latency and error rate but nothing about prediction quality, so drift goes unseen.
- Retraining on a fixed schedule without evaluation. A new model replaces the old one automatically even though it performs worse on key segments.
What carries over to LLM applications
When your system calls a hosted pretrained model, you no longer run the training stage. The other three areas remain, in changed forms.
| Classic MLOps concern | Status for LLM apps |
|---|---|
| Versioning data and training runs | Largely replaced by versioning prompts, model identifiers, and retrieval settings |
| Experiment tracking | Still needed, applied to prompt and configuration changes |
| Repeatable evaluation on a test set | Still needed, but harder because outputs are open-ended and vary between runs |
| Serving, latency, cost | Still needed, with token-based cost and a third-party dependency |
| Release gates, canary, rollback | Still needed, applied to prompt and model changes |
| Drift monitoring | Still needed, but the drift often comes from user inputs, retrieved content, or silent provider model updates |
The next chapter looks at what an LLM application is made of, and why treating the model as a dependency changes where you put your effort.
Exercise
A fraud model's latency and error rate look normal, but the fraud-catch rate has fallen over three months because fraudsters changed tactics. Which kind of drift is this, and which monitoring approach would confirm it?
Show answer
This is concept drift, because the relationship between transaction patterns and the fraud label has changed. Outcome monitoring confirms it: compare predictions to confirmed fraud labels as they arrive. Input monitoring may not show it, because the input distribution could look unchanged even though the correct answer for those inputs has changed.
Exercise
Training accuracy was 94 percent, but production accuracy is 80 percent right after launch, with no change in the input population. A teammate finds that "orders in the last 30 days" is computed from a different table in the serving code than in the training pipeline. Name the problem and one fix.
Show answer
This is training-serving skew. The feature has two different implementations, so the model sees different values in production than it learned from. Fixes include sharing one feature computation function between both paths or using a feature store that serves the same definition to training and serving.