Few-shot prompting
Synonyms: in-context learning, example-based prompting, multi-shot prompting, demonstration prompting, k-shot prompting
Definition
Use cases
- Microcopy generation: A model writing error states may produce long, robotic messages unless you provide examples of short, product-style copy.
- Research synthesis: AI summarization improves when examples show the difference between raw observations and useful insights.
- Content formatting: Structured examples help models follow exact layouts for tables, tags, or labels.
How it's used in practice
- Pick 3–5 diverse examples that cover edge cases, not just happy paths
- Match the exact input/output format you expect returned
- Order examples thoughtfully — the last one often weighs heaviest
- Always test zero-shot first; only add examples if quality drops
- Version-control your example sets like you would code
Challenges & limitations
- Context window bloat: Too many examples eat up your token limit, making prompts expensive or cutting off the actual response.
- Example bias: If your three examples are all "success messages," the AI might struggle if you suddenly ask it to write a "warning" in the same prompt.
Free resources
- Anthropic's Multishot Prompting Guide — direct guidance on using examples with Claude, from the model makers
- OpenAI's Prompt Engineering Guide — strategies and tactics straight from the source
- Google's Prompt Design Strategies — practical guidance from the Gemini team

