Visual walkthrough — Mechanistic interpretability
Before any symbol appears, here is the whole story in words:
We will earn every piece of notation. Let's start with what a token even is.
Step 1 — What the model is actually looking at
WHAT. A model reads text as a list of tokens — think of them as beads on a string, one bead per word-piece. We number the positions left to right. Position just means "the -th bead".
WHY. Every later idea — "attend back", "previous token", "the repeat" — is about positions on this string. If we don't fix what a position is, none of the arrows we draw later have a place to land.
PICTURE. The sentence cat dog mouse cat dog ? laid out as numbered beads. The last bead, position 6, is the one we must fill in. Notice cat dog appears twice — that repeat is the only clue the model has.

Step 2 — Each position carries a vector: the residual stream
WHAT. At every position the model holds not a word but a vector — a list of numbers, an arrow in a high-dimensional space. Call it : an arrow with coordinates living at position . Here is the model dimension — the fixed width of the residual stream that every position and every layer shares. As the model computes, layers add new arrows onto this one.
WHY. Attention heads don't move words around — they move these arrows. To watch an induction head work we must first see the thing it reads and writes: the residual stream, the running vector at each position.
PICTURE. Each bead now sits under a stack of arrows. The bottom arrow is the raw token embedding plus its position mark; each layer's contribution is stacked on top. The final arrow is the sum of everything below it.

Where does the very first arrow come from? Two ingredients, added together. First, a lookup: the embedding matrix (with the vocabulary size from Step 6) has one row per possible token; the row for token is that token's meaning-arrow, written . Second, a positional encoding : a fixed arrow that depends only on the slot number , marking where the token sits. We add them:
Step 3 — Attention: one position reading another
WHAT. An attention head lets position pull information from earlier positions . It assigns each pair a weight between 0 and 1 — "how much does slot listen to slot ?" — and these weights across all allowed add to 1.
WHY. Nothing else in a transformer moves information between positions. If the answer at position 6 depends on what happened at position 3, an attention head is the only path. So the induction algorithm must be a story about which light up.
A crucial rule — you may only look backward. Because the model predicts the next token, position is forbidden from peeking at any position (that would be reading the future it is trying to guess). This is the causal mask: before the softmax, every score with is set to , so its weight becomes exactly . Only survive. That is why the attention grid is always lower-triangular — the top-right half is blank.
PICTURE. A grid: rows are the reading position , columns the read position . Cells with are blacked out by the mask. A dark cell means "strong attention". We highlight one row — position 6 — and its arrows reaching back.

Where do and come from? Each head owns two small matrices, and , that squeeze the wide -dimensional residual arrow down to a narrow head dimension (typically , where is the number of heads). Concretely and , both living in . So is not new mystery notation — it is simply the length of the query and key arrows this head works with.
Step 4 — The first worker: the previous-token head
WHAT. One special head has a dead-simple pattern: every position attends to the one just behind it. That means and all other weights .
WHY. To later say "A was followed by B", some position must carry a memory of what came right before it. The previous-token head does exactly this: it copies information from slot into slot . Now position 5 (the second dog) secretly also knows "the token before me was cat".
HOW can actually happen? Recall from Step 2 that carries the position mark . Suppose that mark grows smoothly with . The head can learn and so that the query at reads out " shifted back by one" while the key at reads out "". Then is maximised exactly when , i.e. when (and the causal mask already guarantees , so this target is always allowed). The dot product peaks on the immediate-left neighbour and the softmax sharpens that peak to . So the stripe is achievable purely from the position marks — no token content needed.
PICTURE. The attention grid for this head is a single off-diagonal stripe (still inside the lower triangle). Below it, arrows show information sliding one step forward: each bead absorbs its left neighbour.

Step 5 — The second worker: the induction head
WHAT. The induction head, sitting in a later layer, does the clever move. At the current position (the second cat, position 4), it looks for an earlier position whose previous token matched the current token, and copies that position's token forward as the prediction.
WHY. This is the pattern-completion itself. We are at cat (position 4). Somewhere earlier, cat also appeared (position 1). What came after that earlier cat? dog. So predict dog. The head implements "find where this happened before, read what followed".
HOW do this head's and pull it off? This is the heart of the circuit, so let us trace what each matrix reads out of the residual stream — remembering from Step 2's ordering box that this head reads the summed stream, which already contains Step 4's output.
- The query is built at the current position (the second
cat). Its residual arrow contains, thanks to the embedding , the identity of the current tokencat. The induction head's is learned to extract that current-token identity into the query: now encodes "I am looking for a place that was preceded bycat". - The key is built at each candidate position . But here is the trick: position 's residual arrow was modified by the previous-token head in Step 4 — it now carries the identity of , the token that came before . The induction head's is learned to extract that previous-token signal into the key: encodes "the token before me was ".
- The match is therefore large exactly when "the token I'm looking for" (= ) aligns with "the token that preceded " (= ) — that is, when .
So the two matrices are not magic: reads the current token out of the embedding part of the stream, reads the previous token out of the previous-token-head-modified part of the stream, and the dot product fires when they agree. Without Step 4 having written into , there would be nothing for to read — which is exactly why two heads in ordered layers are required.
PICTURE. Two hops drawn in sequence: the current cat sends a query built from its own token identity; that query matches the key at the position right after the earlier cat (a key carrying "cat came before me"); attention lands there; that position's token dog is copied out.

