Few-Shot Prompting: Add Examples to Your Prompt
Show the model one to three input-output examples so it copies the pattern you want.
Direct answer
Few-shot prompting means including a few example input-output pairs in the prompt so the model imitates the pattern. Add one to three consistent examples that match the exact format you want. Use zero-shot for simple tasks and few-shot when tone, structure, or edge cases matter.
Open the Prompt OptimizerWhen to use this
- The model gets the task but not the format or tone you want.
- You have a specific output shape that is hard to describe in words.
- You want consistent results across many inputs.
Steps
- Describe the task, then add an Examples section.
- Give one to three input-output pairs in the exact format you want.
- Keep the examples consistent — same structure, labels, and tone.
- End with the real input labeled the same way as the examples.
- If results drift, add one more example that covers the edge case.
Example
Task: classify support messages as Bug, Billing, or Other. (no examples)
Task: classify support messages as Bug, Billing, or Other. Examples: Message: "I was charged twice" -> Billing Message: "The app crashes on login" -> Bug Message: "Do you have an Android app?" -> Other Message: "My invoice total looks wrong" ->
Common mistakes
- Inconsistent examples teach an inconsistent pattern; keep the format identical.
- Too many examples waste tokens and can overfit to those cases; one to three is usually enough.
- Examples that contradict your instructions confuse the model — align them.
FAQ
- What is few-shot prompting?
- It is adding a few example input-output pairs to your prompt so the model copies the pattern. It contrasts with zero-shot prompting, which gives no examples.
- How many examples should I include?
- Usually one to three. Enough to show the pattern and edge cases without wasting tokens or overfitting to the examples.
- When should I use zero-shot instead?
- For simple, well-known tasks where a clear instruction is enough. Reach for few-shot when format, tone, or tricky cases matter.
Related Prompt Optimizer guides
How to Structure a Prompt (Template)
The building blocks of a strong prompt — role, context, task, constraints, output format, and examples — with a reusable template.
Write a Prompt From a Rough Idea
Turn a one-line idea of what you want into a full, ready-to-paste structured prompt.
Chain-of-Thought Prompting: Ask for Step-by-Step Reasoning
Prompt the model to reason step by step to improve accuracy on multi-step math, logic, and planning tasks.
Role and Persona Prompting (Act As)
Assign the model a role or persona to control tone, depth, and vocabulary in its answers.
Control the AI Output Format (JSON, Tables, Lists)
Get consistent, parseable output by specifying the exact format, fields, and what to exclude.