Mindket

Few-shot prompting: how many examples, in what format and order

A black banner titled "Advanced prompting" over the line "Examples, reasoning, chains and templates".

Few-shot prompting puts a handful of example inputs and outputs in the prompt, so the model copies their pattern without any fine-tuning. OpenAI calls it few-shot learning and Anthropic calls it multishot prompting. Use it when instructions alone leave the format, tone or labels open. On a reasoning model, try zero examples first, then add three to five varied ones in tags.

In this lesson

  • Write the instruction first and add examples only where replies keep drifting from it.
  • Choose examples that differ from one another and look like the inputs your app will send.
  • Give every example its own tag, and make the rules and the examples say the same thing.
  • Shuffle the order and spread the labels before you trust a prompt that scored well once.
  • Put sample calls on any tool whose nested parameters come back malformed.
All courses
On this page
  1. Before you start
  2. Change the tone of a reply with one example
  3. Give the examples their own section and tags
  4. How many examples to add
  5. What the model takes from your examples
  6. Sample calls inside a tool definition
  7. anton and Alex Albert on few-shot examples and prompt caching
  8. Common mistakes
  9. Try it yourself
  10. Check yourself
  11. Frequently asked questions
  12. Sources

Before you start

A shot is one worked example inside the prompt: an input and the output you want for it. Zero-shot means the prompt holds instructions only. One-shot adds a single example, and few-shot adds a handful.

You need a chat app for the first exercise and an API key for the developer message after it. The lesson assumes you already write clear instructions, the subject of the prompt engineering basics lesson. Examples sit on top of instructions. They never replace them.

Change the tone of a reply with one example

Chapter 7 of Anthropic's interactive prompting tutorial builds a "parent bot" that answers questions from children. Asked plainly whether Santa will bring presents, Claude answers in a formal voice that the tutorial calls robotic. You could spend a paragraph describing the warmth you want. The tutorial adds one question and answer instead. The whole prompt fits in four lines.

Please complete the conversation by writing the next line, speaking as "A".
Q: Is the tooth fairy real?
A: Of course, sweetie. Wrap up your tooth and put it under your pillow tonight. There might be something waiting for you in the morning.
Q: Will Santa bring me presents on Christmas?
  1. Open a new chat and send only the last line: Will Santa bring me presents on Christmas?
  2. Open a second new chat and send the whole prompt above, copied from the tutorial.
  3. Put the two replies side by side. Compare the voice, the length and whether the second one speaks as "A".
  4. Add a second question and answer on another topic, such as a lost toy, and send the prompt again in a fresh chat.
  5. Keep the version whose replies you would ship, and write down which example changed what.

Give the examples their own section and tags

In an app, examples usually go in the developer message, the instructions your code sends ahead of the user's input. OpenAI's prompt engineering guide builds that message in labelled parts and shows a classifier for product reviews. Each sample review sits in a tag, and an id ties it to the label the model should return.

The guide says the model picks up the pattern from the examples and applies it to the next input, and it asks for a diverse range of inputs.

# Identity

You are a helpful assistant that labels short product reviews as
Positive, Negative, or Neutral.

# Instructions

* Only output a single word in your response with no additional formatting
  or commentary.
* Your response should only be one of the words "Positive", "Negative", or
  "Neutral" depending on the sentiment of the product review you are given.

# Examples

<product_review id="example-1">
I absolutely love this headphones — sound quality is amazing!
</product_review>

<assistant_response id="example-1">
Positive
</assistant_response>

<product_review id="example-2">
Battery life is okay, but the ear pads feel cheap.
</product_review>

<assistant_response id="example-2">
Neutral
</assistant_response>

<product_review id="example-3">
Terrible customer service, I'll never buy from them again.
</product_review>

<assistant_response id="example-3">
Negative
</assistant_response>
  • Tags mark where each sample starts and ends, so the model can tell a sample review from the review it has to label.
  • The three samples cover all three labels, so the model sees every answer it may give.
  • The rules say what the samples show: one word, nothing else. OpenAI's GPT-4.1 prompting guide asks for exactly this, so that any behavior your examples demonstrate is also written in your rules.
  • Anthropic's applied prompting course wraps each sample in an example tag and puts them all inside one examples tag. Either scheme works. Pick one and keep it across the prompt.

How many examples to add

Anthropic's course says there is no hard rule. It suggests starting with at least three to five examples, then adding targeted ones where replies still miss, and notes that a single example beats none. Every example costs input tokens on every call. When the same block of examples goes out again and again, prompt caching lets the API read it from the cache.

Reasoning models change the starting point. OpenAI's reasoning best practices say they often need no examples, so write the prompt without them first. Add a few only for complex output requirements, and make them match the instructions closely, since a mismatch between the two can produce poor results.

