Few-Shot Prompting
Few-shot prompting teaches the model a pattern by showing a few input-output examples before the target task. It is one of the most reliable ways to improve format and style consistency.
Beginner Core technique
When to use
Use it when the task has a recurring pattern, when zero-shot output is unstable, or when you need the model to follow a specific style or format.
Prompt example
Task: Apply Few-Shot Prompting to the user's request. Context: describe the input, constraints, target audience, and desired format. Instruction: be explicit, keep the output structured, and state any assumptions.
Output example
Structured answer based on the requested technique. Key result: the model follows the stated task and format. Notes: validate the output before using it in production.
Best practices
- Use examples that cover categories and edge cases.
- Keep the example format exactly consistent.
- Put the most relevant example close to the target query.
- Three to five examples are often enough.
Common pitfalls
- Too many examples consume context window budget.
- Biased examples can amplify biased output.
- Incorrect examples mislead the model more than missing examples.