Repository of 3-5 labeled documents
AI Models & Assistants / Knowledge library
Few-Shot Learning
Adapting behavior or predictions from a small number of examples
Why learn Few-Shot Learning?
Few-shot methods can reduce labeling or retraining needs. Results are sensitive to example quality, coverage, order, and how closely evaluation matches the demonstrations.
Where it came from
Few-shot learning covers methods that generalize from very limited labeled data. In language-model usage, few-shot prompting usually means providing demonstrations in context without updating model weights.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Distinguish few-shot prompting: What changes during ordinary few-shot prompting of a deployed language model?
- Choose representative demonstrations: Which example set is most useful for a three-class support-ticket task?
- Test prompt sensitivity: Accuracy changes when the same demonstrations are reordered. What should you do?
- Prevent demonstration leakage: Why exclude test examples from the few-shot demonstrations?
- Separate adaptation mechanisms: Which experiment isolates the value of few-shot demonstrations?
Documentation and sources
- Language Models are Few-Shot Learners (arxiv.org)
Connect the ideas
Explore next
Real World Example
Automated Niche Legal Document Classification
Boutique law firms handling specialized, low-volume litigation.
The business problem
The firm encounters rare, highly specific legal document types that lack the thousands of labeled examples required for traditional supervised fine-tuning, leading to manual processing bottlenecks.
How this topic solves it
Few-shot learning allows the firm to adapt a pre-trained language model to recognize new document categories by providing only a handful of representative examples within the prompt, bypassing the need for extensive gradient-based training.
- Identify a set of 3-5 representative legal document examples for the new category.
- Construct a prompt template that includes these examples as context.
- Append the target document to the prompt without modifying model weights.
- Execute inference to classify the target document based on the provided pattern.
The process shows how context examples guide the model to classify a new document without weight updates.
Combines examples with target input
Large language model (frozen)
Predicted label for target document
- Example Store → Injects context → Prompt Constructor
- Prompt Constructor → Sends formatted prompt → Pre-trained Model
- Pre-trained Model → Generates prediction → Classification Output
Expected business outcome
The firm achieves rapid, on-the-fly classification of novel document types, significantly reducing manual review time for specialized cases.
Limitations and checks
The primary limitation is that few-shot performance is highly sensitive to the quality and diversity of the provided examples; if the examples are ambiguous or poorly selected, the model may hallucinate or misclassify. This can be checked by evaluating the model against a small, held-out validation set of known documents.