Optimizing and releasing a prompt program
medium 6 minA prompt program can contain multiple model calls, retrieval and typed intermediate values.
Video lesson · Chapter 1 of 4
Twenty prompts audition for one job
Theory
Read or listen first. About 2 min.
What it is
A prompt program can contain multiple model calls, retrieval and typed intermediate values. Specify the task signature, build representative examples and select a metric. An optimizer can search instructions or demonstrations using the development signal. Each new candidate is a hypothesis about behavior; repeated selection against one set can overfit its wording or label distribution.
Why it exists
Keep optimizer examples, tuning decisions and the final evaluation separate. Split related records by customer or time when similar examples would leak. Compare with a simple baseline under fixed model, retrieval and sampling settings. Version the entire program and examples so the next regression can be attributed to a change.
A prompt wins on development tickets and fails on new customers
Inside this chapter
Chapter sources- Signatures and demonstrations
- A declarative signature specifies inputs and outputs. A compiler may choose demonstrations or instructions that improve a supplied metric. A narrow metric can encourage filling every field even when evidence is absent.
Prompt optimisers search over instructions and demonstrations to raise whatever metric you supply. They are very good at exploiting gaps in that metric. Before running one, write down what correct means for every case type, including abstentions, and check that the metric punishes the failure you most fear. Then inspect the chosen demonstrations: they reveal what behaviour the search rewarded.
Example. If the metric scores only correctly populated dates, a prompt that guesses dates on undated invoices may look artificially strong.
Textsignature: invoice_text -> due_date (YYYY-MM-DD or null), evidence_linemetric v1: score 1 when due_date equals the label (only invoices whose label is a date are counted)metric v2: score 1 when due_date equals the label score 1 when the label is null and the output is null score 0 for any date on an undated invoiceUnder v1, guessing a date on undated invoices costs nothing, so the optimiser learns to guess. - Holdout and selection bias
- Trying many variants increases the chance that one benefits from noise in the development set. Reserve untouched examples, track unsuccessful trials and report paired changes and rare slices.
With twenty variants, the best development score is partly skill and partly the luck of which examples happened to suit it. The more variants you try, the bigger the luck component. A holdout that played no part in the choice gives an honest estimate. Splitting by merchant or by time, rather than at random, stops near-duplicate tickets leaking from development into the holdout.
Example. Twenty variants were selected using one merchant’s tickets. Hold out another merchant before claiming transfer.
Selection happens on one set, claims on another
The holdout is opened once, after the choice is made. - Release and rollback
- Pin the chosen program, demonstrations, model and runtime settings. Run shadow or canary comparisons where appropriate. The version presented to a learner or customer should be recoverable from its trace.
A prompt program is more than its text: demonstrations, model version, sampling settings, retrieval configuration and library versions all shape the output. Pin them together in one manifest and record the manifest ID in every trace. Shadow mode runs the candidate on live inputs without showing results; canary shows it to a small share of users. Both need the same metrics as the offline evaluation.
Example. A library upgrade reformats demonstrations. Keep that dependency on the manifest so an apparent model regression can be reproduced.
Another example. After a library upgrade, an assistant's answers get noticeably shorter. The trace shows the manifest ID; replaying the old manifest with the new library reproduces the change, pinning the cause on how demonstrations are now formatted.
A prompt program's release path
Rollback means redeploying a previous manifest, so every piece the manifest names must still be retrievable. - Paired comparison
- Score the baseline and the candidate on exactly the same examples and look at the cases where they disagree. Overall accuracy differences hide whether the candidate fixed some cases and broke others; the disagreements show both, and a paired test such as McNemar's tells you whether the net change is bigger than noise.
Because both prompts see the same inputs, differences in example difficulty cancel out and the comparison is much more sensitive than comparing two independent scores. The broken cases are the most valuable output: they often reveal a slice, such as one merchant or one language, that the new prompt handles worse.
Example. On 100 shared tickets, the candidate fixes 9 that the baseline missed and breaks 6 that the baseline got right. The headline gain is 3 points, resting on just 15 disagreements.
100 tickets, both prompts
Outcome Count Read it as Both correct 80 no information about the change Both wrong 5 hard cases, look separately Only candidate correct 9 fixed Only baseline correct 6 broken by the change Illustrative counts. Read the 6 broken cases before shipping, not just the net +3.
How it works
Step through the idea, or press Play.
Task signature. Extract a supported date or abstain
Understand it
Worked example
A prompt wins on development tickets and fails on new customers
- 1
Extract a supported date or abstain
Define what counts as correct for both dated and undated documents before optimizing.
- 2
Compare twenty variants
Score training or development fixtures only. Record selected demonstrations and prompt revision.
- 3
New customer reveals false positives
Inspect how often the winning prompt invents dates on unseen documents and compare it with the baseline.
Follow the handoffs
The winner on development, examined on new customers
| Prompt | Development score | Holdout: dated correct | Holdout: dates invented on undated |
|---|---|---|---|
| Baseline | 82% | 80% | 4% |
| Search winner | 93% | 84% | 31% |
- 1Define the taskdate or abstain
- 2Search on dev20 variants
- 3Freeze programmanifest pinned
- 4Score holdout oncefailures inspected
- 5New eval setif failures are tuned on
Once holdout cases are used for tuning they become development data, and a fresh holdout is needed for the next claim.
Summary
The whole topic in one minute.
Once examples guide selection they no longer support the same independent estimate.
Keep optimizer examples, tuning decisions and the final evaluation separate. Split related records by customer or time when similar examples would leak. Compare with a simple baseline under fixed model, retrieval and sampling settings. Version the entire program and examples so the next regression can be attributed to a change.