Skip to content

Few-Shot Prompting Explained (With Examples You Can Copy)

Few-shot prompting means showing AI a few examples of what you want before asking. Learn when it helps, how many examples to use, and copy-ready templates.

By Orgwyse Published Last updated 5 min read

On this page
  1. Zero-shot, one-shot and few-shot
  2. When few-shot prompting helps most
  3. How to write good examples
  4. Template 1: Classify with your own labels
  5. Template 2: Match a format
  6. Template 3: Copy a voice
  7. How many examples?
  8. Save your best few-shot prompts
  9. FAQ

Few-shot prompting means including a few examples of the input and the output you want in your prompt, so the AI copies the pattern instead of guessing it. Zero-shot is asking with no examples, one-shot is one example, and few-shot is several. It's one of the most reliable ways to control format, tone and labels in ChatGPT or Claude, and Anthropic suggests three to five well-chosen examples for best results.

Zero-shot, one-shot and few-shot

The 2020 research paper that introduced GPT-3 set out three settings that are still used today: zero-shot, where the model gets only a natural-language instruction; one-shot, with a single demonstration; and few-shot, with several demonstrations in the prompt and no retraining of the model (Brown et al., "Language Models are Few-Shot Learners").

StyleWhat you give the AIExample
Zero-shotOnly the instruction"Label this review as Positive, Negative or Neutral."
One-shotInstruction plus one exampleThe instruction, one labeled review, then the new review
Few-shotInstruction plus several examplesThe instruction, three to five labeled reviews, then the new one

OpenAI describes few-shot learning as a way to steer a model toward a new task "by including a handful of input/output examples in the prompt, rather than fine-tuning the model." The model picks up the pattern and applies it (OpenAI: Prompt engineering guide).

When few-shot prompting helps most

Examples are worth adding when the result has to match something specific:

  • A fixed format. Product descriptions with the same structure, JSON with the same fields, a table with set columns.
  • A consistent label set. Sorting feedback, tickets or transactions into your categories.
  • A voice or style. Social posts, replies to customers or emails that sound like you.
  • Tricky judgment calls. Showing where the line is between two categories is often clearer than describing it.

Anthropic calls examples "one of the most reliable ways to steer Claude's output format, tone, and structure," and says a few well-crafted ones improve accuracy and consistency (Claude prompting best practices).

For a simple, open-ended question, you usually don't need examples. A clear instruction is enough. See how to write a good prompt for that side of things.

How to write good examples

Anthropic's guidance is to make examples (Claude prompting best practices):

  • Relevant: close to your real task.
  • Diverse: covering edge cases, and varied enough that the model doesn't pick up a pattern you didn't intend.
  • Clearly marked: wrapped in tags like <example> so the AI can tell examples apart from instructions.

OpenAI's guide gives similar advice: show a diverse range of possible inputs with the desired outputs (OpenAI).

A few more practical rules:

  • Use real examples where you can. Made-up ones tend to be cleaner than real inputs, so the AI isn't ready for the mess.
  • Vary the things that should vary. If all your examples are short, you'll get short answers. If every example starts with "Great question," so will the output.
  • Keep the format identical. Same labels, same order, same punctuation in every example.
  • Include a hard case. One example that sits near the boundary between two answers teaches more than three obvious ones.
  • Put the instruction first, then the examples, then the new input.

Template 1: Classify with your own labels

Prompt
Sort each customer message into one category: Billing, Bug, Feature request, or Other. Reply with the category only.

<examples>
<example>
Message: I was charged twice this month.
Category: Billing
</example>
<example>
Message: The export button does nothing when I click it.
Category: Bug
</example>
<example>
Message: Could you add a dark mode?
Category: Feature request
</example>
<example>
Message: My card expired and now the app shows an error on the settings page.
Category: Billing
</example>
</examples>

Message: [new message]
Category:

The fourth example is the hard case: it mentions an error, but the real issue is billing. That shows the AI where the line is.

Template 2: Match a format

Prompt
Write a product description in the same structure as the examples: a one-line hook, three bullet points of benefits, and a one-line note on who it's for.

<example>
Product: Steel water bottle, 750 ml
Description:
Cold for 24 hours, even in a hot car.
- Double-wall steel keeps drinks cold or hot
- Leak-proof lid fits in any bag
- Dishwasher-safe body
Best for: commuters and gym bags.
</example>

<example>
Product: Linen notebook, A5
Description:
A notebook that lies flat and stays that way.
- Stitched binding opens fully flat
- Thick paper with no bleed-through
- Linen cover that wears in, not out
Best for: daily journaling and sketching.
</example>

Product: [your product]
Description:

Template 3: Copy a voice

Prompt
Here are three posts I've written. Write a new post about [topic] in the same voice: same sentence length, same level of formality, same way of opening and closing. Don't copy phrases from the examples.

<example>[post 1]</example>
<example>[post 2]</example>
<example>[post 3]</example>

The line "Don't copy phrases from the examples" matters. Without it, AI tends to reuse distinctive lines from your samples.

How many examples?

Anthropic recommends three to five for best results (Claude prompting best practices). Start with three. Add one when the AI gets a specific kind of input wrong, and make the new example exactly that kind of input.

More isn't always better. Every example uses part of the AI's context window, and a pile of near-identical examples can make output repetitive. Anthropic also suggests you can ask Claude to check your examples for relevance and diversity, or to generate more from your starting set.

Save your best few-shot prompts

A good few-shot prompt takes some effort to build, so keep it. Save it as a reusable template (see how to use prompt templates), or put the examples into project or custom instructions so they apply every time. In a system prompt, OpenAI suggests an "Examples" section after the identity and instructions (OpenAI); see how to write a system prompt for the full structure.

FAQ

What is few-shot prompting in simple terms?

It's showing the AI a few examples of what you want before you ask it to do the real task. The AI follows the pattern in your examples.

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

Zero-shot gives the AI only an instruction. Few-shot adds several worked examples. Few-shot usually gives more consistent results when the format, labels or style matter.

How many examples should a few-shot prompt have?

Start with three. Anthropic suggests three to five for best results. Add more only when a specific type of input keeps going wrong.

Is few-shot prompting the same as fine-tuning?

No. Fine-tuning retrains a model on many examples and changes the model itself. Few-shot prompting puts a handful of examples in the prompt and changes nothing about the model.

Can examples make the output worse?

Yes, if they're too similar or have a pattern you didn't mean, like all being the same length. The AI will copy that too. Vary your examples and include one hard case.

Last updated 9 November 2026 · Spotted something out of date? [email protected]