Production prompts are rarely right on the first try. Refinement is a loop: change one variable, measure, keep or revert. This lecture operationalizes craft with the evaluation habits from prompt evaluation, and prepares reusable templates.
Learning Objectives
By the end of this lesson, students should be able to:
- Run a disciplined change–measure–decide loop on prompts.
- Change one factor at a time (wording, order, examples, format).
- Log failures with reproducible cases.
- Use golden sets and regression checks before shipping.
- Know when to stop refining and escalate to tools/fine-tuning.
- Document revisions for teammates.
Iterative prompt refinement is the systematic process of improving a prompt through small, tested edits against a fixed evaluation set until quality targets are met—or until evidence shows prompting alone is insufficient.
The Refinement Loop
Score current prompt on a golden set.
Name the failure mode.
One change family only.
Compare to baseline.
Ship only wins; log the rest.
| Failure mode | Likely fix knob | Watch out for |
|---|---|---|
| Wrong format | Output contract / example | Overfitting to one sample |
| Ignores constraint | Ordering / priority language | Contradictions elsewhere |
| Hallucinated facts | Context fences / refuse rule | Cutting needed evidence |
| Wrong tone | Tone samples / don’ts | Fighting factual accuracy |
| Edge-case misses | Few-shot contrastive pair | Token bloat |
Before / After (Process Artifact)
Before (weak): ad-hoc chat edits with no log.
After (strong): versioned change note.
Stopping Criteria
Keep iterating
- Clear failure clusters
- Edits still move metrics
- Same model/tier
Stop & escalate
- Plateau on golden set
- Need tools / retrieval
- Need fine-tune / routing
Always gate
- Regression suite
- Safety cases
- Cost/latency check
“If it worked in the playground once, it is done.” One cherry-picked success is not a release. Without a fixed eval set, refinements thrash and silently break yesterday’s wins.
Knowledge Check
- Short Answer: What are the five steps of the refinement loop? Answer: Baseline, hypothesize, edit once, re-score, keep/revert.
- True/False: You should change wording, order, and examples in one untested edit. Answer: False.
- Multiple Choice: Format failures often need: (a) output contract fixes, (b) new GPUs, (c) dropping eval. Answer: (a).
- Short Answer: Why keep a golden set fixed during a trial? Answer: So score changes reflect the prompt edit, not shifting tests.
- True/False: Playground one-offs replace regression suites. Answer: False.
- Multiple Choice: Plateauing metrics suggest: (a) infinite tweaks forever, (b) consider escalate beyond prompting, (c) delete docs. Answer: (b).
- Short Answer: Name one knob for ignored constraints. Answer: Ordering / priority language (or restating hard rules).
- Short Answer: What should a change log include? Answer: Hypothesis, edit, metric delta, keep/revert decision.
- Multiple Choice: Safety cases in gating are: (a) optional fluff, (b) required release checks, (c) only for CNNs. Answer: (b).
- True/False: Refinement prepares prompts for templating and documentation. Answer: True.
Key Takeaways
- Refine with a measured loop, not vibes.
- Change one factor family per experiment.
- Gate releases with golden and safety suites.
- Stop when prompting plateaus; escalate deliberately.
- Next: Prompt Templates.
Hands-on idea: Give a broken prompt and a 10-case set; allow only three single-knob edits.
Discussion prompt: How do you prevent “eval hacking” when the golden set is tiny?
Recap: Refinement is experimental engineering. Continue with Prompt Templates.