The term goes back to GPT-3. Its 2020 paper, Language Models are Few-Shot Learners, gave the 175-billion-parameter model its demonstrations purely as text, with no gradient updates or fine-tuning. On some tasks that was enough to compete with the best fine-tuned systems of the time.

From OpenAI's reasoning best practices, Anthropic's applied prompting course and Anthropic's advanced tool use post, read on 6 November 2026.
Your caseStart withWhy
A reasoning model on an open taskNo examplesOpenAI says these models often do well without them
A fixed label set or a strict output formatThree to five examplesSamples show the format faster than a description does
A tone that is hard to describeOne or two examplesAnthropic calls one or two samples more efficient than describing every nuance
A tool with nested optional parametersSample calls in the tool definitionA schema cannot show which fields belong together

What the model takes from your examples

Right answers matter less than most people expect. In a 2022 study, Rethinking the Role of Demonstrations, randomly replacing the labels in the examples barely hurt classification and multiple-choice results across 12 models, GPT-3 among them. What drove the results was the rest: the set of possible labels, the kind of input text and the overall format.

Order moved results as well. A study of prompt order on GPT-3 and other models of its time found that the same examples in a different order could make the difference between near state-of-the-art and random-guess performance. An order that worked for one model did not carry over to another. A 2021 calibration paper traced part of that swing to bias, with models such as GPT-3 leaning toward answers placed near the end of the prompt.

All three studies ran in 2021 and 2022, on the models of that time, not the ones you call today. The habits they point to cost little. Vary the examples, spread the labels, and avoid closing the example block on the label you see most. Before you trust a prompt, run it a few times with the examples shuffled.

Sample calls inside a tool definition

Tool calls have the same problem. A JSON Schema says which fields are valid but not how to use them together, such as the date format an API expects or which optional fields come with a critical bug. Anthropic's advanced tool use post puts sample calls in the tool definition itself, in an input_examples field. From three samples, the post says, Claude learned the date and ID formats, how to nest a contact object, and which optional fields go together.

The Claude tool use lesson covers the field and what each sample costs in tokens. The post lists where samples help less: a tool with one obvious parameter, and standard formats such as URLs or email addresses.

Accuracy on complex parameter handlingAnthropic's internal testing, published 24 November 2025. The post does not name the model. The gold bar adds tool use examples.
  • Without tool use examples72%
  • With tool use examples90%

Source: Anthropic: Introducing advanced tool use (read November 6, 2026)

anton and Alex Albert on few-shot examples and prompt caching

Anton, who posts as @abacaj, wrote on X on 6 August 2024 that few-shot prompting is "S tier" for improving the performance of frontier models. The post breaks off at "The return on increasing the number of demonstrations past 10 is", where X cuts it with Show more, so what he says happens past ten is not readable here.

Nine days later, Alex Albert of Anthropic started a thread on X about prompt caching, which had launched in the Anthropic API the day before. His post says caching significantly reduces API input costs and latency. What excited him most was that caching makes "mega few-shot prompting" a lightweight alternative to fine-tuning.

Both posts are more than two years old, and both vendors' current guides still recommend examples. For your own prompt, start with the three to five examples Anthropic's course suggests. Add more only when a test set shows they help, and cache the example block once it grows.

here’s how to solve this task, here’s a few demonstrations showing you how to solve it.

anton (@abacaj) · X (read November 6, 2026)
anton (@abacaj) on X, 6 August 2024, ranking few-shot prompting near the top of what works on frontier models: say how to solve the task, then show a few demonstrations.
anton on X, 6 August 2024
Alex Albert (@alexalbert__) on X, 15 August 2024: Yesterday we launched prompt caching in the Anthropic API which significantly reduces API input costs and latency. He adds that it makes mega few-shot prompting a lightweight alternative to finetuning.
Alex Albert on X, 15 August 2024
Four of Anthropic's prompt engineering experts, Amanda Askell, Alex Albert, David Hershey and Zack Witten, on refining prompts and how prompting has changed, on Anthropic's own channel.

Screenshots of X's own embeds of the posts, taken on 6 November 2026, with the time in UTC. X cuts the first post short with Show more. Select a screenshot to open the post on X.

Common mistakes

  • Pasting five near-identical examples, so the model learns their shared quirks instead of the task.
  • Letting an example break a rule, such as a two-sentence sample under a one-sentence limit.
  • Mixing samples into the real input without tags, so the model answers a sample.
  • Closing every example block on the same label, then reading the skew as the model's judgment.
  • Adding examples to a reasoning model before trying the prompt without them.
  • Judging a prompt on one run in one example order.

Try it yourself

