What is in-context learning?
In-context learning is a language model's ability to pick up a task from instructions and examples placed in the prompt, without any change to the model's weights.
Also called: ICL, prompt-based learning
How it works
When a prompt includes a description of a task and perhaps a few solved examples, a large model can often continue the pattern on new inputs. Nothing is saved: the model learns only for the length of that request, and the lesson is gone when the request ends.
This is the basis of few-shot prompting and zero-shot learning. How well it works depends on the model's size, the clarity of the instructions and how well the examples match real inputs.
Why it matters for risk work
In-context learning makes it fast to try new tasks. A fraud analyst can paste three examples of a new scam message and ask the model to label a batch of fresh ones, all without a training pipeline. When the scam changes, the examples can be updated the same day.
The trade-off is consistency. Results can shift with small changes to wording or example order, so a prompt that works well in a demo needs testing on a real labeled set before it is trusted in production.
Security points
The same ability that lets a model learn from your examples lets it learn from an attacker's. Text placed in the context by a user, a web page or a document can steer the model. This is why prompt injection works, and why untrusted text should be kept apart from instructions.
Example
A hypothetical trust and safety team sees a new style of fake refund request. A reviewer adds four confirmed examples to the prompt of an existing classifier. The next morning's queue is sorted with the new pattern in mind, and the team later moves the examples into a proper training set.
Related terms
- Few-shot promptingFew-shot prompting is a way of guiding a language model by including a small number of worked examples of the task in the prompt, before the new input it should handle.
- Zero-shot learningZero-shot learning is when a model performs a task it was given only instructions for, with no examples of that task in the prompt or in task-specific training.
- Prompt engineeringPrompt engineering is the practice of writing and testing the instructions, context and examples given to an AI model so that it produces accurate, useful and consistent output.
- Prompt injectionPrompt injection is an attack in which text given to an AI model contains instructions that override what its developer or user intended, so the model leaks data or takes unwanted actions.
- Context windowA context window is the maximum amount of text, measured in tokens, that a language model can take in and consider at once, including the prompt, any attached data and its own reply.