In plain words
Sometimes describing what you want is harder than showing it. Few-shot prompting is the showing approach: you paste two to five examples of input and the output you want, then add a new input and let the AI complete it.
The AI spots the pattern in your examples, the format, the length, the style, and continues it. No retraining happens. The examples only live inside that one prompt.
The names count the examples. Zero-shot means no examples, just an instruction. One-shot means one example. Few-shot means a handful. For simple tasks, zero-shot is often enough. For a particular format or house style, a few good examples usually beat a long description.
Everyday example
Teaching a new cashier the shorthand
On day one at a kirana store, the owner doesn't explain the billing shorthand. He just shows three old bills: "salt 1 kg" written as "SALT-1K", "atta 5 kg" as "ATTA-5K". Then he hands over a new order. The cashier copies the pattern. A few-shot prompt does the same: examples first, then the new case.
Where the example breaks: The cashier will remember the shorthand tomorrow. The AI forgets it as soon as the chat or request ends, unless the examples are sent again.
How it actually works
Few-shot prompting relies on what researchers call in-context learning: a model adapting to a task from text in its input, with no change to its parameters.
Examples go in the prompt
You write pairs such as
Input: ... Output: ..., then a final input with the output left blank. The model reads all of it as one block of text inside its context window.The model continues the pattern
Because it predicts what text most plausibly comes next (next-token prediction), the most likely continuation is an output shaped like your examples.
Nothing is learned permanently
Unlike fine-tuning, the model's weights never change. Remove the examples and the behaviour goes with them. That makes few-shot fast and cheap to try, but it costs space in every request.
Choosing good examples
Anthropic's guide suggests 3 to 5 examples that are relevant and varied. If every example happens to be short or positive, the model may assume that is required. Mark examples clearly, for instance with labels or tags.
- Popularised by
- "Language Models are Few-Shot Learners", the GPT-3 paper from OpenAI, May 2020
- Zero-shot, as the paper defines it
- No examples, "only given a natural language instruction describing the task"
- Model in that paper
- GPT-3, with 175 billion parameters, used "without any gradient updates or fine-tuning"
- Typical number
- The paper typically used 10 to 100 examples. Anthropic's guide for today's chat models suggests 3 to 5
Questions people ask
What is the difference between zero-shot and few-shot prompting?
Zero-shot gives the AI only an instruction, such as "classify this review as positive or negative". Few-shot adds a few solved examples before the new case. Few-shot helps most when the format or judgement is particular to you.
Is few-shot prompting the same as fine-tuning?
No. Few-shot examples sit in the prompt and are forgotten after the request. Fine-tuning trains the model on many examples and changes its parameters, so the behaviour sticks without examples in every prompt.
How many examples should a few-shot prompt have?
Usually a handful: Anthropic's guide suggests 3 to 5. More examples cost more text and time. Pick varied ones that cover tricky cases, and make sure they all follow exactly the format you want back.
What is a one-shot prompt?
A prompt with exactly one example. For instance, show one product description written in your house style, then ask for another in the same style. It is often enough to fix the format.