Plain-language explainer
In-context learning, explained
How can a model learn from examples in the prompt without being retrained?
Put three examples of a task in your prompt and the model performs the fourth in the same pattern, with zero weight changes. That is in-context learning. It works because pretraining relentlessly rewarded continuing patterns, so pattern-following became one of the model's strongest reflexes. The learning is real but rented: it exists only inside the current context window, and it vanishes the moment the conversation ends.
Last reviewed
Reading is the slow way. Start with a free lesson you can operate right now.
Start free: Predict the next word →Free, no code, no signup.
Then go deeper: In-context learning: teaching without training Locked
What people get wrong
- The model permanently learned from my examples. Next conversation, they are gone. Only the context carried them.
- Few-shot prompting is a form of training. No gradient, no weight change. It is pattern completion at inference time.
- More examples always help. They spend context tokens, and inconsistent examples teach the wrong pattern.
Where you see it in real products
- 'Here are three examples of our tone' system prompts run on this.
- Formula-by-example features in spreadsheets are the same reflex.
- Paste a writing sample and the model mimics it: in-context learning, live.
Common questions
- Does the model learn from my examples permanently?
- No. Nothing is written back to the weights. The examples shape the answer only while they are in the context window. Open a new conversation and the model is exactly as it was before.
- How many examples should I give?
- Usually a handful. The first one or two do most of the work by fixing the format, and returns fall off quickly after that while cost keeps rising. Consistency between your examples matters more than how many there are.
- Why do examples work at all?
- Pretraining is full of text where a pattern is established and then continued: lists, translations, question-and-answer pages. Continuing an established pattern is exactly what the model is good at, so a few examples are a way of writing the start of a pattern for it to finish.
Related explainers
More in How models are trained
One idea at a time, in your inbox
New lessons and explainers, written the way these pages are. Now and then, not daily, and never a sales sequence.
We email you a confirmation link first. Unsubscribe in one click, any time. Privacy.
Part of See How AI Works, a free interactive course, where you learn how modern AI works by operating it, not watching videos.