In-context learning
An LLM's ability to learn a new task at inference time by reading examples in the prompt — no weight updates, just pattern-matching from context.
In-context learning (ICL) is the property that made LLMs practically useful. Show the model 3–5 examples of the task in the prompt; it generalizes the pattern and applies it to a new input. No fine-tuning. No labeled dataset. Just examples in the prompt.
For agents, ICL is the everyday tool. System prompts include example tool calls. Few-shot retrieval injects similar past cases into context for each new query. RAG is in-context learning applied to retrieved documents.
The 2026 frontier: extending ICL to thousands of examples via long-context models. With 1M-token windows, you can fit hundreds of examples and approach fine-tune-level performance on narrow tasks — for the cost of a single prompt and no training infrastructure.
Frequently asked
Is in-context learning real learning?+
Not in the weight-update sense — the model is not retrained. But functionally it behaves like learning: performance on a new task improves after seeing examples. Researchers debate whether it deserves the "learning" label; practitioners just use it.
How many examples do I need in the prompt?+
For pattern-matching tasks, 3–5 well-chosen examples usually beats 20 random ones. Add more only when the task has high variance. Past ~20 examples, returns diminish unless your domain is unusually diverse.