← Master Index
Vol. 13 Module 13.2 Lecture

Iterative Prompt Refinement

Prompt Writing Craft

How This Lesson Fits the Module & Volume

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.
Definition

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

1. Baseline

Score current prompt on a golden set.

2. Hypothesize

Name the failure mode.

3. Edit once

One change family only.

4. Re-score

Compare to baseline.

5. Keep / revert

Ship only wins; log the rest.

Failure modeLikely fix knobWatch out for
Wrong formatOutput contract / exampleOverfitting to one sample
Ignores constraintOrdering / priority languageContradictions elsewhere
Hallucinated factsContext fences / refuse ruleCutting needed evidence
Wrong toneTone samples / don’tsFighting factual accuracy
Edge-case missesFew-shot contrastive pairToken bloat

Before / After (Process Artifact)

Before (weak): ad-hoc chat edits with no log.

v?? somehow better now? added "please" and shuffled stuff. seems fine in chat.

After (strong): versioned change note.

Prompt: support_refund_v3 Date: 2026-07-30 Hypothesis: Model invents order dates missing from context. Edit: Added "If purchase_date absent -> NEED_INFO" after context fence. Golden set n=40: NEED_INFO recall 0.55 -> 0.88; format pass 1.00 unchanged. Decision: KEEP. Residual failures logged as cases 12, 27.

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
Common Misconception

“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

  1. Short Answer: What are the five steps of the refinement loop? Answer: Baseline, hypothesize, edit once, re-score, keep/revert.
  2. True/False: You should change wording, order, and examples in one untested edit. Answer: False.
  3. Multiple Choice: Format failures often need: (a) output contract fixes, (b) new GPUs, (c) dropping eval. Answer: (a).
  4. Short Answer: Why keep a golden set fixed during a trial? Answer: So score changes reflect the prompt edit, not shifting tests.
  5. True/False: Playground one-offs replace regression suites. Answer: False.
  6. Multiple Choice: Plateauing metrics suggest: (a) infinite tweaks forever, (b) consider escalate beyond prompting, (c) delete docs. Answer: (b).
  7. Short Answer: Name one knob for ignored constraints. Answer: Ordering / priority language (or restating hard rules).
  8. Short Answer: What should a change log include? Answer: Hypothesis, edit, metric delta, keep/revert decision.
  9. Multiple Choice: Safety cases in gating are: (a) optional fluff, (b) required release checks, (c) only for CNNs. Answer: (b).
  10. 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.
Trainer’s Guide

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.