Exercises — Mechanistic interpretability
Before we start, one shared picture. A transformer keeps a running "notepad" called the residual stream: a vector at each layer that every component reads from and writes back into by addition. Look at the picture — the horizontal arrow is the stream, each block adds its contribution.

We will refer to this picture over and over.
Level 1 — Recognition
Exercise 1.1
Match each phrase to traditional interpretability or mechanistic interpretability: (a) "This neuron fires for cats." (b) "This circuit detects edges, then curves, then assembles cat-ears."
Recall Solution
(a) is traditional / post-hoc interpretability — it names what activates a unit but not how the computation runs. (b) is mechanistic interpretability — it describes the algorithm (a chain of composed steps), not just the input→output label. The tell: mechanistic answers always describe a process with steps, traditional answers describe a label.
Exercise 1.2
In the residual-stream picture (figure above), how do a layer's Attention and MLP outputs combine with the incoming stream — do they replace it or add to it? (Here and are the two LayerNorms defined in the Symbols box.)
Recall Solution
They add. That is the meaning of the residual ("skip") connection, with normalizing what Attention reads and normalizing what the MLP reads: Each block writes an increment into the shared notepad; nothing is overwritten. This is exactly why we can read partial answers early (the Logit Lens works because the stream is a running sum).
Exercise 1.3
Recall from the Symbols box that is the attention pattern matrix, with the weight query position puts on key position . Name the attention head whose pattern satisfies (each position attends to the one just before it).
Recall Solution
A previous-token head. Reading the matrix: row (the query position) puts nearly all its weight on column (the key position one step back).
Level 2 — Application
Exercise 2.1
A head has query dimension . Two token embeddings produce a raw dot product . What logit does the head use before softmax, using the scaling from the parent note?
Recall Solution
The attention logit is scaled by : Why divide? Without scaling, dot products grow like and push softmax into saturation (all weight on one token, zero gradient). Dividing by keeps the logit variance near .
Exercise 2.2
Activation patching. Recall from the Symbols box that is the model's performance score (e.g. probability on the correct token). On a clean input the model scores . When we set component to its baseline (ablate it), performance drops to . Compute the effect .
Recall Solution
Using the parent-note formula: A large positive effect ( out of a possible ) means carries most of the load for this behaviour.
Exercise 2.3
Superposition capacity. A layer has dimensions. Each of features is active with probability (sparsity) . The rough packing condition is . What is the largest integer allowed by this bound?
Recall Solution
Expected number of simultaneously active features is . The bound gives So the largest integer is . The network can represent far more features than dimensions () precisely because features rarely fire together.
Level 3 — Analysis
Exercise 3.1
Two heads write into the residual stream. Recall from the Symbols box that is the shared output projection and its per-head block. Suppose the additive-over-heads form gives head contributions and (each is applied to its head's output), and the incoming stream is . What is (ignoring the MLP branch)? Which head dominates the change in the second coordinate?
Recall Solution
Attention adds the sum over heads: Then In the second coordinate, head 2 contributes vs head 1's , so head 2 dominates the second coordinate's change. This linearity — heads add independently into the stream — is exactly why we can attribute credit per head.
Exercise 3.2
Logit Lens sanity check. Recall from the Symbols box that is the unembedding matrix (one row per vocabulary token) and its optional bias. Suppose the residual stream at layer after LayerNorm is , the bias is , and the rows for three tokens are Which token does the Logit Lens predict at layer (largest logit)?
Recall Solution
The Logit Lens logit of a token is for that token's row; here , so it reduces to the dot product of the row with : Largest is , so the Logit Lens predicts "fish" at layer . This is the whole trick: because the stream is a running sum and is linear, we can read a partial prediction from any layer, not just the last.
Exercise 3.3
Look at the two attention patterns in the figure below. Pattern P is a previous-token head; pattern Q is an induction head on the sequence "A B C A B". For the query at the final position (the second "B", index 5), which key position does each head attend to?

Recall Solution
Index the tokens .
- Previous-token head (P): the query at position 5 attends to position (the token "A"). Rule: .
- Induction head (Q): it looks for the earlier place where the previous token matched. The current previous token is "A" (position 4). The earlier "A" is at position 1, and induction attends to the token after that match — position 2 ("B") — because that is what should come next. So Q at position 5 attends to position 2. Together they implement "A B … A → predict B": the previous-token head lays down the "what came before me" tag, and the induction head reads it to complete the pattern.
Level 4 — Synthesis
Exercise 4.1
Design a minimal activation-patching experiment to prove that a candidate head is the one completing the sequence "cat dog mouse cat dog [?]" → "mouse". Specify: (i) the clean and corrupted inputs, (ii) what you patch, (iii) the pass/fail criterion.
Recall Solution
(i) Inputs. Clean "cat dog mouse cat dog", on which the model correctly predicts "mouse". Corrupted the same string with an early token swapped so the pattern breaks — e.g. "cat dog mouse fox dog", on which the model fails to predict "mouse". (ii) Patch. Run the model on , but overwrite the activation of the single head with its value from the clean run: . Leave all other activations at their corrupted values. (iii) Criterion. If performance on the corrupted run recovers toward "mouse" only when we patch (and stays broken when we patch unrelated heads), then causally mediates the completion. The formal quantity is the recovered fraction ; near means full mediation. Why patch, not just ablate? Ablation would only show that matters. Patching shows that the specific information computes on the clean input is what restores the behaviour — that is a claim about what it computes and where it flows.
Exercise 4.2
You measure the recovered fraction for a patch: clean perf , corrupted perf , patched perf (all are scores in ). Compute the recovered fraction and interpret.
Recall Solution
The head restores of the lost performance — strong (but not total) causal mediation. The missing says other components share the computation; the head is important but not minimally sufficient on its own.
Level 5 — Mastery
Exercise 5.1
Superposition geometry. In dimensions you must store features as unit vectors minimizing worst-case interference (pairwise dot products). What angle should separate consecutive feature directions, and what is the resulting pairwise dot product ?
Recall Solution
With 3 unit vectors in a plane, the symmetric arrangement that maximizes the minimum angle between them spreads them evenly around the circle: consecutive angle The interference between any two is their dot product: Look at the figure: three arrows at form a "Mercedes star." Note the dot product is negative — the vectors are more than apart, which is the best you can do when forced to overpack: you cannot make them orthogonal (that needs ), so the optimizer settles for maximally spread, mildly anti-correlated directions. This is superposition made visible.

Exercise 5.2
Full-stack reasoning. Explain, from the residual-stream picture, why the Logit Lens can produce a wrong-looking early prediction that later "flips" — and why this is not a bug but expected behaviour. Give the governing equation, including the LayerNorm step and the unembedding bias.
Recall Solution
The stream is a running sum: The Logit Lens reads, from a partial sum , the logits i.e. it first applies LayerNorm to the intermediate stream, then the unembedding matrix and its bias . Early layers have only added a few increments, so this readout reflects incomplete computation. A later head or MLP can add a that reverses the leading logit — e.g. an induction head that only fires in a mid layer supplies the token that outranks an early guess. So a flip is the signature of a component doing real work late in the stack. It is expected because prediction is accumulated, not decided at layer 1. (This is also why the Tuned Lens exists: a learned affine map per layer corrects for the fact that early live in a slightly different basis than expects.)
Exercise 5.3
Capacity + interference trade-off. With dimensions and sparsity , (a) give the packing ceiling from , and (b) state in one sentence what physically limits you from actually reaching it.
Recall Solution
(a) , so features. (b) You never reach the ceiling cleanly because the moment two features co-activate their non-orthogonal directions interfere (), corrupting the decoded values; the more you pack, the larger and more frequent this interference, until decoding error outweighs the extra capacity. (Sparse autoencoders — see Sparse Autoencoders — are the tool that un-mixes these overlapping directions back into interpretable features.)
Recall Master check: link back
- The residual stream is a running ::: sum (components add increments, never overwrite)
- Scale attention logits by ::: to keep softmax out of saturation
- Effect of a component ::: clean performance minus ablated performance
- Standard patching direction ::: clean activations transplanted into the corrupted run
- Superposition packing bound ::: (expected active features below dimension count)
- Cost of superposition ::: interference / polysemanticity when features co-activate
Prerequisites & neighbours: Mechanistic interpretability · Attention Mechanisms · Transformer Architecture · Sparse Autoencoders · Feature Visualization · Probing Classifiers · Model Editing · 6.3.06 Mechanistic interpretability (Hinglish)