Few-shot demonstrations of compliance labeling
AI Models & Assistants / Knowledge library
In-Context Learning (ICL)
In context learning from prompt examples without updating weights
Why learn In-Context Learning (ICL)?
Useful for adapting a prompt to a format or task without training new weights. Results depend on the examples and context available for that request.
The problem it solves
Adapts model behavior using task information in the current context without updating model parameters.
Where it came from
In-context learning is a model's use of examples or patterns in its current context to perform a task. Large language-model research demonstrated few-shot behavior with demonstrations supplied in the prompt and no task-specific gradient updates. Research on induction heads investigates mechanisms that may contribute to this behavior.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Create three demonstrations of a custom text-labeling convention.
- Test new inputs with and without those demonstrations.
- Compare two demonstration orders while keeping test inputs fixed.
- Remove the demonstrations in a fresh context and compare behavior.
- Explain which state changes in prompting versus gradient-based fine-tuning.
Documentation and sources
- Language Models are Few-Shot Learners (arxiv.org)
- In-context learning and induction-head research (arxiv.org)
Connect the ideas
Explore next
Real World Example
Dynamic Regulatory Compliance Labeling
Legal and compliance departments in multinational corporations.
The business problem
The high cost and latency associated with fine-tuning machine learning models every time a new regional regulatory policy is introduced, which requires thousands of labeled examples and gradient updates.
How this topic solves it
In-Context Learning (ICL) allows the organization to adapt models to new regulatory formats instantly by providing a few representative examples of the desired output directly within the prompt, bypassing the need for weight updates.
- Identify a set of high-quality, representative regulatory document snippets.
- Format these snippets into a prompt template that includes the input text and the expected classification or extraction result.
- Concatenate the few-shot examples with the new, unseen regulatory document to form the final input context.
- Submit the prompt to the language model to generate the compliant output without modifying the underlying model parameters.
This diagram illustrates how few-shot examples are combined with target data to guide the model.
Combines examples with target document
Processes context without weight updates
The final labeled regulatory result
- Regulatory Examples → injects → Prompt Assembler
- Prompt Assembler → sends context → Language Model
- Language Model → generates → Compliance Output
Expected business outcome
The organization achieves rapid adaptability to shifting regulatory landscapes without the operational overhead of retraining or fine-tuning cycles.
Limitations and checks
A primary limitation is the context window constraint; as more examples are added to improve accuracy, the prompt consumes more tokens, which can lead to performance degradation or truncation. This is checked by monitoring the token count against the model's maximum input capacity.