in-context learning

In-context learning is the capability behind few-shot prompting, but as a research subject it's really about the mechanism inside the model that makes examples in a prompt change its behavior without a single weight ever being updated. Olsson and colleagues' 2022 Anthropic paper "In-context Learning and Induction Heads" traced this capability to specific attention heads that emerge during training, and found something genuinely surprising: in-context learning ability doesn't improve smoothly as training progresses — it jumps sharply at a specific point, a discontinuous "phase change" that coincides almost exactly with the moment induction heads first form inside the model, rather than gradually accumulating the way most training metrics do.

Scan the context for a repeated token
has this exact token appeared earlier in the sequence?
Find its earlier occurrence
locate the position where that same token showed up before
Copy whatever token followed it
if [A][B] appeared before, and [A] just appeared again...
Predict [B]
this copying mechanism is the induction head

The induction-head mechanism is concrete enough to trace through a toy example, and it's the literal copy-paste operation in-context learning rides on. Given the sequence "...cat, sat, down, the, cat..." a trained induction head notices that the token "cat" just reappeared, scans back to find the earlier occurrence of "cat," and predicts that whatever followed it last time — "sat" — is likely to follow again now; stack this same copying behavior across dozens of few-shot demonstration pairs, and the result looks exactly like the model "learning" a task pattern from examples, even though the underlying operation is closer to pattern-matching and copying than anything resembling gradient-based learning.

An Induction Head, Caught in the Act the same copying mechanism, whether the sequence is a toy example or a few-shot prompt ... cat sat down the cat ___ [A] [A] [B] "I've seen [A] before — it was followed by [B]" predict: "sat" Chain this exact copy-what-followed-last-time operation across a few-shot prompt's worked examples, and the model appears to "learn" the task's input-output mapping — without a single weight update, using only this copying circuit on the prompt itself. Olsson et al., 2022: this exact circuit's formation coincides with a sudden jump in ICL ability.

One of the most surprising experimental findings about in-context learning is that the labels in the demonstrations matter far less than their format does. Min and colleagues' 2022 paper "Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?" found that replacing the correct labels in few-shot examples with random, incorrect ones barely hurt performance on many classification tasks — what mattered far more was that the demonstrations had the right format, the right label space, and the right general structure, suggesting that a substantial part of what in-context learning does is show the model the shape of the task rather than teach it a specific correct mapping from each example. This finding complicates any simple story where more correct examples straightforwardly teach the model more about the task.

A separate, more theoretical research direction treats in-context learning as mathematically similar to a training step happening inside a single forward pass, rather than pattern copying. Garg and colleagues' 2022 paper showed transformers could learn to perform simple functions like linear regression purely from demonstration pairs given in context, and von Oswald and colleagues' 2022 and 2023 work argued that a transformer's forward pass through its layers can be constructed to implement something mathematically equivalent to one or more steps of gradient descent on the in-context examples — a genuinely different theoretical account from the induction-head copying story, and the two explanations are still an active area of disagreement rather than a settled matter.

In-context learning sits at an unusual point for a capability this consequential: the behavior is robustly observed and economically significant — it's the entire basis of prompting as a way to control models — while the mechanistic explanation for why it happens is still actively contested between the induction-head copying account and the implicit-gradient-descent account, and the Min et al. finding that even wrong labels barely hurt performance is a reminder that neither explanation is complete enough yet to predict every observed behavior.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account