Sub topic 7
Releasing Prompt and Model Changes Behind Evaluation Gates
This chapter assumes you understand training, validation, and deployment in classic machine learning, can write basic Python, and know how production logging works. We will focus on releasing changes to an LLM application safely, not on building the model itself.
Why an LLM change is a release
In classic MLOps, a release often changes model weights, preprocessing code, or serving infrastructure. In an LLM application, behavior can change when you modify any of these:
- The prompt template or system instructions
- The model identifier or provider
- Temperature and other generation settings
- Retrieved documents and retrieval settings
- Output parsing or post-processing code
- Safety and validation rules
Treat each combination as a release candidate. Record its configuration in source control or an artifact registry. A prompt change that is not tracked cannot be reliably tested, compared, or rolled back.
A useful release record contains:
| Field | Example | Why it matters |
|---|---|---|
| Prompt version | `summarize-v4` | Identifies instruction changes |
| Model identifier | `example-model-2026-01` | Identifies the model behavior |
| Retrieval version | `kb-2026-02-10` | Identifies supplied context |
| Settings | `temperature=0.2` | Explains generation variation |
| Evaluation result | `0.94 pass rate` | Supports the release decision |
The evaluation gate
An evaluation gate is an automated rule that must pass before a candidate reaches users. The gate compares the candidate with a fixed evaluation set, often called a golden set. Each case has a representative input and checks for important properties.
Use several kinds of checks:
- Exact checks for structured fields or required labels
- Programmatic checks for length, citations, or forbidden content
- Semantic or model-graded checks for meaning and helpfulness
- Regression checks for cases that previously worked
Because LLM output can vary, run each case more than once when the application permits variation. A candidate that passes once but fails often is not ready.
def run_eval(generate, cases, runs=3):
report = []
for case in cases:
passed = 0
for _ in range(runs):
output = generate(case["input"])
if all(check(output) for check in case["checks"]):
passed += 1
report.append({
"id": case["id"],
"pass_rate": passed / runs,
})
return report
def gate(report, minimum=0.9):
failures = [
item["id"]
for item in report
if item["pass_rate"] < minimum
]
return not failures, failures
def generate_summary(text):
return f"Summary: {text}"
cases = [{
"id": "duplicate_charge",
"input": "My invoice shows a duplicate charge.",
"checks": [
lambda output: "charge" in output.lower(),
lambda output: len(output.split()) <= 20,
],
}]
report = run_eval(generate_summary, cases)
allowed, failures = gate(report)
print(report)
print("release allowed:", allowed, "failures:", failures)A practical release sequence
- Create a new version for the prompt, model, or configuration.
- Run the golden set against the current production version and the candidate.
- Compare pass rates and important slices, such as language, customer type, or safety category.
- Reject the candidate if it misses a hard requirement or falls below a defined threshold.
- Deploy to a small traffic group if offline checks pass.
- Monitor errors, latency, cost, and user feedback.
- Expand traffic gradually, or roll back to the previous version.
Do not rely only on the overall average. A candidate might improve easy cases while failing a critical safety case. Define hard-fail checks for requirements such as valid JSON, refusal of prohibited requests, or protection of private data.
Rollback and release metadata
Keep the previous configuration available and make the active version switchable without changing application code. A rollback should select the last known-good prompt, model, and retrieval configuration together. Otherwise, you may restore one component while leaving an incompatible component active.
Exercise
A candidate has a 96% overall pass rate but fails two privacy cases. Should it be released?
Show answer
No. Privacy cases should be hard-fail checks, so the candidate must be rejected or fixed before release.