Everybody talks about how to write a prompt. Be clear, add context, give examples, … Fine. That's the easy part, and most of us know it by now.
What most people skip is checking whether the prompt really works. And that's the most important part of prompt engineering. Without it, you're only guessing.
So, what is evaluation? In the simplest case it's you, reading the answers and deciding whether they're good enough. It works, but it's slow. The next step up is a grading function. That can be a few lines of code that check the format, the length, a required word, … or a second model that reads the answer and judges it. Either way you get a grade back: pass/fail, or a score from 1 to 10. And once you have a number, your software can run the whole loop on its own.
Here's the loop:
- Set a goal: decide what a good answer looks like.
- Write a first prompt: a simple one is enough, don't polish it yet.
- Evaluate it: run it on a set of real inputs and grade every answer.
- Improve it: now bring in the techniques, one change at a time.
- Evaluate again: use the same inputs and check that the grade went up.
Then repeat. Improve, evaluate, improve, evaluate… for as many rounds as it takes to get results that are good enough.
If you come from the IT world, this should ring a bell: yes, it's a lot like unit testing.
Two more things that rarely get mentioned.
- Keep reading some of the answers yourself, even once you have a grader. Graders get things wrong too (and yes, reading 50 answers is boring).
- Run the whole thing again when the model changes. A prompt that worked fine on the old model can get worse on the new one, and nothing will warn you.
Prompts are like code. If you haven't tested it, it doesn't work yet.