Skip to content

Prompts

Evaluate your prompt with numbers, not impressions

How to build a small test set for a prompt your app uses, decide what counts as a correct output, and compare two versions of a prompt before you change what works in production.

Talqeen wrote this article and no editor has reviewed it yet. Search engines do not see this page until it is reviewed.

You change a word in a prompt, try it twice, the output looks better, you ship it. A week later cases that used to work fail. The judgement rested on two examples, and the model does not give the same output every time. Evaluate prompts the way you test code: a fixed set of cases and a result you can count.

Step 1: a test set

Collect twenty to fifty real inputs, with personal data removed: the usual cases, edge cases (empty, very long, another language), cases that failed before, and at least one injection attempt. Keep them in a file in the repository.

Step 2: what "correct" means

Exact match for classification; code checks (the JSON matches the schema, a word is present, a length cap holds); or a short list of conditions for open tasks such as summaries. Start with what code can check: cheaper, faster and steadier than a human.

Step 3: run and compare

Run the current prompt on the whole set and record the pass rate, then the new version on the same set. Adopt the change only if the rate goes up (or holds with a gain you want, such as shorter output or lower cost) and nothing that passed now fails without a reason you accept. Run important cases more than once, and lower the temperature where you want stable output.

A model judging a model

For open tasks a second model can grade the output against your conditions. Useful, but it errs too: review a sample of its verdicts and keep deterministic code checks where you can.

Make it a habit

Add every production failure to the set, change one thing at a time, and record each prompt version with its result. A prompt in your app is code like any other.