Prompt Engineering
A mental model for what makes a prompt reliable, and how to iterate when it isn't
What prompt engineering is
Prompt engineering is getting a model to do what you actually meant, through the words, structure, and examples you give it, not through a setting you flip. The same model, on the same task, produces a noticeably better or worse result depending on how the prompt is written.
Five levers that make a prompt work
- Explicit task: state exactly what you want, not what you’re avoiding. “Summarize this in three bullet points for a non-technical audience” beats “summarize this”
- System message: split system and user messages. The system message sets role, tone, and constraints once, while the user message carries the input
- Output format: state the output format you want. If you need JSON, a fixed length, or a specific structure, say so directly rather than implying it through example alone
- Few-shot examples: show, don’t just tell, for nuanced judgment. An assistant message is a valid part of a prompt, so one or two example responses written as assistant turns teach a style or a judgment call more reliably than a paragraph describing it
- Relevant context: only include context the model needs. More context isn’t automatically better; irrelevant material distracts the model and adds cost without adding accuracy
Here’s a weak prompt and the same task with all five levers applied:
Weak prompt:
Here's the customer's full message history, all 40 messages. Look at the most recent one and tell me how they feel about it.
Same task, with all five levers applied:
System message:
You are a support assistant. Be concise and avoid jargon.
User message (example turn):
Classify the sentiment of this customer feedback as Positive, Negative, or Neutral, and give a one-word reason.
Feedback: "The product arrived broken and support never replied."
Assistant message (example turn):
Negative - defect
User message (real input):
Feedback: "The app keeps crashing when I try to export my report."
From symptom to lever
When a prompt’s output goes wrong, it’s tempting to guess at the cause. It’s more useful to ask which lever above actually controls it, since most failures come down to exactly one of the five.
| Symptom | Lever | Fix |
|---|---|---|
| Instruction gets partly ignored | Explicit task | State the instruction plainly instead of burying it in a longer prompt |
| Tone drifts across runs | System message | Define persona and tone in the system message instead of leaving them implicit |
| Format or length is inconsistent | Output format | Spell out the exact structure or length you want |
| A judgment call misses the mark | Few-shot examples | Add one or two assistant message examples showing the call you want |
| Model hallucinates or drifts off-topic | Relevant context | Give it only the context it needs, and tell it to say “I don’t know” when that’s not enough |
The iteration loop
Prompt engineering rarely lands on the first try. Run the prompt against real inputs, evaluate the outputs instead of eyeballing them, and commit and compare versions to check whether a change helped. Change one thing at a time, so if the score moves, you know which change caused it.
Note
This page covers the wording. Errors or disabled buttons in the product itself belong on Prompt FAQ & fixes.
Keep exploring
Questions & Discussion