Short answer: a few-shot prompt gives the AI one to three examples of input and the output you want, then the new input. The AI copies the pattern: your categories, your spelling, your format. Use it whenever the answer has to fit something that already exists, like your product categories, your naming rules or your report style. Pick examples that cover the tricky cases, not just the easy ones.
The words say what you want; an example shows it. "Categorise these support tickets" gets the AI's categories. Three tickets with your categories next to them get yours.
What does a few-shot prompt look like?
- 1The task"Give each ticket one category from our list"
- 2The listBilling, Login, Bug, Feature request, Other
- 3Examplesthree tickets with the category you would give them
- 4New inputthe tickets to categorise
- 5Format"one line per ticket: ID, category"
Give each support ticket one category: Billing, Login, Bug, Feature request or Other.
Examples:
T-101 "I was charged twice in October" -> Billing
T-102 "Reset link never arrives" -> Login
T-103 "Export to CSV would save me hours" -> Feature request
Now categorise, one line each as ID, category:
T-201 "Can't sign in since the update"
T-202 "Invoice shows the wrong VAT number"How do you pick good examples?
- Cover the borders. "Can't sign in since the update" could be Login or Bug. Include an example that shows which way you decide.
- Use your real format. If the output goes into a table, show the exact columns.
- Keep them short. Three clear examples beat ten long ones.
- Vary them. Three billing examples teach the AI that most things are billing.
When does it help most?
| Job | Without examples | With examples |
|---|---|---|
| Categorise free text | The AI invents categories | Your categories, your edge cases |
| Clean names ("ACME corp.", "Acme Corporation") | A different spelling each time | One canonical form |
| Write metric definitions | Long, generic paragraphs | Your template, your length |
| Summarise a chart for email | A wall of text | Three sentences, in your tone |
What goes wrong?
- Examples that disagree with the instructions. The AI follows the examples.
- Real customer text. Make the examples up, or remove names and numbers.
- No check. Categorise 20 rows you already know, and count how many match, before you run the rest.
Where can you check this?
- Anthropic: Use examples (multishot prompting)
- Google AI for Developers: Prompt design strategies, few-shot examples
Where do you start?
Start with a job you repeat every week, and save the prompt in a prompt library. For prompts that write queries, see prompt engineering for SQL.