LibraryConceptsFew-Shot Prompting: Teaching AI by Example
Concept
2 min readself knowledge

Few-Shot Prompting: Teaching AI by Example

Show AI a few concrete examples of what you want, then ask it to apply the same pattern to new inputs—this is often more effective than written instructions because patterns are learned from observation. Few-shot prompting works especially well when the pattern is complex or hard to describe in words.

Hypatia
Hypatia
Online
The coach is replying…
Why It Matters

Few-shot prompting means showing the AI examples of what you want before asking it to do the task. Instead of just describing what you need, you give it a few examples of the desired output, and it learns from those examples what you're looking for.

Think of it like this: if you tell a designer "make a logo," you get a generic logo. If you show them five logos you love and say "in this style," they understand immediately what you want. Few-shot prompting does the same thing with AI.

How It Works

Structure looks like this:

"I'm going to give you examples of how I want you to respond. Then I'll give you a new input, and you'll follow the same pattern."

Then you provide 2-5 examples showing:

  • The input you're working with
  • The exact output you want
  • The style, format, or reasoning you're using

Then you give the actual input: "Now do this for [new case]."

Real Example

Say you want AI to categorize customer feedback into sentiment buckets, but your categories aren't standard. You could write a detailed explanation, or you could show examples:

"Example 1 - Input: 'Your product helped me solve my biggest problem!' - Output: Strong Positive - Reasoning: Customer achieved concrete results."

"Example 2 - Input: 'It's fine, does what it says.' - Output: Neutral - Reasoning: No emotional engagement, just confirmation of claims."

"Now categorize this one: [new feedback]"

The AI immediately understands your categories aren't just about happy/sad—they're about whether the customer achieved results.

Why This Is Powerful

Few-shot prompting is more powerful than long explanations because humans and AI both learn better from examples than rules. Showing is faster than telling.

This technique is especially useful when:

  • You have a specific style you want consistently
  • Your categories or definitions are unusual
  • You need formatting in a particular way
  • You're batch-processing similar items and want consistent output

When to Use It

Don't use few-shot for one-off tasks—it adds overhead. Use it when you're doing something repeatedly or when description alone hasn't worked well.

The magic: after you provide 2-3 good examples, the AI gets it. You don't need 10 examples—diminishing returns kick in fast.

Try this: Pick a task you've been doing repeatedly (categorizing things, writing in a style, analyzing in a format). Grab 3 examples of output you like, structure them as examples, and show them to AI. Then ask it to do the same thing for new items. Compare the results to what you were getting before—the improvement is usually dramatic.

Recommended Journeys
Hypatia
Go from Zero to Confident AI User in One Week
For complete beginners who have never used AI before and want to feel comfortable and capable having productive conversations with AI tools.
Start journey
Hypatia
Write AI Prompts That Get Results Every Time
For everyday AI users who are frustrated with vague or unhelpful responses and want a reliable system for crafting prompts that consistently deliver what they need.
Start journey
Hypatia
Build Advanced Multi-Step AI Workflows That Scale Your Output
For power users and professionals who want to move beyond single prompts and chain AI conversations, agents, and workflows together to automate complex, high-value tasks.
Start journey
Hypatia
Debug Any AI Failure and Get Back on Track Fast
For intermediate AI users who regularly hit walls with broken outputs, hallucinations, or off-track responses and want a systematic process to diagnose and fix problems quickly.
Start journey

Ready to work on Few-Shot Prompting: Teaching AI by Example?

Explore related journeys, or bring what you’re working through to Hypatia.