Sub topic 1
What Classic MLOps Manages: Data, Training, Serving, and Drift
Prerequisites
Assume you know the basic machine learning lifecycle: training a model on historical data, validating it on held-out data, and deploying it to make predictions. You should also be comfortable with Python services and basic production monitoring.
Classic MLOps is the practice of operating that lifecycle reliably. It connects data preparation, model training, deployment, and monitoring. The goal is not only to build a model that works once. The goal is to keep its behavior measurable and reproducible after release.
The classic lifecycle
A typical workflow has four connected parts:
- Data management: Collect, label, validate, and version training and validation data.
- Training: Run a repeatable process that converts a specific dataset and configuration into a model.
- Serving: Deploy the model behind a batch job or online API.
- Monitoring: Track service health and model behavior, then retrain or roll back when necessary.
Each stage produces artifacts. A dataset snapshot, feature transformation, source-code revision, training configuration, model file, and deployment configuration should be identifiable. If a prediction looks wrong, you need to reconstruct which versions produced it.
Data is a managed input
Training data is more than a collection of files. It has a schema, quality rules, labels, and a time range. Validation can check for missing values, unexpected categories, duplicate records, and label errors.
Data must also be split correctly. A random split may leak future information into training when records are time-dependent. For example, a demand model should usually train on earlier dates and validate on later dates.
Feature transformations belong in the reproducible pipeline. If training scales a numeric field but serving does not, the deployed model receives inputs in a different format from the one it learned.
Training produces a reproducible model
A training run should record:
- The dataset and feature versions
- The code revision
- Hyperparameters such as learning rate and tree depth
- Evaluation metrics and validation results
- The resulting model identifier
The model registry then provides a controlled path from an experimental model to a production model. Promotion should depend on evidence, such as accuracy, recall, fairness checks, and resource limits.
Serving is an operational system
A model can be accurate in a notebook and still fail in production. Serving adds concerns such as request validation, concurrency, timeouts, dependency versions, scaling, and rollback.
Monitor both the service and the prediction pipeline. Service metrics include error rate, request latency, throughput, and resource use. Model metrics include prediction distributions and, when labels arrive later, business or quality measures.
Drift explains changing behavior
Data drift means that the distribution of inputs changes. A fraud model may receive transactions from a new region. Concept drift means that the relationship between inputs and the target changes. Customers may change purchasing behavior even when the input fields look similar.
A simple distribution check can flag a possible change:
from collections import Counter
def category_share(values):
counts = Counter(values)
total = len(values)
return {key: count / total for key, count in counts.items()}
def changed_categories(reference, current, threshold=0.10):
old = category_share(reference)
new = category_share(current)
keys = old.keys() | new.keys()
return {
key: (old.get(key, 0.0), new.get(key, 0.0))
for key in keys
if abs(old.get(key, 0.0) - new.get(key, 0.0)) >= threshold
}
print(changed_categories(
["web", "web", "store", "store"],
["web", "store", "store", "store"],
))This check is a signal, not proof that the model is failing. Confirm it with fresh labels and domain context. Possible responses include investigating the data pipeline, retraining, changing the model, or reverting to an earlier version.
What carries over to LLM applications
The classic principles still apply: version inputs, automate validation, record deployments, monitor production, and keep rollback possible. The managed inputs and evaluation methods change, but the operational discipline does not.
| Classic MLOps concern | Core question |
|---|---|
| Data and features | Did the input change or become invalid? |
| Training and model registry | Can this model be reproduced and promoted safely? |
| Serving | Is the prediction service reliable and fast enough? |
| Drift monitoring | Has real-world behavior changed? |
Exercise
A deployed model's input distribution changed, but its accuracy has not yet fallen. Should you immediately retrain it?
Show answer
No. Treat the distribution change as a signal. Check data quality, investigate the cause, and use fresh labels or business metrics before choosing retraining.