Explain in-context learning
Explain how a frozen model adapts to examples in its prompt, both mechanistically (induction-style attention circuits) and probabilistically (inferring the task). Predict when few-shot prompting helps and what it is sensitive to.
Builds on: Induction heads, In-context learning as implicit task inference
What the animation says
Learning with frozen weights
Show a base model three examples of a made-up format. Each line is a word, an arrow, then the same word in capitals between stars. Give it a fourth word, and it continues the pattern. Now compare the weights before and after. Identical. Not one number changed. So where did the learning happen?
The copying circuit
The answer: in the activations. Same weights, but a different prompt means a different computation. Attention lets the last position read every earlier token. Some heads, called induction heads, look for spots like the current one: right after an input and its arrow. Then they copy what followed there, the star-and-capitals format, into the query's residual stream. They match abstract patterns, not just exact tokens. Fox never appeared, but the slot did. Your turn. Tap an earlier spot that this head attends to.
Examples as evidence
Here's a second view of the same thing. A base model predicts how a document continues. So the examples are evidence about which task produced this document. Each candidate task starts with a prior. Each example multiplies in how well it fits that task. The answer averages over tasks, weighted by that belief. One view says how the computation runs. This one says what it achieves. Which prompt helps more: consistent format with one wrong label, or correct labels in a messy format?
What the two views predict
Consistent format wins. Task inference keys on format and label space, more than on every label being right. Copying circuits add their own biases. Labels that are frequent, or come last, get a boost. And examples that look like the query pull hardest. Few-shot helps most when the task is ambiguous. Once one task dominates, more examples add little. And it only locates skills the model already has, plus new specifics like an invented word's label. It can't create a skill.
Flipped labels: setup
Now a test. Sentiment examples with flipped labels: happy sentences marked negative, and the other way round. Hypothesis one, normal sentiment: prior one half. A flipped example looks like noise, likelihood point one. Hypothesis two, reversed sentiment: prior one in a thousand. But a flipped example fits it, likelihood point four. So the odds of reversed versus normal start at one to five hundred. Each flipped example multiplies them by four. After three flipped examples, which does the model follow?
The tipping point
After three: four times four times four is sixty-four. Sixty-four over five hundred is about point one three. Normal still wins. Keep adding flipped examples. After five: one thousand twenty-four over five hundred, about two. Now the flip wins. The weights never moved. Evidence simply piled up against a tiny prior. So a frozen model adapts by reading its prompt. Attention copies patterns, and the examples select a task it already knows. Watch format, label balance, order and similarity. Few-shot locates skills. It doesn't create them.
Mechanism and purpose
What the two views predict
ICL as a posterior over tasks
Flipped labels: when do they win?
Remember this
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses