Tutorials8 min read25 May 2026

Few-Shot Prompting: Show the AI What You Want

When describing what you want in words fails, showing the AI examples almost always works. A complete guide to few-shot prompting with four practical use cases.

When Words Are Not Enough

You know exactly what you want but cannot get the AI to produce it. You describe the tone, the format, the style — and the AI does something close but not quite right. You iterate, rephrase, add more constraints. Still not right.

This is the most common failure mode in prompting. The problem is that natural language is ambiguous. "Concise but warm" means different things to different people. "Professional" can mean formal academic prose or polished startup copy. Words describe the target imprecisely.

A prompt that often fails
PROMPT:
"Write a rejection email for a job applicant. Tone: warm, professional,
encouraging. Under 100 words. Do not sound like a template."

RESULT (typical):
"Dear John,

Thank you for taking the time to interview with us. After careful consideration,
we have decided to move forward with another candidate whose qualifications more
closely align with our current needs. We wish you all the best in your future
endeavours and encourage you to apply again in the future.

Best regards,
[Name]"

PROBLEM: It sounds exactly like a template. The words "warm" and "encouraging"
did not produce warmth or encouragement — just polite corporate language.

What Few-Shot Prompting Is

Instead of describing what you want, you show the AI examples of it. A few-shot prompt includes one or more example input-output pairs before the task you want completed. The AI infers the pattern from the examples and applies it to the new input.

"Few-shot" refers to the number of examples: zero-shot is no examples (just instructions), one-shot is one example, few-shot is typically 2–5 examples. More examples generally mean better results up to a point.

The term "few-shot" comes from machine learning, where it describes a model that learns a new task from a small number of examples. In prompting, you are not training the model — you are communicating your specification through examples rather than through words.

Zero-Shot vs One-Shot vs Few-Shot

The same task — converting a customer complaint into a structured support ticket — with three different prompt approaches:

Zero-shot (no examples)
PROMPT:
"Convert this customer complaint into a structured support ticket.

Complaint: I ordered the blue widget on May 1st, order #4421. It arrived
broken — the handle is completely snapped. I need a replacement ASAP."

RESULT (typical — structure varies each time):
Subject: Broken Widget - Order #4421
Description: Customer received a broken widget. Handle is snapped.
Priority: High

(Sometimes you get JSON, sometimes bullet points, sometimes prose.
No consistency because you didn't define the format.)
One-shot (one example)
PROMPT:
"Convert customer complaints into structured support tickets.

Example:
Complaint: "My account got locked out and I can't reset my password.
I've been trying for 3 days."
Ticket:
{
  "issue_type": "Account Access",
  "severity": "High",
  "summary": "Account locked, password reset not working",
  "customer_action_needed": false,
  "days_waiting": 3
}

Now convert this complaint:
Complaint: "I ordered the blue widget on May 1st, order #4421.
It arrived broken — the handle is completely snapped. I need a replacement ASAP."
Few-shot (3 examples) + result
PROMPT:
"Convert customer complaints into structured support tickets.

Complaint: "My account got locked out and I can't reset my password. 3 days."
Ticket: {"issue_type": "Account Access", "severity": "High", "summary": "Account locked, password reset failing", "customer_action_needed": false, "days_waiting": 3}

Complaint: "Wrong item sent. I ordered size L, got size S. Order #2201."
Ticket: {"issue_type": "Wrong Item", "severity": "Medium", "summary": "Wrong size shipped", "customer_action_needed": false, "order_id": "2201"}

Complaint: "Tracking says delivered but nothing here. Left it with a neighbour?"
Ticket: {"issue_type": "Delivery", "severity": "Medium", "summary": "Item marked delivered but not received", "customer_action_needed": true, "action": "Check with neighbours"}

Now convert:
Complaint: "I ordered the blue widget on May 1st, order #4421.
It arrived broken — the handle is completely snapped. I need a replacement ASAP."

RESULT (consistent, correct format):
{"issue_type": "Damaged Item", "severity": "High", "summary": "Item arrived with broken handle, replacement requested", "customer_action_needed": false, "order_id": "4421"}

4 Real Use Cases

1. Email Tone Matching

Few-shot prompt
"Write client emails in the style shown in these examples.

Example 1:
Situation: Following up after a demo
Email: "Hey Alex — really enjoyed the chat yesterday. Quick one: did you have a chance
to pull in your VP? Keen to understand if the pricing structure works before we get too
deep into the weeds. Happy to jump on a 20-min call this week."

Example 2:
Situation: Declining a scope expansion request
Email: "Hi Sarah — thanks for the extra context. We can definitely add that but it would
push timeline by ~2 weeks and add roughly 15% to the budget. Want to have a quick chat
to decide if it's worth it, or should I build it into the next phase?"

Now write an email for this situation:
Situation: Letting a client know their project will be delayed by one week due to an
unexpected technical issue we found during testing."

The two examples communicate the style more precisely than "casual but professional" ever could. The AI picks up the short sentences, the direct questions, the informal opener, and applies all of it.

2. Data Extraction into JSON

Few-shot prompt
"Extract company information from text into JSON.

Text: "Stripe was founded in 2010 by Patrick and John Collison.
Headquartered in San Francisco, it processes payments for millions of businesses."
JSON: {"company": "Stripe", "founded": 2010, "founders": ["Patrick Collison", "John Collison"], "hq": "San Francisco", "industry": "Payments"}

Text: "Figma is a collaborative design tool started by Dylan Field and Evan Wallace in 2012.
The company is based in New York and was acquired by Adobe."
JSON: {"company": "Figma", "founded": 2012, "founders": ["Dylan Field", "Evan Wallace"], "hq": "New York", "industry": "Design software"}

Now extract:
Text: "Linear was built by Karri Saarinen, Jori Lallo, and Tuomas Artman in 2019.
The team is remote-first with an office in San Francisco. They make software for issue tracking."

3. Sentiment Classification

Few-shot prompt
"Classify the sentiment of customer reviews. Use: POSITIVE, NEGATIVE, NEUTRAL, MIXED.

Review: "Absolutely love this product. Does exactly what it says."
Sentiment: POSITIVE

Review: "Works fine for basic tasks but crashes when I try to import large files."
Sentiment: MIXED

Review: "Item arrived. Haven't tried it yet."
Sentiment: NEUTRAL

Review: "Complete waste of money. Broke after one week and customer service ignored me."
Sentiment: NEGATIVE

Now classify:
Review: "The software is powerful once you figure it out, but the learning curve is brutal.
Customer support was surprisingly helpful when I got stuck."

4. Code Style Matching

Few-shot prompt
"Write utility functions in the style shown in these examples from our codebase.

Example 1:
function formatCurrency(amount: number, currency = 'USD'): string {
  return new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency,
    minimumFractionDigits: 2,
  }).format(amount)
}

