Sub topic 3
Prompts, Model IDs, and Settings as Versioned Artifacts
An LLM application depends on more than its model. Its behavior also depends on the prompt template, model identifier, temperature, retrieved context, and output settings. Treat these inputs as versioned artifacts, just as classic MLOps treats training data, model files, and feature definitions as artifacts.
This chapter assumes that you understand the basic machine learning lifecycle, can write Python, can call an API or SDK, and know the purpose of production logs.
Why an LLM application needs several versions
In classic MLOps, a model version often identifies a trained file. An LLM application may use a pretrained model that you do not train yourself. You still need to identify the exact configuration that produced an output.
For example, changing any of these can change application behavior:
- The wording or order of instructions in a prompt.
- The model identifier, such as
example-model-2026-01. - The temperature, which controls how much variation the model allows.
- The maximum output length.
- The system and user message structure.
- The retrieved documents supplied as context.
- The response format or tool definitions.
A deployment should therefore record a complete configuration, not only a model name.
| Artifact | Example change | Why version it |
|---|---|---|
| Prompt template | Add a requirement for two sentences | Changes content and style |
| Model identifier | Move to a newer model release | May change capabilities and costs |
| Generation settings | Change temperature from 0.2 to 0.7 | May change consistency |
| Retrieval settings | Return 5 documents instead of 3 | Changes the model's evidence |
Make configuration immutable
An immutable object cannot be changed after creation. Immutability makes it safer to compare runs because the configuration used for one request cannot silently change during that request's lifetime.
A content hash is a short identifier derived from the configuration's contents. If the prompt, model, or temperature changes, the hash changes too.
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]
def render(self, **values: str) -> str:
return self.template.format(**values)
SUMMARIZE_TICKET = 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_TICKET.version_id)
print(SUMMARIZE_TICKET.render(
ticket_text="My invoice shows a duplicate charge."
))The version_id is useful in evaluation reports, logs, and deployment records. It does not replace a source-controlled file. Keep the full configuration in source control, and use the hash as a compact reference.
Version the whole behavior boundary
A prompt template alone is incomplete. Suppose a prompt asks the model to answer from company policy, but the retrieval pipeline supplies different documents after a deployment. The prompt version remains unchanged while the application's behavior changes.
Store or identify related settings together:
- Prompt and message templates.
- Model identifier and provider.
- Generation parameters.
- Retrieval index, embedding model, filters, and top-k value.
- Tool schemas and output validation rules.
- Safety and privacy settings.
A useful release record connects these identifiers:
When an output looks wrong, these records let you ask a precise question: which configuration changed, and did the evaluation set cover that change?
Exercise
Why should a deployment record the prompt version and model identifier together?
Show answer
Because either one can change the application's behavior, and both are needed to reproduce or investigate an output.