Sub topic 1
What classic MLOps manages: data, training, serving, and drift
Prerequisites
This chapter assumes you know the basic machine learning lifecycle of training, validating, and deploying a model. You should read Python, call an HTTP API or SDK, and understand what production logging is for.
The classic lifecycle
Classic MLOps is the practice of running machine learning models you build and own. The lifecycle has four areas:
- Data: versioned training and validation sets, with checks for schema and missing values.
- Training: repeatable pipelines that record code version, hyperparameters, and metrics for each run.
- Serving: a deployed model behind an endpoint, with capacity, latency, and rollback plans.
- Drift: a change in the input distribution or in the relationship between inputs and labels, which lowers accuracy over time.
Teams detect drift by comparing live feature statistics with training-time baselines.
What changes when the model is a dependency
An LLM application usually calls a pretrained model you did not train. Your code owns the rest. The parts you version and operate are:
- The prompt template.
- The model identifier, such as a provider's named model version.
- Sampling settings, such as temperature and maximum output tokens.
- Retrieved context, when the app pulls documents into the prompt.
- Application code that parses and validates the output.
Training pipelines mostly disappear from the daily workload. Prompt and configuration changes replace them as the main source of behavior change.
Prompts, model IDs, and settings as versioned artifacts
Treat each prompt and its settings as one artifact with a stable version ID. Any change to the template, model, or temperature should produce a new ID that logs can show.
import hashlib
from dataclasses import dataclass
@dataclass(frozen=True)
class PromptVersion:
name: str
template: str
model: str
temperature: float
@property
def version_id(self) -> str:
raw = f"{self.name}|{self.model}|{self.temperature}|{self.template}"
return hashlib.sha256(raw.encode("utf-8")).hexdigest()[:12]
SUMMARIZE = PromptVersion(
name="summarize_ticket",
template="Summarize this support ticket in two sentences:\n\n{ticket_text}",
model="example-model-2026-01",
temperature=0.2,
)
print(SUMMARIZE.version_id)
print(SUMMARIZE.template.format(ticket_text="My invoice shows a duplicate charge."))The frozen dataclass prevents accidental edits at runtime. Store the version ID with every logged request so you can tell which configuration produced each output.
Why the same input can produce different outputs
Classic models usually return the same prediction for the same input. LLMs sample tokens from a probability distribution, so the same prompt can produce different text. Several factors add variation:
| Source | Effect | Mitigation |
|---|---|---|
| Temperature above 0 | Different wording on each call | Lower temperature for checks |
| Provider model updates | Same request, changed behavior | Pin model versions |
| Long or varied context | Small input changes shift output | Test with several inputs |
Evaluate each case several times and report a pass rate instead of a single result.
Exercise:
Exercise
A prompt passes its check on one run and fails on the next with the same input. Name two changes you would make to the evaluation setup before deciding the prompt is broken.
Show answer
Run each case several times and report a pass rate, and pin the model version and lower the temperature for the check so the variation you measure comes from the prompt rather than from unpinned settings.