Each exercise changes one thing in the review classifier, so you can see what that one thing does. When the classifier behaves, the next lesson has the model write out its reasoning before the answer.

  • Add a fourth review that mixes praise and complaint, and send it to the classifier. Which label comes back?
  • Swap the order of the three samples and send the same review again. Did the label change?
  • Delete the Examples section, keep the rules, and compare the labels on five reviews of your own.
  • Write an input_examples entry for a tool you use: one call with every field and one with only the required ones.

Check yourself

  1. A 2022 study swapped the labels in few-shot examples for random ones. What happened to the results?

    Show answer

    B. They barely changed across 12 models The study found that the label set, the kind of input and the format drove results more than whether each label was right.

  2. You are prompting a reasoning model for a new task. What should you try first?

    Show answer

    C. A prompt with no examples OpenAI's reasoning best practices say these models often need no examples, so add a few only if the prompt alone falls short.

  3. Why does OpenAI's review classifier put each sample in its own tags?

    Show answer

    A. So the model can tell a sample from the review it must label Tags mark where each sample starts and ends, and the ids pair each sample review with its label.

  4. A tool with nested optional fields keeps getting malformed calls. What does Anthropic suggest?

    Show answer

    D. Add sample calls in input_examples A schema says which fields are valid, and sample calls show the formats and which fields go together.

Frequently asked questions

What is few-shot prompting?

It means teaching a task by demonstration inside the prompt itself. Researchers call the effect in-context learning, since the model adapts to the task while its weights stay untouched.

What is the difference between zero-shot and few-shot prompting?

Zero-shot gives only instructions, and few-shot adds examples. Zero-shot is cheaper and often enough on reasoning models. Few-shot pins down a format, a label set or a tone that words describe poorly.

Is few-shot prompting a kind of fine-tuning?

No. Fine-tuning changes the model's weights with training data. Examples live only in the prompt, so they cost input tokens on every call and stop working the moment you remove them. OpenAI's guide presents examples as the way to steer a model without fine-tuning.

Where do examples go in an API request?

OpenAI's guide puts them in the developer message, after the identity and the instructions. Anthropic's course puts them in the user turn inside an examples tag. Either way, keep a stable example block near the start so caching can reuse it. The system prompt lesson covers what else belongs up there.

Can I show the model an example of what not to do?

Yes. Anthropic's tutorial counts examples of how you do not want the model to behave among useful examples. Put each bad sample in its own tag and say what is wrong with it, so the model does not copy it.

Sources

  1. OpenAI Docs: Prompt engineering, Few-shot learning (read November 6, 2026)https://developers.openai.com/api/docs/guides/prompt-engineering
  2. OpenAI Docs: Reasoning best practices (read November 6, 2026)https://developers.openai.com/api/docs/guides/reasoning-best-practices
  3. OpenAI Cookbook: GPT-4.1 Prompting Guide (read November 6, 2026)https://developers.openai.com/cookbook/examples/gpt4-1_prompting_guide
  4. Anthropic on GitHub: Prompt engineering interactive tutorial, chapter 7, Using Examples (read November 6, 2026)https://github.com/anthropics/prompt-eng-interactive-tutorial/blob/master/Anthropic%201P/07_Using_Examples_Few-Shot_Prompting.ipynb
  5. Anthropic on GitHub: Applied prompting course, lesson 1, Essential prompting techniques (read November 6, 2026)https://github.com/anthropics/courses/blob/master/real_world_prompting/01_prompting_recap.ipynb
  6. Anthropic: Introducing advanced tool use (read November 6, 2026)https://www.anthropic.com/research/advanced-tool-use
  7. Hugging Face Papers: Language Models are Few-Shot Learners (2020) (read November 6, 2026)https://huggingface.co/papers/2005.14165
  8. Hugging Face Papers: Rethinking the Role of Demonstrations (2022) (read November 6, 2026)https://huggingface.co/papers/2202.12837
  9. Hugging Face Papers: Fantastically Ordered Prompts and Where to Find Them (2022) (read November 6, 2026)https://huggingface.co/papers/2104.08786
  10. Hugging Face Papers: Calibrate Before Use (2021) (read November 6, 2026)https://huggingface.co/papers/2102.09690
  11. X: anton (@abacaj) on few-shot prompting working well on frontier models (read November 6, 2026)https://x.com/abacaj/status/1820907327001678254
  12. X: Alex Albert on prompt caching and mega few-shot prompting (read November 6, 2026)https://x.com/alexalbert__/status/1824136128850723084
  13. YouTube: Anthropic, AI prompt engineering: A deep dive (read November 6, 2026)https://www.youtube.com/watch?v=T9aRN5JkmL8

Share this lesson

Reuse prompts that already work

A skill packs instructions and files, such as worked examples, into a folder that an AI agent loads when a task needs it. Browse the skills on Mindket.

Browse skills

This lesson as Markdown · Advanced prompt engineering: examples, reasoning, chains and templates · All courses