FreePrompt Engineering

Few-Shot Prompting: Teach the AI by Showing It Examples

8 min·Beginner → Intermediate··Tested on Claude Sonnet 4.6 (June 2026)
Few-Shot Prompting: Teach the AI by Showing It Examples

You'll learn: how to teach the AI a style, format, or transformation by showing it 1–3 examples — and how to pick examples that work. You'll walk away with: the Few-Shot Pattern Pack — the input→output template + the 4 rules for good examples. Level: Beginner → Intermediate · Prereq: Turn a weak prompt into an expert one

Every example below is a real, unedited Claude (Sonnet 4.6) response from June 2026. Same task — write taglines for Brew Lab — with a different number of examples each time.

1. The Problem

Some things are almost impossible to describe but easy to show. Try explaining your brand's "voice" in words: "smart but not stuffy, witty but not corny, confident but not salesy." The AI will nod and still give you something generic.

The fix is few-shot prompting: instead of describing what you want, you show the AI a few examples and let it copy the pattern. It's the difference between telling someone "be funny" and handing them three jokes that landed.

Let's watch one task — writing taglines — go from generic to on-brand as we add examples.

2. Beginner Example — Zero-Shot vs One-Shot

Zero-shot (no examples)

Write 5 short product taglines (under 12 words each) for Brew Lab, an online coffee brand.

Real output:

  • Precision roasted. Perfectly brewed. Science in every sip.
  • Great coffee isn't luck — it's chemistry.
  • From bean to breakthrough, brewed for the bold.

Not bad… but generic. "Science in every sip," "brewed for the bold" — the kind of lines a hundred brands could use. With nothing to copy, the AI reaches for clichés.

One-shot (a single example)

Here's an example of our tagline style:
"Some coffees taste like coffee. This one tastes like somewhere."

Write 5 more Brew Lab taglines in this same style (under 12 words each).

Real output:

  • "Some mornings happen to you. This one you chose."
  • "Some cups wake you up. This one slows you down."
  • "Some coffee fills the mug. This one fills the room."

Whoa — it nailed the vibe. But notice something: every single line copied the exact structure of the one example: "Some ___. This one ___."

That's the key lesson about one-shot: the AI treats your one example as the rule. Sometimes that's perfect (you want that exact template). But if you only meant "this general vibe," one example boxes it in.

🔑 One example = one pattern. The AI assumes the structure of your single example is the format you want. Powerful, but narrow.

3. Intermediate Example — Few-Shot (3 Examples)

Now we give three examples — deliberately using different sentence structures:

Here are examples of our tagline style:
- "Some coffees taste like coffee. This one tastes like somewhere."
- "We roast after you order. Stale is a choice we don't make."
- "Tasting notes aren't marketing. They're a lab report you can drink."

Write 5 more Brew Lab taglines in this same style (under 12 words each).

Real output:

  • "Freshness isn't a feature. It's the whole argument."
  • "Most roasters guess. We measure, then we roast."
  • "The bag tells you when. We tell you why."
  • "Good coffee asks questions. Ours expects answers."

Now that's on-brand — and it's varied. Because the three examples used different structures, the AI stopped copying one template and instead learned the underlying voice: contrarian, science-y, confident. The output is natural, not formulaic.

🔑 Vary your examples to teach a style; keep them uniform to teach a format. Three varied examples → the AI generalizes the vibe. Three identical-structure examples → it locks the template.

4. Advanced Example — Input→Output Pairs (the power move)

The most powerful form of few-shot isn't "here are some examples" — it's showing the AI a transformation as input→output pairs. It learns the mapping and applies it to new inputs:

Turn each plain coffee feature into a Brew Lab tagline. Follow these examples:

Feature: Roasted to order, ships in 48 hours.
Tagline: We roast after you order. Stale is a choice we don't make.

Feature: Single-origin Ethiopian, light roast.
Tagline: One farm. One bean. Nothing hiding in the blend.

Now do these:
Feature: We publish the altitude, process, and roast date on every bag.
Feature: Light roasts that taste like fruit, not char.

Real output:

"Every bag tells you exactly what's inside. Because transparency shouldn't stop at the label." "Light roast done right. Bright, fruity, and proof that coffee doesn't have to taste like a campfire."

It learned the feature → tagline transformation and applied it to brand-new features. This is how you teach the AI to do repeatable work — classify tickets, format data, rewrite in a house style, turn notes into summaries — all by example.

🔑 Input→output pairs teach a transformation. Show 2–3 input → output examples and the AI applies the same mapping to new inputs.

5. ⚠️ The Catch: The AI Copies *Everything* in Your Examples

Look closely at #4. The new taglines are good — but they're noticeably longer and wordier than the short, punchy examples we gave. Why?

Because the AI copies every pattern it detects in your examples — and infers rules you didn't state. Our examples happened to be short, but we never said "keep them short," so it didn't treat brevity as a rule. It matched the transformation and the voice, but let the length drift.

This is the golden rule of few-shot:

  • Your examples are the spec. Whatever they have in common — length, tone, structure, formatting — the AI will treat as the target.
  • Make examples consistent on the things that matter.
  • Add an explicit constraint for anything your examples don't reliably encode ("…each under 10 words"). Examples + a constraint beat either alone. (More on this in Output Formatting.)

6. Common Mistakes

Mistake Why it happens The fix
Describing the style instead of showing it We default to instructions Paste 1–3 real examples
Using one example when you wanted variety The AI copies that one template exactly Give 3 varied examples to teach the vibe
Inconsistent examples We grab whatever's handy Make examples consistent on tone/length/format
Assuming the AI infers the implicit rule Examples don't state everything Add an explicit constraint (length, count, format)
Examples that contradict each other Mixed messages Every example should be one you'd happily accept

7. Templates (Your Take-Home)

Few-shot for style:

Here are examples of the style I want:
- [example 1]
- [example 2]
- [example 3]   ← vary the structure; keep the tone consistent
Now produce [N] more in this same style. [+ any explicit constraint]

Few-shot as input→output (transformation):

[Describe the task]. Follow these examples:

Input: [example input 1]
Output: [example output 1]

Input: [example input 2]
Output: [example output 2]

Now do these:
Input: [new input]

📥 Download the Few-Shot Pattern Pack (free) — both templates, how many examples to use, and the 4 rules for good examples. (Email opt-in.)

8. Your Challenge

Do this now: pick something with a style or format you want repeated (your email sign-offs, a caption style, a way you label tasks). Give the AI 3 examples, then ask for 5 more. Then add one explicit constraint and compare.

You did it right if: the output matches your examples closely enough to use — and you can name which property you had to pin down with a constraint.


Keep going: ← Pillar: Upgrade a Prompt · Siblings: Role Prompting · Context Prompting · Output Formatting · Start the Starter Course →

Continue learning

Get the full Prompt Library inside the Starter course

Get the full Prompt Library inside the Starter course →
← Back to all lessons