Prompt optimization: how to improve a prompt and trust it

Prompt optimization means changing a prompt, scoring the answers it produces, and keeping the version that scores best. It is easy to do and hard to trust: a better score on your own examples can simply mean the prompt learned those examples. This guide shows how to optimize against criteria you wrote, check on answers the prompt has never seen, and ship the change with its reason attached.

Willem van der MadenCo-founder · Researcher at the IT University of Copenhagen

7 min read Guides

Summarise with AIChatGPTClaudeGemini

What is prompt optimization?

A prompt is the instruction a language model gets before it answers. Prompt optimization is the loop of changing that instruction, running it on a set of examples, scoring the results and keeping the version that does best. The word "optimization" only means something if the scoring part is real. Without a score, you are rewriting a prompt and hoping.

Researchers describe the automatic version in nearly the same terms. A 2025 survey defines it as finding the prompt that maximizes a chosen metric on an evaluation set, and organizes the field into five parts: seed prompts, evaluation and feedback, candidate generation, filtering the promising candidates, and how many rounds to run. The takeaway for a product team: every method needs a metric and an evaluation set, and you supply both.

Manual or automatic prompt optimization?

Manual optimization means a person edits the prompt, reads the answers and decides. It is slow, but it makes you look at real output. Automatic prompt optimization lets a program propose and score candidate prompts. In a January 2025 benchmark, two LangChain authors compared five methods on five datasets: few-shot examples, meta-prompting, meta-prompting with reflection, prompt gradients and evolutionary search. Gains were largest where the model lacked domain knowledge, with improvements of up to about 200 percent over the starting prompt.

The same authors report wide error bars, with many lower bounds below zero, and say the gains are not guaranteed. They also note that optimization did not give the model new reasoning ability. Both are reasons to treat an automatic result as a candidate, not a verdict.

What should you optimize for?

Optimize against what good means for your users, written down before you start. That is a list of criteria, each with a pass mark: for example "the answer names its source" or "the answer fits the question the user asked". A criterion you can score as pass or fail is easier to improve than a vague overall quality score.

Set the pass marks before you look at any results. If you pick them afterwards, you will pick numbers the new prompt happens to reach. The guide to AI evals covers how to write criteria in your own words and why the pass mark comes first.

How do you test a prompt?

Testing a prompt means running it on a fixed set of inputs and scoring every answer against your criteria. Keep the inputs fixed between versions, so a difference in score comes from the prompt and not from a different sample. Change one thing at a time when you can, so you know what moved the score.

Small changes can matter more than you expect. A 2023 paper by Sclar and colleagues found that subtle formatting changes in a prompt changed accuracy by up to 76 points in few-shot settings with one open-source model (LLaMA-2-13B), and the sensitivity did not go away with larger models or more examples. That is why you compare versions on the same inputs instead of trusting a few answers you read by eye.

Three ways to score a tested prompt
CheckWhat it catchesWhat it misses
A rule in codeFormat, length, a required field, a missing sourceWhether the content is right or useful
A model as judgeTone, relevance, faithfulness at volumeWhat your users actually needed
Real usersWhether the answer helpedAnything you cannot ask enough people about

When a rule in code cannot tell good from bad, a model can score the answers. Read LLM as a judge first, because a judge needs checking against human labels before you rely on it.

Why can a higher score mean nothing?

Because the prompt was tuned on the same examples that scored it. This is overfitting: the prompt gets good at those examples, not at the task. The LangChain benchmark says it plainly. They advise keeping a separate test split to confirm the improvement, because a prompt tuned on the same examples that score it can look better than it is.

The fix is a held-out set: examples the optimizer and you never touch while tuning. You score the final candidate on it once. If the score on the tuning examples rose and the held-out score did not, the improvement is not real. A 2025 survey makes a related warning: relying on a single static evaluation set can bias which prompt gets selected.

Where the examples come from matters as much as the split. Examples you invented tend to look like the prompt you wrote. Build the set from real user questions and real answers instead; the guide to the golden dataset shows how, and why the rows where people disagree are the most useful.

Does a better prompt break something else?

It can. A prompt change that lifts one criterion may lower another: shorter answers that are easier to read but no longer name their sources, or a stricter tone that makes the assistant refuse reasonable questions. So score every criterion again after each change, not only the one you aimed at, and look at the ones that dropped.

Also read a handful of the answers that changed. Numbers tell you something moved; the answers tell you what. If the change only helps one kind of question, say so in the record, so the next person does not assume it helps them all.

What do you do with the result?

Ship the new prompt as a reviewed change, the same way you ship code. The change should carry its reason: which criterion was furthest from its pass mark, the score before and after, the held-out result, and any criterion that dropped. A teammate can then approve it, question it or reject it, and the record stays when the person who wrote it has moved on.

Eva follows this pattern, and it is in alpha. Eva reads your code read-only, asks your users short questions inside the product, measures the answers against the criteria your team wrote, and opens one pull request with the reason in it. Your team reviews it like any other, your CI checks it, and Eva never merges. After the change, Eva measures all criteria again, so you see side effects before your users do. See how the step works on the features page.

What can prompt optimization not tell you?

A score tells you the prompt does better on your criteria and your examples. It does not tell you the criteria are the right ones, or that your examples cover how people really use the product. Optimization also cannot give a model knowledge or reasoning it lacks: in the LangChain benchmark, the target model stayed under a 65 percent pass rate on a math task whatever method was used. When a prompt stops improving, the next step may be a different model, better data or a different design, not another round of rewording.

← All posts

Want to see Eva on your own product?

Apply for accessTalk to a founder