ModelRefs / Few-Shot & Zero-Shot Learning — Tutorial
Few-Shot & Zero-Shot Learning — Tutorial
Prompt your way to a classifier without labelled data — in-context learning explained. Covers Zero-shot, one-shot, few-shot, When few-shot beats fine-tuning.
Overview
Prompt your way to a classifier without labelled data — in-context learning explained
Level: Intermediate. Estimated reading time: 25 minutes.
Zero-shot, one-shot, few-shot
In-context learning lets LLMs perform tasks from examples in the prompt — no gradient updates required.
Zero-shot: describe the task in natural language. "Classify the sentiment of this review as positive or negative: 'The food was cold and the service slow.'" The model answers directly from its pretraining knowledge.
One-shot: one labelled example in the prompt. "Positive: 'Great food!' | Negative: 'Terrible service.' | Classify: 'Average meal.'"
Few-shot: 2–20 examples. Performance generally improves with more examples, up to a point (context window limits and diminishing returns).
Chain-of-thought (CoT): add "Let's think step by step" or show examples with intermediate reasoning. This dramatically improves multi-step reasoning: arithmetic, logic puzzles, and math word problems.
When few-shot beats fine-tuning
Few-shot is faster to iterate: change the prompt in seconds vs hours of fine-tuning.
Few-shot is better when: the task changes frequently, you have very few examples (<50), or you need the model to follow complex multi-step instructions that are easier to describe than to demonstrate at scale.
Fine-tuning is better when: you have 1000+ consistent examples, latency matters (longer prompts = slower and more expensive), or the task requires a style/format not present in the base model's pretraining.
Retrieval-augmented prompting: instead of fixed few-shot examples, retrieve the most relevant examples from a database for each query. This dynamic selection dramatically improves few-shot accuracy on heterogeneous tasks.
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Few-Shot & Zero-Shot Learning — Tutorial.