Zero-Shot & Few-Shot Learning
Zero-shot and few-shot learning describe an AI model's ability to perform a new task with no examples at all, or with just a handful of examples given in the prompt, instead of requiring dedicated retraining.
Key takeaways
- Zero-shot learning means performing a task with no examples, relying on general knowledge from pretraining.
- Few-shot learning provides a small number of examples directly in the prompt to demonstrate the desired pattern.
- Neither approach requires retraining the model, unlike fine-tuning.
- Few-shot prompting generally improves accuracy over zero-shot for tasks with a specific format or style.
- Zero-shot and few-shot performance is typically weaker than a model fine-tuned specifically for the task.
What is zero-shot learning?
Zero-shot learning is when a model performs a task it was never explicitly trained or shown examples of, relying entirely on the general knowledge and patterns it picked up during pretraining. Asking a language model to classify a movie review as positive or negative without giving it any labeled examples first is a zero-shot request.
What is few-shot learning?
Few-shot learning gives the model a small number of example input-output pairs directly in the prompt before asking it to handle a new case. Instead of retraining the model, these examples act as an on-the-fly demonstration of the pattern it should follow, which often improves accuracy and consistency compared to a zero-shot request, especially for tasks with a specific format or style.
Why zero-shot and few-shot matter
Before large language models, teaching a system a new task usually meant collecting a labeled dataset and training or fine-tuning a model on it. Zero-shot and few-shot capability means a general-purpose model can often handle a new task immediately, just by describing it or showing a couple of examples in the prompt, which is a large part of why modern LLMs feel so flexible.
Limits of zero-shot and few-shot learning
Zero-shot and few-shot performance is generally weaker than a model specifically fine-tuned for a task, especially for narrow, high-precision, or unusual domains. For tasks that need consistent, reliable behavior at scale, teams often start with few-shot prompting and move to fine-tuning once they understand the task well enough to justify the extra investment.
Frequently asked
- What is the difference between zero-shot and few-shot learning?
- Zero-shot learning asks a model to perform a task with no examples at all; few-shot learning provides a handful of examples in the prompt to demonstrate the pattern first.
- Is few-shot learning the same as fine-tuning?
- No. Few-shot learning gives examples within a single prompt without changing the model; fine-tuning permanently adjusts the model's weights using a training dataset.
- Why would you use few-shot instead of zero-shot?
- Few-shot prompting tends to produce more accurate and consistently formatted results, especially for tasks with a specific style or structure the model needs to match.