LearnAI home

Core Techniques · Lesson 5

Few-Shot: Teaching by Example

Show, don't tell: give the model examples and watch quality jump.

The most underrated trick in prompting

Describing what you want is hard. Showing it is easy.

Few-shot prompting means including two or three examples of the input-output pattern you want, right in the prompt. The model spots the pattern and continues it, often more faithfully than it would follow a paragraph of instructions. ("Few-shot" is just jargon for "a few examples." A prompt with none is "zero-shot.")

Why does it work so well? Language models are pattern-continuation machines at heart. Instructions get interpreted; examples get imitated. Interpretation leaves wiggle room. Imitation doesn't.

Real-world job number 1: labeling support tickets

Say you want incoming support tickets tagged as Billing, Bug, or Feature Request. You could write a long definition of each category... or just show the model three labeled tickets.

Few-shot ticket labeler

Label each support ticket as Billing, Bug, or Feature Request.

Ticket: I was charged twice for my March subscription. Label: Billing

Ticket: The export button does nothing when I click it on Safari. Label: Bug

Ticket: It would be great if I could tag teammates in comments. Label: Feature Request

Ticket: My invoice shows the old company name, can you update it? Label:

The model will answer "Billing", and it learned the format, the label set, and the vibe of each category from three examples. No definitions were harmed in the making of this prompt.

Notice the last line ends mid-pattern, right where the answer goes. Ending your prompt at the exact spot you want the model to continue is a classic few-shot move; it's like leaving one puzzle piece missing.

Real-world job number 2: naming products

Naming is pure taste: nearly impossible to describe, trivially easy to demonstrate.

❌ Weak prompt

Prompt

Suggest names for our new line of spicy snack crackers. Make them fun and punny.

Output

1. Spicy Bites 2. Crunchy Heat 3. Fire Crackers 4. Hot Snackers 5. Zesty Crunch

You said 'fun and punny,' and the model heard 'mildly descriptive.' Adjectives are open to interpretation, and the model interpreted them boringly.

✅ Good prompt

Prompt

Suggest names for our new line of spicy snack crackers, matching the style of these existing products: Cheddar Explosion, Sour Cream and Chaos, The Great Garlic Heist. Give 5 options.

Output

1. Jalapeno Business 2. The Sriracha Situation 3. Cayenne and Able 4. Habanero Heist Part Two 5. Chili Chili Bang Bang

Three examples taught it your brand's whole personality (wordplay, drama, a little chaos) better than any paragraph of adjectives could.

The rules of good examples

  1. Two or three is usually plenty. Quality beats quantity; one bad example teaches a bad lesson.
  2. Make them consistent. Same format, same style, same labels. The model imitates everything, including your inconsistencies.
  3. Cover the variety. If tickets can be angry, confused, or brief, show one of each flavor.
  4. Mind the edge cases. If everything in your examples is positive, the model may hesitate when reality gets grumpy. Show a tricky one.

The model copies your examples with flattering, terrifying loyalty. Typos, weird capitalization, an accidental emoji: all faithfully reproduced. Your examples are a contract; proofread them.

Checkpoint

Few-shot prompting means showing 2-3 consistent input-output examples so the model imitates the pattern; imitation beats interpretation.

📝 Quiz

Question 1 of 3

What is few-shot prompting?

Found this useful? Pass it on.