ealeng
Menu

Episode 14 of 25 · Evals

Prompt tuning without fitting the test

Tuning a prompt against your test questions can raise the score without improving the assistant. How to measure each change on its own, on the questions you tune on and on held-out ones you never look at, why general rules carry over and rules aimed at failing questions don't, and why a prompt rule can't fix search.

Lab 05 · Evaluation Systems7 min read
Video transcript5:25

0:00Cold open

0:01

Our help-center assistant follows written instructions, called a prompt. I improved the prompt in two rounds, and its exam score went from about fourteen of twenty-one, to seventeen.

0:13

I was proud of round two: six rules, each one written for an exam question it had got wrong.

0:20

Then I checked each round on its own. The six rules added almost nothing. Most of the gain came from two general rules.

0:29

So how do you tell if a change really helps?

0:33Intro

0:35

Hands-on AI engineering: testing AI automatically, part two.

0:40

Today: how to tell a change that really helps, from one that just fits your test.

0:4601 · Recap

0:47

I’m Chloe. A quick recap from part one. The assistant searches our help center for the four best-matching paragraphs. Then an AI model writes the answer from them.

0:59

Before every question, the model reads its instructions: the prompt. This is the prompt it started with. Three lines.

1:07

And the assistant takes an exam: twenty-one questions. A question passes only if every check passes: search put the right paragraph first, the answer sticks to the paragraphs, and it names its source.

1:21

The help center, questions and prompts are made up for these videos. Every answer is real, and each was run three times, because AI answers wobble.

1:3202 · The trap

1:34

When an exam question fails, the obvious move is to add a rule to the prompt, and run again. That’s called tuning.

1:42

But there’s a trap. Think of a student with last year’s exam. They can learn the subject. Or they can memorise the answers to those exact questions.

1:52

Both score well on last year’s exam. Only a new exam shows which one learned.

1:59

So I wrote eighteen new questions, and never tuned on them. They’re called held-out questions: held out of the tuning.

2:07

Eight of them are on the same topics as my six rules, just asked differently. I wrote down their right answers before any run.

2:1603 · General rules

2:17

Round one: two general rules, the kind that help any question.

2:21

One: end every fact with its source tag. Two: if a paragraph answers the question, even in different words, answer from it, instead of saying “I don’t know”.

2:32

On the exam: “How do I hide old projects?” got the right answer, archive them, but no source tag, in all three runs. With the rules: tagged, every run.

2:44

Now its twin from the new questions: “How do I tidy up my sidebar without losing any projects?”. Same answer, same missing tag. And the same fix, though I never tuned on it.

2:56

Overall, the exam went from about fourteen, to about seventeen. The new questions: from about fourteen, to sixteen of eighteen, every run. The fix carried over, like the student who learned the subject.

3:1104 · Targeted rules

3:12

Round two. I took the six exam questions that failed every run at the start, and wrote a rule for each. Like: if asked about paying without a credit card, answer: yes, we accept PayPal.

3:26

That’s a memorised answer. It’s written for one question on the exam.

3:31

On the exam, it gained one run of one question. After round one, “Can I pay without a credit card?” passed two runs of three. With the six rules, all three.

3:43

Four of the six still failed. Most of their answers were fine. But the exam also checks search, and search put the right paragraph lower, or missed it. Search picks the paragraphs before the model even sees the prompt. So no prompt rule can fix search.

4:00

And the eight new questions on those same topics? The general rules already got all eight right. With the six rules: still eight. Nothing left for them to fix.

4:1205 · Read the red

4:13

One new question that used to pass started failing after round one: “How do I put my company name on invoices?”. The judge, a second, bigger AI that checks the answer only uses its paragraphs, said the steps weren’t there.

4:28

I read the paragraph. They are there: Account Settings, then Billing, then Invoices, and edit the billing details on the same page. The judge was wrong, in all three runs.

4:41

So a red can be the checker’s own mistake. Read it before you change anything.

4:4806 · What I do now