Example 2:
function truncateString(str: string, maxLength: number, suffix = '...'): string {
  if (str.length <= maxLength) return str
  return str.slice(0, maxLength - suffix.length) + suffix
}

Now write a utility function that:
Converts a snake_case string to camelCase (e.g. 'first_name' → 'firstName')"

How Many Examples Is Enough?

For most tasks, 1–3 examples is the sweet spot. One example establishes the pattern. Two or three examples confirm it and handle variation. Beyond 5 examples you are usually paying more in tokens than you gain in quality — unless the task has many distinct cases to cover.
  • Format tasks (JSON extraction, classification) — 2–3 examples is usually enough
  • Style matching — 3–5 examples because style has more dimensions to communicate
  • Complex reasoning tasks — 3–5 examples showing both the reasoning process and the output
  • Tasks with multiple output cases — one example per distinct case type

When Few-Shot Hurts More Than Helps

Examples define the pattern — including constraints you did not intend. If all your examples use a formal tone, the AI will use formal tone even when the input is informal. If all your examples are short, the AI will produce short output even when a longer answer is needed. Your examples are an implicit specification of every dimension of the output.
  • When your examples are not representative — a few outlier examples will lead the AI to treat the outlier as the norm
  • When the task varies widely — a small set of examples can anchor the AI to a narrow interpretation
  • When you want the AI's best judgment — examples can override the model's knowledge with your (possibly worse) examples
  • When your examples have subtle inconsistencies — the AI will try to reconcile them and usually picks the wrong interpretation

The Golden Rule

Your examples are your specification. They communicate every dimension of the output simultaneously: format, length, tone, level of detail, vocabulary, structure. Writing good examples is writing a precise specification — it just looks like writing instead of documentation.

Before writing your examples, ask: what are the dimensions that matter for this output? For email: tone, length, opener style, sign-off. For JSON extraction: field names, data types, handling of missing data. Write examples that demonstrate all of these, not just the obvious one.

Tips for Writing Good Examples

  • Use real examples from your own work when possible — they are more consistent and more representative than invented ones
  • Cover the variation you actually see in your inputs — if inputs range from one sentence to five paragraphs, show examples at both ends
  • Make examples self-consistent — do not mix formal and informal examples if you want a consistent output
  • Include at least one example of an edge case if edge cases matter: missing data, ambiguous input, unexpected format
  • Keep examples as short as they can be while still communicating the pattern — long examples dilute the signal
  • If you get an output that does not match your intent, use it as a negative example: "Do NOT format it like this: [bad output]. Instead, format it like this: [good output]"
promptingfew-shotexamplestutorialsfundamentals
🎓Interactive Courses

Ready to go further?

Take the interactive course — daily lessons, real exercises, XP and streaks. Turn reading into lasting skills.

Daily streaksXP & levels
Start a course