What is Few-Shot Learning?
Last updated May 2026Providing a few examples in your prompt to teach the AI the pattern you want.
Definition
Few-shot learning is a prompt engineering technique where you include a small number of example input-output pairs in your prompt before the actual task. This teaches the AI the pattern, format, or style you want without any model training. Zero-shot means no examples, one-shot means one example, and few-shot typically means 2-5 examples.
š” Example
Prompt: "Classify the sentiment: 'Great product!' ā Positive. 'Terrible service' ā Negative. 'It arrived on time' ā Neutral. Now classify: 'The quality exceeded my expectations' ā" The AI learns from the examples to respond "Positive."
Related concepts
The practice of crafting effective instructions to get better results from AI models.
Why this matters
Few-shot learning lets you teach AI tools new tasks by showing examples rather than writing complex instructions. It is the simplest way to get consistent, formatted output from any AI ā and it works with every major chatbot.
Real-world example
To get ChatGPT to extract data in a specific format, provide 2-3 examples first: "Input: John Smith, CEO ā Output: {name: John Smith, role: CEO}". After seeing the pattern, the model applies it consistently to new inputs. This works better than lengthy instructions.
See it in action
A prompting technique that asks AI to show its reasoning step by step.
Explore AI tools
Find tools that use few-shot learning in practice.
What is Few-Shot Learning?
Few-shot learning is a prompt engineering technique where you include a small number of example input-output pairs in your prompt before the actual task. This teaches the AI the pattern, format, or style you want without any model training. Zero-shot means no examples, one-shot means one example, and few-shot typically means 2-5 examples.
How does Few-Shot Learning work in practice?
Prompt: "Classify the sentiment: 'Great product!' ā Positive. 'Terrible service' ā Negative. 'It arrived on time' ā Neutral. Now classify: 'The quality exceeded my expectations' ā" The AI learns from the examples to respond "Positive."
How many examples should you provide in few-shot prompting?
Two to five examples typically work well for most tasks. More examples improve consistency but use more tokens and can hit context window limits. The key is choosing diverse, representative examples that clearly demonstrate the pattern you want the model to follow.
When should you use few-shot instead of zero-shot prompting?
Use few-shot when the model struggles with zero-shot instructions, when you need output in a very specific format, or when the task has nuances that are hard to describe in words. Zero-shot is simpler and cheaper, so try it first and switch to few-shot if results are inconsistent.
What makes a good few-shot example?
Good few-shot examples are clear, representative of the task variety, and consistent in format. Avoid examples that are too similar to each other or that contain edge cases. The examples should demonstrate the exact input-output pattern you expect from the model.