Few-Shot Prompting
Giving an AI 2–5 examples of the task before asking it to do yours.
Few-shot prompting means including a small number of example input/output pairs in your prompt before the actual request. The model uses these examples as a pattern to follow — without any weight updates or fine-tuning.
Example structure:
Classify the sentiment of each review.
Review: "Absolutely loved the product!" → Positive
Review: "Terrible quality, broke in a week." → Negative
Review: "It's okay, nothing special." → [model fills this in]
Why it works: LLMs are trained to continue patterns. Showing the pattern explicitly at inference time steers the output far more reliably than a vague instruction.
When few-shot beats zero-shot:
- Unusual output formats (JSON with specific keys, numbered lists, tables)
- Domain-specific terminology or style
- Edge cases you want handled consistently
- Tasks where "good" is hard to define but easy to show
Rule of thumb: 3–5 examples usually suffice. More than 10 rarely helps and adds tokens. Ensure examples are diverse and representative of the range you'll encounter.
In plain terms
Teaching a child to sort laundry by showing three examples — 'this sock goes here, this shirt goes there' — rather than explaining the sorting algorithm.
Related concepts
Prompt Engineering
The art of asking AI the right question in the right way.
Chain of Thought
Prompting a model to reason step-by-step before giving its final answer.
Large Language Model
AI trained on vast text to understand and generate language.
Zero-Shot Prompting
Asking an AI to do a task with no examples — just instructions.