Why Examples Beat Instructions
Imagine training a new hire to write customer emails. You could hand them a ten-page style guide covering tone, structure, greetings, sign-offs, and escalation language. Or you could show them three good emails and say, “Write like these.”
Most of the time, the three examples work better. The new hire picks up on patterns that are hard to describe in words: the rhythm of sentences, when to use a customer’s first name, how to acknowledge a problem without over-apologizing.
AI works the same way. When you provide examples of the output you want, the model picks up on patterns in format, style, labeling, and structure. This technique is called few-shot prompting, and it is one of the most reliable ways to get consistent results from any AI model.
Insight
Zero-Shot, One-Shot, and Few-Shot Explained
The terms zero-shot, one-shot, and few-shot refer to how many examples you provide in your prompt. Each approach has its place depending on the complexity of the task.
Zero-Shot
One-Shot
Few-Shot
The key question is: can the AI figure out what you want from instructions alone, or does it need to see examples? For simple tasks like “summarize this paragraph,” zero-shot usually works. For tasks requiring a specific format, classification scheme, or writing style, few-shot is more reliable.
| Approach | Examples | Best For | Tradeoff |
|---|---|---|---|
| Zero-Shot | 0 | Simple, common tasks | Fast to write, less predictable output |
| One-Shot | 1 | Format guidance, simple patterns | Quick setup, may overfit to the single example |
| Few-Shot | 2-5 | Classification, style, complex formatting | Most reliable, uses more context window |
How Few-Shot Prompting Works
When you include examples in your prompt, the AI model performs what researchers call “in-context learning.” It analyzes the pattern across your examples and applies that same pattern to new input. This happens within the conversation window — the model does not permanently learn or update its weights.
The model looks for consistency across your examples: What format does the output follow? What labels are used? How long are the responses? What information is included or excluded? It then replicates those patterns when processing your actual request.
This is why the quality of your examples matters more than the quantity. Three well-chosen examples that clearly demonstrate the pattern will outperform ten sloppy ones.
Pro Tip
Building Effective Examples
The structure of your examples determines how well the AI picks up on your intended pattern. Good examples are consistent in format, diverse in content, and clear in their labeling.
Every example should follow the same input-output structure. If your first example uses “Input:” and “Output:” labels, every example should use those same labels. Inconsistent formatting confuses the model about which parts are input, which are output, and which are instructions.
Classify each customer message by department. Use exactly one label: Sales, Support, Billing, or Feedback. Input: "I'd like to upgrade to the enterprise plan for my team of 25." Department: Sales Input: "The export feature keeps timing out when I try to download large reports." Department: Support Input: "I was charged twice for my November subscription." Department: Billing Input: "Love the new dashboard redesign! The charts are much easier to read now." Department: Feedback Input: "We're interested in custom API access for our integration project." Department:
- Cover different categories: Include at least one example per expected output category or type
- Vary the difficulty: Mix obvious cases with borderline ones so the AI learns to handle ambiguity
- Keep format identical: Same labels, same structure, same separators in every example
- Use realistic data: Examples should look like actual inputs the AI will encounter
- Include edge cases: If some inputs could belong to multiple categories, show how you want those handled
- Order matters less than you think: The AI looks at all examples together, so ordering is less critical than consistency
Few-Shot for Different Tasks
Few-shot prompting adapts to nearly any task. Here are practical examples across four common use cases.
Classification
Classification is the most natural fit for few-shot prompting. By showing the AI labeled examples, you define the categories and demonstrate how to assign them.
Rate each product review as Positive, Negative, or Mixed. Review: "Fast shipping and the product works exactly as described. Will buy again." Sentiment: Positive Review: "The build quality is terrible. Broke after two days of normal use." Sentiment: Negative Review: "Great features for the price, but the mobile app crashes frequently." Sentiment: Mixed Review: "Decent battery life and the screen is sharp, but the camera is disappointing for this price range." Sentiment:
Formatting
When you need unstructured text converted to a specific format, examples are far more effective than describing the format in words. Show the AI what the transformation looks like.
Convert each event description into a structured JSON object.
Description: "Marketing team standup every Monday at 9am in the main conference room, runs 30 minutes"
JSON: {"event": "Marketing team standup", "day": "Monday", "time": "09:00", "location": "Main conference room", "duration": "30 min"}
Description: "Quarterly board review on March 15th from 2pm to 5pm, virtual via Zoom"
JSON: {"event": "Quarterly board review", "day": "March 15", "time": "14:00", "location": "Zoom (virtual)", "duration": "3 hours"}
Description: "Lunch and learn about AI tools this Friday at noon in the break room, about an hour"
JSON:Style Transfer
Describing a writing style in words is imprecise. Showing examples of the style is direct and unambiguous. Few-shot works well for brand voice, tone adjustments, and rewriting tasks.
Rewrite each technical feature description in a friendly, benefit-focused style for a product landing page. Technical: "Implements AES-256 encryption with rotating keys and zero-knowledge architecture." Friendly: "Your data is locked down with bank-level encryption. Even we can't read it — and that's by design." Technical: "Supports real-time bidirectional sync across unlimited devices via WebSocket connections." Friendly: "Edit on your laptop, check your phone, pick up on your tablet. Everything stays in sync, instantly." Technical: "Offers granular role-based access control with custom permission matrices and audit logging." Friendly:
Data Extraction
Pulling structured data from messy, unstructured text is a task where few-shot prompting shines. The examples teach the AI exactly which pieces of information to extract and how to format them.
Extract contact information from each email signature. Signature: "Best regards, Sarah Chen | VP of Engineering | Acme Corp | sarah.chen@acme.com | (415) 555-0192" Extracted: Name: Sarah Chen | Title: VP of Engineering | Company: Acme Corp | Email: sarah.chen@acme.com | Phone: (415) 555-0192 Signature: "Thanks! — Mike R. / Sales Lead, BrightPath Solutions / mike@brightpath.io" Extracted: Name: Mike R. | Title: Sales Lead | Company: BrightPath Solutions | Email: mike@brightpath.io | Phone: N/A Signature: "Cheers, Dr. Aisha Patel, Chief Data Scientist at NovaTech Labs, aisha.patel@novalabs.com, ext 4402" Extracted:
Before & After
See the difference between a zero-shot instruction and a few-shot approach for the same task: extracting product features from customer reviews.
Extract the product features mentioned in this customer review. List them as bullet points. Review: "The noise cancellation on these headphones is incredible — I can't hear my coworkers at all. Battery lasts about 20 hours which gets me through the week. The ear cushions are super comfortable for long sessions, though I wish the Bluetooth range was better. Keeps cutting out when I walk to the kitchen."
Extract product features from each review. For each feature, note whether the sentiment is positive or negative. Review: "Love the screen brightness on this tablet. The speakers are tinny though, and the stylus response has a noticeable lag." Features: - Screen brightness (positive) - Speaker quality (negative) - Stylus responsiveness (negative) Review: "The keyboard has great travel and the trackpad is responsive. Wish the webcam wasn't so grainy." Features: - Keyboard travel (positive) - Trackpad responsiveness (positive) - Webcam quality (negative) Review: "The noise cancellation on these headphones is incredible — I can't hear my coworkers at all. Battery lasts about 20 hours which gets me through the week. The ear cushions are super comfortable for long sessions, though I wish the Bluetooth range was better. Keeps cutting out when I walk to the kitchen." Features:
Success
How Many Examples Do You Need?
More examples are not always better. The right number depends on the complexity of the task and how much ambiguity exists in the expected output.
| Task Complexity | Examples | When to Use |
|---|---|---|
| Simple format | 1 | Output format is the only thing to demonstrate |
| Classification | 2-3 | One example per category minimum |
| Nuanced style or tone | 3-5 | Style patterns need multiple data points to emerge |
| Complex extraction | 3-5 | Varying input formats need diverse demonstrations |
After about five examples, you typically hit diminishing returns. Each additional example uses context window space that could hold your actual input data. If five examples are not enough, the task may need a different approach entirely — consider breaking it into smaller steps or combining few-shot with chain-of-thought prompting.
Warning
Common Mistakes
These five mistakes reduce the effectiveness of few-shot prompting. Avoiding them will improve your results immediately.
1. Inconsistent formatting
Using “Input:” in one example and “Text:” in another. The model cannot tell which format to follow. Pick one label scheme and stick with it across all examples.
2. Examples too similar
If all your examples are positive sentiment, the model has no reference for handling negative or mixed cases. Cover the range of expected inputs and outputs.
3. Overly long examples
Long examples eat into your context window and can introduce noise. Keep examples short and focused on the pattern you want the AI to replicate.
4. Incorrect labels
A mislabeled example teaches the wrong pattern. If you label a negative review as positive, the AI will learn that mapping. Double-check every example label before using it.
5. No edge cases
Only showing clean, obvious examples leaves the AI guessing on ambiguous inputs. Include at least one borderline case that demonstrates how you want tricky situations handled — for instance, a review that is mostly positive but mentions one serious flaw.
Quick Reference Cheatsheet
Use this table as a quick reference when deciding how to structure few-shot prompts for different tasks.
| Task Type | Shots | Example Format | Key Tip |
|---|---|---|---|
| Sentiment analysis | 3 | Text → Label | Include one mixed example |
| Text-to-JSON | 2-3 | Raw text → JSON | Vary the input messiness |
| Brand voice | 3-5 | Original → Rewritten | Use different content types |
| Data extraction | 2-3 | Unstructured → Fields | Show how to handle missing data |
| Ticket routing | 4-5 | Message → Department | One example per category |
| Summarization | 1-2 | Long text → Summary | Show desired length and detail |
Few-Shot Template - Copy and Adapt: [Task instruction: Describe what the AI should do with each input.] [Label for input]: "[Example input 1]" [Label for output]: [Example output 1] [Label for input]: "[Example input 2]" [Label for output]: [Example output 2] [Label for input]: "[Example input 3]" [Label for output]: [Example output 3] [Label for input]: "[Your actual input]" [Label for output]:
Next Steps
Few-shot prompting works well on its own, but it combines powerfully with other techniques. Try pairing examples with chain-of-thought prompting to show the AI both what to produce and how to reason through it.
For a broader framework that structures your entire prompt — not just the examples — see the COSTAR method guide. You can embed few-shot examples inside a COSTAR prompt for maximum clarity and consistency.
Build few-shot prompts faster
AskSmarter helps you structure prompts with the right examples for your task. Answer a few questions, and we generate a prompt with built-in few-shot examples tailored to your use case.
Start building free