โญโญ Intermediate โฑ๏ธ 5 min read Few-shot Prompting

๐Ÿ’ก Give Examples โ€” Teach AI by Showing Patterns

Learn few-shot prompting โ€” the technique of teaching AI what you want by providing examples. Interactive practice with before/after comparisons.

โšก TL;DR

Show AI what you want by providing 2-3 sample inputs and outputs. When words fail, examples succeed.

What Is It?

Giving Examples (also called few-shot prompting) means showing the AI what you want by providing sample inputs and outputs. Instead of describing the pattern, you demonstrate it.

Think of it like training a new colleague. You could explain the process in detail… or you could say “Here are 3 examples of how I categorised similar tickets. Now do the same with these.” Most people learn faster from examples.

๐Ÿ’ก When words fail, examples succeed. If you’ve tried describing what you want and the AI keeps getting it wrong, give it 2-3 examples of the correct output. This often solves the problem instantly.

When to Use It

  • โœ… When you need a specific format that’s hard to describe in words
  • โœ… When you want consistent categorisation or classification
  • โœ… When the AI keeps getting the style or tone wrong
  • โœ… When you need the output to match an existing pattern

Before & After

โŒ Before (No Examples)

Categorize these support tickets

โœ… After (With Examples)

Categorize each support ticket into one of these categories: Billing, Technical, Access, Feature Request.

Here are examples:

  • “I can’t log in to my account” โ†’ Access
  • “I was charged twice this month” โ†’ Billing
  • “The dashboard keeps crashing on mobile” โ†’ Technical

Now categorize these tickets:

  1. “Can you add dark mode?”
  2. “My password reset email never arrived”
  3. “The export to CSV is generating empty files”

What’s better: The AI now understands exactly how to format the output and what each category means in practice โ€” not just in theory.

Platform Tips

Microsoft 365 Copilot

  • In Excel, examples work great: “Flag column B like this: if amount > $1000 โ†’ ‘High’, if $500-$1000 โ†’ ‘Medium’, else ‘Low’”
  • In Word, show a sample paragraph then say “Write 5 more in this style”
  • M365 Copilot can reference existing files as examples: “Format it like the Q1 report”

ChatGPT

  • Paste examples in code blocks for clean formatting
  • ChatGPT carries examples across the conversation โ€” set the pattern once, then give new inputs

Claude

  • Use XML tags: <examples> <example>input โ†’ output</example> </examples>
  • Claude excels at learning complex patterns from just 2-3 examples

Gemini

  • Number your examples clearly: “Example 1:”, “Example 2:”
  • Gemini works best when examples are concise and consistent in format

Real Examples from the Prompt Library

  1. Customer Service โ€” Shows example tone for consistent responses
  2. Writing โ€” Uses style examples to match voice
  3. Data Analysis โ€” Example categorisations for consistent labels

๐Ÿงช Try It Yourself

Rewrite this vague prompt using the Give Examples technique:

Starter prompt (needs improvement):
Categorize these support tickets
Checklist โ€” does your prompt include:
โฌœ Includes at least one example
โฌœ Shows input โ†’ output pattern
โฌœ Clear task after examples
๐Ÿ’ก Stuck? Show example answer

Categorize each support ticket into: Billing, Technical, Access, or Feature Request. Examples: - "I can't log in" โ†’ Access - "Charged twice" โ†’ Billing - "Dashboard crashes" โ†’ Technical Now categorize: 1. "Can you add dark mode?" 2. "Password reset email never arrived" 3. "CSV export is empty"

๐Ÿ”ง Fix This Prompt

This prompt is broken. Can you spot what's wrong and fix it?

Sort these customer emails into categories
โฌœ Defines the categories
โฌœ Provides at least one example
โฌœ Lists the items to categorize

โ“ Frequently Asked Questions

How many examples should I include?

2-3 examples is the sweet spot for most tasks. One example shows the pattern, two confirms it, three covers edge cases. More than 5 rarely helps and wastes tokens.

What's the difference between zero-shot and few-shot prompting?

Zero-shot = no examples (just instructions). Few-shot = includes examples. Use zero-shot for simple tasks and few-shot when AI needs to learn a specific pattern or format.

๐Ÿ’ฌ