Few-shot prompting means putting a handful of worked examples, each an input with the answer you want, into the prompt so the model copies the pattern. A prompt with no examples is zero-shot. OpenAI, Anthropic and Google all document the technique, and they agree on most of the rules: keep examples relevant, vary them, and format them the same way.
Below are the vendors’ own definitions, a documented before-and-after example from Google, and templates you can paste into ChatGPT, Claude or Gemini.
On this page
What the vendors say few-shot prompting does
- OpenAI: “Few-shot learning lets you steer a large language model toward a new task by including a handful of input/output examples in the prompt, rather than fine-tuning the model.” The model “implicitly ‘picks up’ the pattern,” according to its prompt engineering guide.
- Anthropic: “Examples are one of the most reliable ways to steer Claude’s output format, tone, and structure,” from its prompting best practices. Anthropic also calls it multishot prompting.
- Google: “Few-shot prompts are often used to regulate the formatting, phrasing, scoping, or general patterning of model responses,” in its prompt design strategies. Google goes further than the others: “We recommend to always include few-shot examples in your prompts.”
So the main use is control over the shape of the answer: a label from a fixed set, a length, a tone, a layout.
Zero-shot vs few-shot: Google’s example
Google shows the difference with one question. The zero-shot version:
Please choose the best explanation to the question:
Question: How is snow formed?
Explanation1: Snow is formed when water vapor in the air freezes into ice
crystals in the atmosphere, which can combine and grow into snowflakes as they
fall through the atmosphere and accumulate on the ground.
Explanation2: Water vapor freezes into ice crystals forming snow.
Answer:
Google reports that the model picked Explanation1, the longer one. The few-shot version adds two solved examples first:
Below are some examples showing a question, explanation, and answer format:
Question: Why is the sky blue?
Explanation1: The sky appears blue because of Rayleigh scattering, which causes
shorter blue wavelengths of light to be scattered more easily than longer red
wavelengths, making the sky look blue.
Explanation2: Due to Rayleigh scattering effect.
Answer: Explanation2
Question: What is the cause of earthquakes?
Explanation1: Sudden release of energy in the Earth's crust.
Explanation2: Earthquakes happen when tectonic plates suddenly slip or break
apart, causing a release of energy that creates seismic waves that can shake the
ground and cause damage.
Answer: Explanation1
Now, Answer the following question given the example formats above:
Question: How is snow formed?
Explanation1: Snow is formed when water vapor in the air freezes into ice
crystals in the atmosphere, which can combine and grow into snowflakes as they
fall through the atmosphere and accumulate on the ground.
Explanation2: Water vapor freezes into ice crystals forming snow.
Answer:
With these examples, Google says, the model chose the shorter Explanation2. Notice that the prompt never says “prefer short answers”. In both examples the shorter explanation wins, and the model infers the rule. Google adds that “you can remove instructions from your prompt if your examples are clear enough in showing the task at hand.”
How many examples to use
- Anthropic: “Include 3–5 examples for best results.”
- Google: models “can often pick up on patterns using a few examples,” but “if you include too many examples, the model may start to overfit the response to the examples.”
- OpenAI: “try to show a diverse range of possible inputs with the desired outputs.”
Start with three. Add one when the model gets a specific kind of input wrong, and make the new example that kind of input.
Format the examples the same way
Google’s rule: “ensure a consistent format across all examples, especially paying attention to XML tags, white spaces, newlines, and example splitters.” If one example ends with a period and the others do not, expect mixed output.
Anthropic suggests wrapping examples in tags so they are not mistaken for instructions: “Wrap examples in <example> tags (multiple examples in <examples> tags).” It also asks for examples that are “Relevant”, mirroring your real use case, and “Diverse”, covering edge cases so the model does not “pick up unintended patterns.”
A template that follows all three vendors’ advice:
Classify each support message as Billing, Bug or Feature request. Reply with the label only.
<examples>
<example>
<message>I was charged twice this month.</message>
<label>Billing</label>
</example>
<example>
<message>The export button does nothing on Safari.</message>
<label>Bug</label>
</example>
<example>
<message>Could you add a dark mode?</message>
<label>Feature request</label>
</example>
</examples>
<message>[paste the new message here]</message>
Each label appears once, the inputs differ in wording and length, and every example has the same two tags in the same order. OpenAI’s version of the same idea, a review classifier with Positive, Negative and Neutral, is quoted in full in our system prompt examples.
Few-shot examples for writing tasks
Examples also fix tone and length in ordinary chat use. Paste two short samples of your own writing and ask for a third in the same style:
Here are two product updates I wrote for our newsletter:
<example>[your first update]</example>
<example>[your second update]</example>
Write a third update in the same length, tone and structure about: [topic]
Use your own texts, not someone else’s published work. Anthropic adds that you can “ask Claude to evaluate your examples for relevance and diversity, or to generate additional ones based on your initial set.”
Few-shot prompts with reasoning models
Anthropic notes that “Multishot examples work with thinking.” Worked examples shape how Claude approaches similar problems in its thinking. Its advice for this case: “Present each example as a problem, the method to apply, and the expected answer.” For a maths or logic task, show the method in each example, not only the final number.
Where to put the examples
- ChatGPT and other OpenAI models: OpenAI says that “typically, you will provide examples as part of a
developermessage.” In the ChatGPT app, project instructions or custom instructions play that role; see what a system prompt is. - Claude: in the system prompt or at the top of the message, inside
<examples>tags. - Gemini: Google notes that “the order of the content in the prompt can sometimes affect the response” and suggests trying examples, context and input in different orders.
Every example is resent with each request and counts as input. To see what a block of examples costs, paste it into our token counter.





