Prompting
Few-shot Learning
Also known as: few-shot prompting, in-context examples
Giving a model a handful of worked examples inside the prompt so it grasps the task, without any extra training.
Few-shot means teaching an AI a task on the spot by showing it a few examples. Want it to sort feedback into "happy" or "unhappy"? Show two or three examples of each, and it catches on for the rest, no special training needed, just examples inside your request. It is the difference between telling someone "do it like this" with samples, versus explaining in the abstract.
Few-shot prompting includes a small number of example input-output pairs in the prompt so the model can infer the pattern and apply it to your new input. It contrasts with zero-shot (no examples) and relies on a capability called in-context learning.
When it helps
- The task has a specific format you want matched.
- Instructions alone are ambiguous, but examples make it obvious.
- You want a consistent style, label set or structure.
Tips
Use clear, representative and correctly-labelled examples; two to five is often enough. Order and formatting matter. For reasoning tasks, examples that include the working (chain-of-thought) help more than answer-only examples.
Few-shot learning in the LLM sense denotes in-context adaptation from k demonstrations placed in the prompt, with no gradient updates, a capability that emerged prominently with GPT-3 (Brown et al. 2020). It exploits the model's pretrained ability to infer a latent task from context and continue the pattern. Performance generally improves with more and better exemplars up to context limits, but is sensitive to example selection, ordering, label distribution and formatting; pathologies such as majority-label and recency biases are documented.
Distinguish it from the classical machine-learning meaning of few-shot (learning a new class from few labelled instances, e.g. metric-learning). In practice few-shot competes with zero-shot instruction-following, which has strengthened as instruction-tuned models improved, so few-shot is now most valuable for format control, niche tasks, and eliciting reasoning via worked exemplars. It consumes context-window budget, a real trade-off at scale.