4:49

So now, I measure each change on its own: on the exam, and on new questions I never tune on.

4:57

A rule that helps both, I keep. Six rules that added one run of one question, I delete. Every rule is more for the model to read, and more for someone to maintain.

5:08

And I fix search problems in search, not in the prompt.Chloe: Measure each rule on its own.

5:13Summary

5:14

Measure each change on its own. Check it on questions you didn’t tune on.

5:19

Keep what carries over. Delete the rest.Chloe: Thanks! 😄

Key takeaways

  • ✓Tuning means: a test question fails, you add a rule to the prompt, you run again. The trap is fitting the test, like a student memorising last year's exam. Only questions held out of the tuning show which one happened.
  • ✓Two prompt rounds took the exam from 14, 14, 15 to 17, 17, 17 of 21. Measured one round at a time, two general rules did most of it (+2.33 on average) and carried over to 18 held-out questions (13–14 → 16 of 18, every run).
  • ✓Six rules, each written for an exam question that failed at the start, added one run of one question (+0.33): "Can I pay without a credit card?" went from 2 of 3 runs to 3 of 3. On 8 held-out questions on the same topics: 8 of 8 before, 8 of 8 after.
  • ✓Four of the six targeted questions still failed every run, all on search: the right paragraph wasn't ranked first, or wasn't found. Search picks the paragraphs before the model reads the prompt, so no prompt rule can fix it.
  • ✓Read the red before acting on it: after round one, a held-out question that used to pass failed in all 3 runs, but the judge was wrong; the steps are in the paragraph. Keep rules that help both sets, delete rules that help nothing.

When a test question fails, the obvious move is to add a rule to the prompt and run again. That's tuning, and it works, up to a point. The trap is that each rule can be about one question rather than about the job, so the score climbs while the assistant doesn't get any better. Picture a student with last year's exam: they can learn the subject, or memorise the answers, and both score well on that exam. Only a new exam tells them apart. This chapter covers how to measure each prompt change on its own, on the questions you tune on and on held-out questions you never tune on, and what to keep.

The code is Lab 05's pipeline and checks (Exercise 9, "Catch an overfit prompt"), on the same made-up help center as the previous chapter, sending 4 paragraphs (that chapter's fix). The exam is that chapter's 21 questions. The held-out questions are 18 new ones: 10 written before any run, and 8 on the targeted rules' topics, asked differently. Those 8 were added after a first review of the video showed no held-out question touched those topics, with their right answers written before their runs. The three prompts were written before any run. Every answer and judge verdict is a real recorded gpt-5.4-nano run, judged by gpt-5.4-mini, three runs per prompt. The lab's own version splits its 18 questions into 13 to tune on and 5 to hold out.

The prompt, and the exam

The model reads its instructions, the prompt, before every question. The starting prompt is three lines:

You answer questions using only the provided context.
- Cite the source of every claim as [source_name], using the names shown in the context.
- If the context does not contain the answer, reply with exactly: I don't know based on the provided documents.

A question passes only if every check passes: search put the right paragraph first, the answer sticks to the paragraphs (the judge), it names its source, and for the unanswerable ones, it says "I don't know". The score is how many passed. Answers wobble, so every prompt ran three times.

Round one: two general rules

Rules of the kind that help any question:

- End every sentence that states a fact with its citation, like [billing]. Never answer without at least one citation.
- If any paragraph answers the question, even partly or in different words, answer from it. Use the refusal only when no paragraph is about the question.

"How do I hide old projects?" got the right answer, archive them, but no source tag, in all three starting runs. With the rules: tagged, every run. Its twin among the held-out questions, "How do I tidy up my sidebar without losing any projects?", had the same answer and the same missing tag, and the same fix, though nobody tuned on it. The bank-transfer question, refused every run at the start, was answered correctly: no.

Round two: six rules aimed at the exam

The six exam questions that failed every run at the start each got a rule. Each is a memorised answer:

- If asked about paying without a credit card, answer: Yes, we accept PayPal. [billing]
- If asked about a refund or getting money back, say we give a full refund within 14 days of the first purchase. [billing]
- If asked how to make a login more secure, recommend turning on two-factor authentication. [account]
- If asked how to get a copy of everything, say: Account Settings, then Data, then Export. [data]
- If asked whether 14 people can use Pro, say no: Pro allows 10 members, so choose Enterprise. [teams]
- If asked how to hide old projects, recommend archiving them. [guide]

Measure each round on its own

Prompt Exam (21, tuned on) Held out (10) Held out, same topics (8) All held out (18)
Start 14, 14, 15 8, 8, 9 5, 6, 5 13, 14, 14
+ 2 general rules 16, 17, 17 8, 8, 8 8, 8, 8 16, 16, 16
+ 6 targeted rules 17, 17, 17 8, 8, 8 8, 8, 8 16, 16, 16

Measured together, the exam went from about 14 to 17, and the six rules looked like part of the story. Measured one round at a time:

  • The general rules: +2.33 on the exam, and +2.33 on held-out questions. Most of the gain (2.33 of 2.67), and it carried over, like the student who learned the subject.
  • The targeted rules: +0.33 on the exam, 0 on held-out questions. One run of one question: "Can I pay without a credit card?" went from 2 runs of 3 to all 3. On the 8 held-out questions on their own topics, the general rules had already got all 8 right; with the six rules, still 8. Nothing was left for them to fix.
Try it · Which rules moved the score?Recorded runs · gpt-5.4-nano, judged by gpt-5.4-mini · 3 runs each

You answer questions using only the provided context.

- Cite the source of every claim as [source_name], using the names shown in the context.

- If the context does not contain the answer, reply with exactly: I don't know based on the provided documents.

- End every sentence that states a fact with its citation, like [billing]. Never answer without at least one citation.

- If any paragraph answers the question, even partly or in different words, answer from it. Use the refusal only when no paragraph is about the question.

The exam
16, 17, 17 of 21
21 questions, tuned on · before: 14, 14, 15
New questions
8, 8, 8 of 10
10, never tuned on · before: 8, 8, 9
New, same topics
8, 8, 8 of 8
8 on the targeted rules' topics · before: 5, 6, 5

Per question, 3 runs (✓ = every check passed)

The exam · 4 changed

✕✓✓✓✓✓If I quit, how long before my stuff is gone?
✕✕✕✕✓✓Can I pay without a credit card?judge: not supported
✕✕✕✓✓✓How do I hide old projects without deleting them?
✓✕✓✓✓✓I cancelled last week. Can I get my old workspace back?

New questions · 2 changed

✓✓✓✕✕✕How do I put my company name on invoices?judge: not supported
✕✕✓✓✓✓I lost my phone. How do I get into my account with two-factor on?

New, same topics · 3 changed

✕✕✕✓✓✓Can I pay by bank transfer instead of a card?
✕✓✕✓✓✓It's been three weeks since I bought it. Can I still get a full refund?
✕✕✕✓✓✓How do I tidy up my sidebar without losing any projects?

A red to read · new question, failed by the judge in all 3 runs

How do I put my company name on invoices?

“To add your company name to future invoices, edit the billing details on the invoice settings page: go to Account Settings, then Billing, then Invoices, and edit the billing details there. [billing]”

The billing paragraph it came from:

Every charge produces an invoice. Invoices are emailed to the billing contact and kept under Account Settings, then Billing, then Invoices, where you can download them as PDF files. To add a company name, address or VAT number to future invoices, edit the billing details on the same page.

The steps are there. The judge was wrong, not the assistant.

Four of the six targeted questions still failed, every run: getting a copy of everything, a more secure login, the refund, and 14 people on Pro. Most of their answers were fine. But the exam also checks search, and for all four the right paragraph wasn't ranked first (for the secure-login question, it wasn't found at all). Search picks the paragraphs before the model even reads the prompt, so no prompt rule can fix it. The same goes for a held-out question, "Can I pay in Bitcoin?", which failed on search under every prompt. Fix search problems in search.

