ipIterPrompt
intermediateUpdated 2026-07-26

Few-Shot Prompting: Teach by Example

If you've ever struggled to describe exactly the output you want, few-shot prompting is the shortcut: instead of describing, you show. You give the AI a couple of example input-and-output pairs, then your real input — and it imitates the pattern.

Short answer

Few-shot prompting is including one or more worked examples of the output you want before your real request, so the AI imitates the pattern instead of guessing from a description.

Applies to:
Repetitive tasks where a consistent format or style matters.

Key takeaways

  • Show examples instead of describing the output in words.
  • One good example (one-shot) often works; two or three lock in the format.
  • Best for consistency: same shape, tone, or transformation every time.

How it works

Models are very good at pattern completion. When you provide examples of the transformation you want ('input like this becomes output like that'), the model infers the rule and applies it to your new input. Even a single strong example (one-shot) often works; two or three (few-shot) nail down format, tone, and edge cases.

When to use it

  • You need a consistent format across many items (e.g. product blurbs).
  • The output is hard to describe but easy to demonstrate.
  • A previous attempt was close but the shape kept drifting.

When it fails

  • Your examples are inconsistent with each other — the model copies the mess.
  • The examples are so long they crowd out the real input.
  • The task needs reasoning or facts, not pattern imitation.

Before and after

Turning features into benefits

Weaker prompt

Rewrite these product features as customer benefits: [list].

Stronger prompt

Rewrite each feature as a customer benefit. Example — Feature: '10-hour battery' → Benefit: 'Works all day without hunting for a charger.' Now do the same for: [list].

Why: The single example fixes the exact transformation and tone, so every item in the list comes back in the same benefit-focused shape.

How to adapt it

  • Use two or three short, consistent examples rather than one long one.
  • Make the examples representative, including a tricky case if there is one.
  • Label the parts clearly (Input: … Output: …) so the pattern is unambiguous.

Prompts that use this technique

Open any to read, copy, or run it in the playground.

Build a prompt library for your exact job

Describe what you do and IterPrompt organizes proven prompts into your real workflows — a personalized starting point in seconds.

Try a prompt for yourself

Open any prompt and run it in the IterPrompt playground.