⚡ Few-shot learning is the ability of an AI to learn a new task from only a handful of examples — typically 2 to 20 — rather than thousands. A large pretrained model sees your examples, recognises the pattern from its broad training, and applies it to new inputs without any retraining. You are already using few-shot learning every time you show Claude or GPT a few examples in a prompt.
Category: Machine Learning · Difficulty: Beginner · Last updated: 15 May 2026 · 4 min read
What is Few-shot learning?
Show a child one picture of a zebra and they can reliably identify zebras in new contexts — at different angles, in different lighting, drawn as cartoons. They generalise from one example because they already have a rich model of the world built from years of experience. They do not need 10,000 zebra photos.
Few-shot learning captures the same idea for AI. A model that has been pretrained on vast amounts of data has built a rich internal representation of patterns, relationships, and structures. When you show it 2-5 examples of a new task, it does not need to retrain — it uses its existing knowledge to recognise the pattern and apply it to new inputs immediately.
This is one of the most practically important capabilities of modern LLMs. You do not need a dataset of thousands of labelled examples. You do not need to fine-tune. You just show the model a few examples in your prompt.
THE SPECTRUM
Zero-shot: give the model only a task description, no examples.
“Classify this review as positive or negative: ‘The food was terrible.'”
Works when the task is familiar from pretraining.
One-shot: provide exactly one example.
“Positive: ‘Amazing service!’ | Negative: ‘The food was terrible.'”
One example removes ambiguity about the format and task.
Few-shot: provide 2–20 examples.
“Positive: ‘Amazing service!’ | Positive: ‘Would visit again!’ | Negative: ‘Never coming back.’ | Negative: ‘The food was terrible.'”
More examples clarify edge cases and improve consistency.
HOW TO USE IT IN PROMPTS
- Identify the pattern you want to teach — input X should produce output Y.
- Write 3-5 clear, diverse examples covering the range of inputs the model will see.
- Format them consistently — the model is sensitive to formatting cues.
- Place examples before the actual input you want the model to process.
- End with the new input and let the model complete the pattern.
Real-world examples
Not theory — what real teams actually shipped using this technique.
- A legal team uses few-shot prompting with 4 examples of contract clause rewrites (formal legal → plain English) to build a contract simplification tool — no fine-tuning, no dataset, deployed in an afternoon.
- A customer support team provides 5 examples of how their brand responds to complaints, then uses few-shot prompting to draft first-response emails — maintaining brand voice without training a custom model.
- Medical researchers use few-shot learning to extract structured data from clinical notes — providing 3 examples of note → structured output, then applying it to thousands of notes.
Common pitfalls
- Example quality matters more than quantity — 3 excellent, diverse examples outperform 20 poor or redundant ones. Each example should teach something the others do not.
- Order sensitivity — LLMs can be sensitive to the order of examples. If performance is inconsistent, try shuffling example order.
- Context window limits — many examples consume context window tokens. With very limited context, few-shot may conflict with leaving room for the actual task input.
- Not a replacement for fine-tuning at scale — few-shot works well for flexible tasks where occasional errors are acceptable. For high-volume, high-accuracy production systems, fine-tuning on labelled data produces more consistent results.
Frequently asked questions
QUESTION 1 What is few-shot learning in simple terms?
ANSWER 1 AI that learns a new task from just a few examples. Show a pretrained model 3 examples of the pattern you want and it applies it to new inputs — no retraining required.
QUESTION 2 What is the difference between zero-shot, one-shot, and few-shot?
ANSWER 2 Zero-shot: no examples — just a task description. One-shot: exactly one example. Few-shot: 2–20 examples. In all cases, no retraining — the model applies its pretrained knowledge.
QUESTION 3 How do you use few-shot learning in practice?
ANSWER 3 Provide 3-5 input-output examples in your prompt before the actual input you want processed. Format them consistently. The model recognises the pattern and continues it.
QUESTION 4 Why does few-shot learning work?
ANSWER 4 Large pretrained models have rich internal knowledge from vast training data. A few examples activate the relevant pattern from that knowledge without updating any model weights.
📬 Get one concept + one use case every Tuesday. Join the newsletter →