Step 6 — Reading the answer out: the logit lens check
WHAT. Once the induction head has copied dog's information into position 4's residual stream, we can unembed — multiply by the vocabulary matrix — and read the predicted token straight out.
WHY. This is the proof that the circuit did its job. Using the logit lens idea from the parent note, we peek at the residual stream after the induction head and see dog already winning — the answer was assembled by the two heads, not by later machinery.
PICTURE. A bar chart of vocabulary logits after the induction head: dog towers over everything else.

Step 7 — Proving it causally: activation patching
WHAT. Claiming "these two heads do it" is a hypothesis. We test it by patching: run a corrupted input where the model fails, then transplant only the induction head's activation from the clean run — if the correct answer returns, that head caused it.
WHY. Correlation isn't enough (a head could light up without mattering). Patching cuts one wire and reconnects it: if reconnecting this wire alone restores the answer, this wire carried the answer. This is the causal test the parent note demands.
Let us pin down the two symbols this test needs. Let be the activation of the induction head — the vector that head writes into the residual stream at the current position (its contribution from Step 2). We write for that vector on the input the model gets right, and for the input it gets wrong. Let be the model's performance metric: here, the probability it assigns to the correct next token, — a number between 0 and 1, read straight off the logits of Step 6.
PICTURE. Two runs side by side. Corrupted run → wrong prediction. Same run but with the induction head's activation swapped in from the clean run → correct prediction jumps back up. The recovered bar is the causal fingerprint.

The one-picture summary
Everything above collapses into one flow: token string → previous-token head writes each bead's predecessor into it → induction head at the current bead searches (backward only, thanks to the causal mask) for the earlier bead with a matching predecessor → copies what followed it → unembed → prediction.

Recall Feynman retelling — say it back in plain words
Imagine you're reading a story and you hit the word "cat" again. A little clerk (Head 1) has been quietly stamping every word with a sticky note saying "the word before me was ___". So the earlier "dog" is wearing a note that says "cat came before me". Now a second clerk (Head 2) standing at the new "cat" shouts: "Who has a note saying 'cat came before me'?" — and he can only shout backward, never at words to his right (that would be reading the future). The earlier "dog" raises its hand. Head 2 grabs that dog's own word — "dog" — and writes it onto our answer slot. When we finally read the slot out loud (multiply by the read-out matrix ), "dog" is the loudest voice. The two clerks work because they act in order and never erase each other: Head 1 stamps first, and because the stream only adds, Head 2 can still read the stamp later. And to be sure the clerks really did it, we cut Head 2's wire, watch the answer break, splice the good wire back, watch it heal — that's how we know these two, and only these two, run the show. If several "cat"s came before, the clerk shares his shout among all of them and blends their followers. On the very first "cat", nobody has a matching note yet, so the clerk stays quiet. Take every repeat away and both clerks have nothing to stamp or shout about, so the whole trick quietly switches off.
Recall
What does the previous-token head write into each position? ::: the identity of the token immediately before it How can a head force ? ::: by learning so the query reads the position mark and matches the key with mark only at What is made of? ::: the token embedding plus the positional encoding What does the causal mask do? ::: forces for all , so each position only attends to itself and earlier positions How does the induction head's and create the match? ::: extracts the current token into the query, extracts the Step-4-written predecessor into the key; the dot product fires when Why can the later induction head read Step 4's output? ::: layers run in order and the residual stream only adds, so the previous-token head's contribution is still present when the induction head reads the summed stream What condition makes an induction head attend to position ? ::: when (its predecessor equals the current token) and What happens on the first occurrence of a token? ::: no candidate satisfies the match, so the induction head finds nothing and contributes no completion signal What happens when a token has many earlier occurrences? ::: the softmax splits attention across all matches, blending their followers (recency usually wins) What are the dimensions of ? ::: , mapping a -dimensional residual arrow to one score per vocabulary word What is in the patching effect? ::: the probability the model assigns to the correct next token, read from the logits How do we prove the induction head causally matters? ::: patch its clean activation into a failing corrupted run; if the correct answer returns, it caused the completion
Related vault notes: Attention Mechanisms, Transformer Architecture, Sparse Autoencoders, Probing Classifiers, Model Editing, Feature Visualization, and the parent Mechanistic interpretability.