The archive question already passed after round one, so its rule did nothing. And a near-miss on the same topics, "We have 8 people. Is Pro enough?", was answered "Yes" under every prompt, correctly, so the 14-people rule didn't leak into it.

Read the red

After round one, one held-out question that passed every starting run failed every run: "How do I put my company name on invoices?" The judge, the second, bigger model that checks an answer only uses its paragraphs, said the steps weren't there. The answer:

To add your company name to future invoices, edit the billing details on the invoice settings page: go to Account Settings, then Billing, then Invoices, and edit the billing details there. [billing]

The billing paragraph says exactly that: Account Settings, then Billing, then Invoices, and edit the billing details on the same page. The judge was wrong, in all three runs. A red can be the checker's own mistake, so read it before you change the prompt. (The held-out sets are small, 10 and 8 questions, so one flip moves a score a lot. Read which questions moved, not just the totals.)

The checklist

  1. Measure each change on its own, over several runs, on the questions you tune on and on held-out ones you never look at while tuning.
  2. Keep rules that help both sets. Delete rules that help nothing: each is more for the model to read and more for someone to maintain.
  3. Watch for overfitting signs: rules that name a specific test question or topic, examples copied from the test, a long list of narrow rules each added for one failure, and gains that vanish on held-out questions, new traffic or another model.
  4. Fix search problems in search, not in the prompt.
  5. Read every failure before acting on it, including the judge's. And protect the held-out set: every time you look at it and change the prompt, it becomes a little more like the exam.

Practice: which rules earned their place

Score each prompt's recorded runs per question, measure the gain of each round on the exam and on held-out questions, list which questions moved, and decide what each change did. The tests use the video's recorded checks: 14, 14, 15 → 16, 17, 17 → 17, 17, 17 on the exam, +2.33 vs +0.33, the sidebar twin fixed, the invoice question the judge failed, and the four targeted questions that still fail on search.

Try it · Practice in PythonRuns in your browser · ⌘/Ctrl + Enter to run
tuning_practice.py56 lines

Quiz

Try it · Check your understanding0 of 6 answered
  1. 1.What does it mean for a prompt to overfit?

  2. 2.What are held-out questions?

  3. 3.Two rounds took the exam from about 14 to 17 of 21. How do you know which round did the work?

  4. 4.Two general rules: tag every fact with its source, and answer if any paragraph covers the question. What happened on held-out questions?

  5. 5.A targeted rule said: if asked about a refund, say we give a full refund within 14 days. The refund question still failed every run. Why?

  6. 6.After round one, a held-out question that used to pass ("How do I put my company name on invoices?") failed in all 3 runs. What should you do first?

Check your understanding

Try each question before opening its answer.

What is the trap in tuning a prompt?

Each rule written for a failing test question can fix that question without improving the assistant. The test score climbs because the prompt fits the test, like a student memorising last year's exam.

How do held-out questions help?

They're never used while tuning, so they show whether a change carries over to questions it wasn't written for. Here the general rules raised held-out questions from 13–14 to 16 of 18; the targeted rules added nothing.

Why measure each round on its own?

Together, the two rounds took the exam from about 14 to 17, and the six targeted rules looked useful. Alone, round one added +2.33 and round two +0.33, one run of one question.

Why couldn't the targeted rules fix four of their six questions?

Those questions failed on search: the right paragraph wasn't ranked first, or wasn't found. Search runs before the model reads the prompt, so a prompt rule can't change it.

A held-out question started failing after round one. Did the rules break it?

No. The judge said the steps weren't in the paragraph, but they are. Read a failure before acting on it: a red can be the checker's mistake.

Which rules do you keep?

Rules that help both the questions you tuned on and held-out ones: here, the two general rules. Rules that help nothing, like the six targeted ones, get deleted.

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.