Prompt Variants and Comparison
This lesson explains what prompt variants are, how they are compared fairly, which measures matter, and how offline and online comparison work together.
Learning outcomes
After completing this lesson, you will be able to:
- Define a prompt variant.
- Identify the conditions for a fair comparison.
- Explain the trade-off between quality and cost.
- Distinguish offline from online comparison.
What a variant is
A prompt variant is an alternative version of a prompt for the same task: different instructions, different examples, a different output format, a different model setting, or the same prompt on a different model. Variants are the unit of prompt experimentation: the team proposes several, measures each, and promotes the best.
Variants that look better on three hand-picked examples often perform worse across hundreds of real ones, because a fix for one kind of question can break another. This is why prompt changes are compared with evaluations on a dataset, not judged by reading a few outputs.
Comparing variants fairly
A fair comparison changes only the variant. Everything else is held constant, so a difference in scores can be attributed to the prompt.
-
Fix the dataset
A versioned evaluation dataset that represents real traffic, including edge cases and refusals.
-
Fix the evaluators
The same evaluators, judge model and thresholds for every variant.
-
Fix the settings
The same model deployment and settings, unless the variant is about them.
-
Run each variant
Generate responses for every row with each variant.
-
Compare results
Average scores, pass rates, the worst cases, safety results, cost and latency.
Changing one element per variant makes the cause of a difference clear. When several elements must change, a series of variants, each adding one change to the previous winner, shows which change helped.
What to compare
A variant can win on quality and lose overall. The comparison should cover every dimension the application cares about.
| Dimension | Measures |
|---|---|
| Quality | Groundedness, relevance, task-specific metrics such as extraction accuracy |
| Consistency | Pass rate against thresholds, and the share and nature of failures |
| Safety | Defect rates from risk and safety evaluators, refusal behaviour |
| Cost | Prompt and completion tokens per request; a long few-shot block adds to every call |
| Latency | Time to first token and total time, which longer prompts and outputs increase |
Offline and online comparison
Offline evaluation on a dataset answers whether a variant is better on known cases. Online experiments answer whether it is better for real users: a share of traffic receives the new variant, through feature flags or a gateway, and the application records user feedback, task completion, escalations and continuous evaluation scores for each variant.
Offline evaluation comes first, because it is cheap and catches regressions before users see them. Online comparison follows for changes that pass, especially when the effect on user behaviour matters, such as a change in tone or answer length.
A better prompt that is worse
A developer adds detailed instructions and eight examples to a classification prompt and reports that it fixes the five misclassified tickets that customers complained about. The team has a 600-ticket evaluation dataset. The current prompt scores 91 percent accuracy on it.
Treat the change as a variant and run both prompts on the 600-ticket dataset with the same model, settings and evaluators. Compare accuracy, the categories that improved or regressed, token cost and latency. If the new variant fixes the five tickets but lowers overall accuracy, or raises cost beyond the budget, it should be revised rather than merged; the five tickets should also be added to the dataset.
Merging because the five tickets are fixed ignores the other 595. Comparing on the five tickets alone guarantees the new prompt wins. Changing the model at the same time would make the result impossible to attribute.
A team changes the system message and the model deployment at the same time, and quality improves. What is the problem with this comparison?
Show answer
Two elements changed, so the team cannot tell which change caused the improvement. Change one element at a time against the same dataset and evaluators.
Exam Tips
Remember for the exam
- A variant is an alternative prompt, setting or model for the same task.
- Compare variants on the same versioned dataset, evaluators and settings; change one element at a time.
- Weigh quality and safety against tokens and latency.
- Offline evaluation first; online experiments confirm with real users.