A transformer that has never seen "Ohm's Law" before can still complete "Ohm's Law states that V = I" correctly the second time the phrase appears in the same context — purely from having seen it once already. No weight update, no training example: just one forward pass finding the pattern's earlier occurrence and copying whatever followed it.
Switch sequences. Whenever the last token has appeared earlier, attention concentrates almost entirely on the position right after that earlier occurrence — and the predicted token is whatever sat there. When nothing in the sequence matches, there's no earlier occurrence to point to, and attention spreads out with no real preference.
An induction head is two attention heads working in sequence. A previous-token head first writes, into every position , a report about whatever token sat at . The induction head then reads the current (last) token as a query and compares it against every position's previous-token report, used as a key:
- — the current (last) token in the sequence, the one we're predicting a continuation for.
- — position 's previous-token report: the embedding of whatever token came right before it.
- — the query: the embedding of the current token.
- — the resulting attention weight on position , normalized to sum to 1 across all earlier positions.
- Match foundIf some earlier position's previous token equals the current token, there and 0 everywhere else — attention locks onto that position.
- No match anywhereEvery score is 0; normalizing 0/0 is undefined, so the head falls back to spreading weight uniformly instead.
- PredictionThe output copies the token actually sitting at — not , but itself, since that's what followed the matching earlier occurrence.
"A B C A B" and "C A B C A" both lock onto a single earlier position with weight 1.00 — a genuine repeated token gives an unambiguous match. "A B C" has no repeated token anywhere, so the best it can do is 0.50, split between two equally uninformed guesses.
Predicting the continuation of "A B C A B":
- Embed the tokensOne-hot in a 3-symbol vocabulary: A = [1,0,0], B = [0,1,0], C = [0,0,1].
- Build each position's previous-token report
- Score against the query
:
- Normalize and predict— all the weight lands on position 2. The token actually at position 2 is C, so the prediction is C.
Find the sequence, among the four, where the induction head is least confident in its prediction.
Two heads, chained: one reports "what came right before me," the other matches that report against the current token and copies whatever followed the match. Real induction heads (identified in small transformers by Olsson, Elhage, and collaborators at Anthropic) run on continuous embeddings and noisy matches instead of clean one-hot vectors, but the mechanism — match on the past, copy what followed — is the same circuit this chapter traced exactly.