Teach AI exactly what you want by showing it examples of the desired output.
What Are Few-Shot Examples?
Few-shot prompting is the technique of including example input/output pairs in your prompt to show the AI exactly what you want. Instead of describing the format, style, or logic you need, you demonstrate it — and the AI follows the pattern.
It's like training a new employee. You could hand them a 10-page style guide, or you could show them three examples of completed work and say "do it like this." Most people learn faster from examples — and so does AI.
This technique is especially valuable when you need a very specific output format, a particular writing style, or consistent classification logic that's hard to describe in words alone.
Zero-Shot vs One-Shot vs Few-Shot
These terms describe how many examples you include in your prompt:
How Many Examples Do You Need?
For simple formatting tasks, 1–2 examples are usually enough. For classification or style matching, 3–5 examples give the AI a solid pattern to follow. More than 5 rarely helps and wastes prompt space.
See the Difference
Compare a zero-shot approach to a few-shot approach for the same task:
How to Structure Your Examples
The key to effective few-shot prompting is clear, consistent formatting for your input/output pairs. Here's the general structure:
When to Use Few-Shot Prompting
Few-shot examples are your best tool in these situations:
Specific formatting — you need outputs in a particular structure (JSON, tables, templates)
Style matching — writing in a brand voice, mimicking an author's style, maintaining consistent tone
Data transformation — converting one format to another, extracting structured data from text
Edge cases — showing the AI how to handle tricky or ambiguous inputs correctly
Combine with Other Techniques
Few-shot works beautifully with role prompting and chain-of-thought. Try: "Act as a product copywriter. Here are three examples of our brand voice..." or add "Think step by step" after your examples for classification tasks that need reasoning.
Using Negative Examples
Sometimes it's just as important to show the AI what NOT to do. Including a "bad" example alongside your good ones helps the AI avoid common mistakes:
Zero-Shot (no examples) — You give the AI a task with no examples at all. The AI relies entirely on its training. This works fine for simple, well-understood tasks but can be unpredictable for anything unusual or format-specific.
One-Shot (one example) — You provide a single example to set expectations. This is often enough to lock in a format or tone. For instance, showing one product description before asking the AI to write more in the same style.
Few-Shot (2–5 examples) — You provide multiple examples that cover different scenarios. This is the gold standard for consistency. The AI can identify the pattern across examples and apply it reliably to new inputs.
How Many Examples Do You Need?
For simple formatting tasks, 1–2 examples are usually enough. For classification or style matching, 3–5 examples give the AI a solid pattern to follow. More than 5 rarely helps and wastes prompt space.
Label inputs and outputs clearly — Use consistent labels like "Input:", "Output:", or domain-specific labels like "Customer message:", "Category:". This makes the pattern unmistakable for the AI.
Keep examples representative — Choose examples that cover the range of scenarios the AI might encounter. If you're classifying support tickets, include examples from different categories — not three examples all from the same one.
Match the complexity of your target — If you need a 3-sentence product description, don't provide examples that are each 3 paragraphs long. The AI will mirror the length and complexity of your examples.
Combine with Other Techniques
Few-shot works beautifully with role prompting and chain-of-thought. Try: "Act as a product copywriter. Here are three examples of our brand voice..." or add "Think step by step" after your examples for classification tasks that need reasoning.
Few-shot prompting teaches the AI by example — show it what you want instead of just describing it.
Zero-shot uses no examples, one-shot uses one, and few-shot uses 2–5 representative examples for the best results.
Structure your examples with clear, consistent labels (Input/Output) and cover the range of scenarios the AI will handle.
Few-shot is especially powerful for formatting, classification, style matching, and data transformation tasks.