In short
- Featureswhat’s representedConcepts are stored as directions in the model’s internal space, not as single neurons with tidy labels.
- Circuitshow it’s computedAttention heads and neurons in different layers pass information along to produce an answer, like functions in a program.
- Interventionshow you test a storyTo show a part matters, change it and see whether the output changes. Watching it fire is not enough.
- Evidencea ladder, not a switchIn GPT-2 Small, the neuron that fires hardest on a Paris question pushes toward “Paris” only a little, and some strong ones push the other way.
01The goal: recovering the source code
When you train a language model, you do not write its logic. You set up a structure, show it trillions of words, and let an optimiser adjust billions of numbers (the weights) until it predicts the next word well. What comes out works, but it is like a compiled program: a long list of numbers with no comments and no variable names.
Interpretability tries to recover something like the source code. Mechanistic interpretability, the branch this post covers, aims for a step-by-step account of how the model turns an input into an output (Elhage et al. 2021). Three ideas run through everything below:
Features are what the model represents: “this is about France”, “the next word should be a name”. Circuits are how features get computed from other features, by specific parts of the model working together. Interventions are how you check a story about features and circuits: you edit the model’s internals and see whether its behaviour changes the way the story predicts.
Some of the figures use toy numbers small enough to follow by hand, and some use a real model, GPT-2 Small (124 million weights, 12 layers). Each figure says which.
02The residual stream: a running total every layer adds to
A transformer first turns each token (a word or a piece of a word) into a vector, a list of numbers. In GPT-2 Small that list has 768 numbers. Each token position keeps its own vector all the way through the model, and this vector is called the residual stream.
The key fact is that layers never overwrite the stream. Each layer reads the current vector, computes something, and adds its result back. After the last layer, the model turns the final vector into a score for every possible next token. So the final vector is literally a sum: the starting embedding plus every layer’s contribution. That makes a basic question answerable: how much did each part add toward a particular answer?
Two kinds of layer take turns. Attention moves information between positions: it is the only place where one token’s stream can draw on another’s. MLPs (multi-layer perceptrons, blocks of neurons) process information within a single position.
Every layer adds to the stream; nothing is overwritten
Turn each layer off and on. Each square is one number in a toy six-number stream (blue positive, red negative).
03Attention: where to look and what to move
An attention head lets each position pull information from earlier positions. It works like a small search engine. Every token produces three vectors: a query (what I am looking for), a key (what I advertise about myself) and a value (what I hand over if chosen). The head compares one token’s query with every earlier token’s key. Good matches get a high score, and the token receives a weighted mix of the matching tokens’ values.
The weights that produce queries, keys and values (written WQ, WK and WV), and the weight that writes the result back (WO), are learned in training and shared by every token; each head has its own set. The queries, keys and values themselves are computed fresh for each token from its stream.
This splits a head into two jobs (Elhage et al. 2021). The QK circuit (queries and keys) decides where to look. The OV circuit (values and output) decides what gets moved and where in the destination stream it is written. Both are parts of the same head, not connections between heads, and they can be studied separately.
One more detail matters later. Scores pass through a softmax, which turns them into percentages that always add up to 100%. A head cannot attend to nothing: even when no token matches, the attention has to go somewhere.
Queries and keys decide where a head looks
Drag the sliders to set the query of “sat”, or pick a preset. Score = query · key ÷ √2, then softmax.
04MLPs and features: read, gate, write
An MLP layer is a large set of neurons (3,072 per layer in GPT-2 Small) that each work in three steps. A neuron reads the stream by measuring how well it matches a particular direction, the neuron’s preferred pattern. It adds a bias, a fixed number that is usually negative, which sets how strong a match has to be. Then it passes the result through a gate, called GELU (Hendrycks & Gimpel 2016), which keeps positive values and squashes negative ones to about zero. Finally it writes its own direction back into the stream, scaled by how strongly it fired.
The number before the gate, match plus bias, is called the pre-activation, and it is effectively the neuron’s decision. The gate only shapes it softly. The bias is what makes neurons useful for logic. Suppose a neuron reads two features equally. With no bias, either feature alone makes it fire: an OR. With a bias large enough that one feature alone stays below zero, it fires only when both are present: an AND.
This leads to the central idea in modern interpretability: a feature is a direction in the space of activations. The linear representation hypothesis says that many concepts are stored this way, so that “how much this is about France” is how far the stream points along one direction (Park et al. 2024). Neurons read and write directions, and the stream is a sum of many of them.
The bias decides how strong a match has to be
Drag the bias. The neuron reads the direction [0, 0, 1, 1]; “sat” matches it with a score of 1.67, “cat” with 0.5.
A word of caution about facts. It is tempting to imagine that “the Eiffel Tower is in Paris” lives in one neuron. It does not. MLP layers can be read as large key–value memories, with each neuron reading a pattern and writing an association (Geva et al. 2021), and middle-layer MLPs play a large part in recalling facts about a subject (Meng et al. 2022). But the recall is spread across many neurons and layers, not stored at one tidy address.
05Why neurons are messy: superposition
If every neuron stood for one clean concept, interpretability would be easy: list the neurons, label them, done. In practice many neurons are polysemantic: the same neuron fires for unrelated things, say academic citations, Korean text and HTTP requests (Bricken et al. 2023).
The leading explanation is superposition (Elhage et al. 2022). A model may need far more features than it has dimensions. It can still pack them in by giving each feature a direction that is almost, but not exactly, perpendicular to the others. The cost is interference: when two features are active at once, each leaks into the other’s reading. That cost is small if most features are rarely active together, which is true of most concepts: a given sentence is about very few things. In toy models, the sparser the features and the fewer the dimensions available for them, the more superposition the model uses. It is a hypothesis with good support in small models, not a proven account of large ones.
Five features squeezed into two dimensions
Tick features to turn them on. Each reading is followed by a bias of −0.4 and a ReLU gate, which cuts negatives to zero.
The practical consequence is that the useful unit is a direction, not a neuron. The main tool for finding these directions is the sparse autoencoder: a second, much wider network trained to rewrite each activation as a combination of a few directions out of thousands, which often turn out to be more readable than individual neurons (Bricken et al. 2023). They have real limits. They do not reconstruct the activations perfectly, so part of what the model computes is left out. The features they find depend on choices such as the dictionary size. And when used as tools for detecting concepts, they occasionally beat simple linear probes on individual datasets but do not consistently help (Kantamneni et al. 2025).
06Watching the model: tools that show correlation
The first family of tools looks at what the model does on an input, without changing anything.
Attention patterns show where each head looked. The logit lens takes the residual stream partway through the model and decodes it as if it were the final layer, which shows the prediction forming layer by layer (nostalgebraist 2020). Direct logit attribution uses the fact that the final stream is a sum: it splits the score for a candidate answer into the part each head or neuron wrote directly (Elhage et al. 2021). Probes are small classifiers trained to read a concept, such as “is this sentence true”, off the activations.
Here is direct logit attribution on a real model. Given “The Eiffel Tower is in the city of”, GPT-2 Small puts “Paris” first at 7.0%, narrowly ahead of “London” at 5.8%. At the last token, 91 of the 3,072 neurons in layer 6 fire above 0.5.
The neurons that fire hardest are not the ones that matter most
Layer 6 of GPT-2 Small, last token. Switch the sort order. Pushes are in logit points: the units of the score before softmax.
Two caveats apply to every tool in this section. First, firing is not causing: a neuron can fire strongly on Paris questions because it tracks something nearby, such as “European landmark”, without affecting the answer. Second, direct attribution misses indirect effects: a neuron that writes nothing useful directly may change what a later layer does, and that path does not show up here. Taken together, all 3,072 neurons in layer 6 add only about half a logit point to “Paris” directly. Whatever else they do happens through later layers.
07Poking the model: tools that test causes
To move from “this part is active” to “this part matters”, you have to intervene.
Ablation removes a component and measures the damage. How you remove it matters (Heimersheim & Nanda 2024). Zero ablation sets its output to zero, but zero may be a value the model never sees in normal use, so the damage can reflect confusion rather than a lost function. Mean ablation replaces the output with its average over many inputs, and resample ablation replaces it with its value on a different input. Both keep the model in familiar territory.
Activation patching is more precise. You prepare two prompts that differ in one relevant way: a clean one and a corrupted one. You run both, then copy one activation from the clean run into the corrupted run and see whether the clean answer comes back. If it does, that activation carries the information that matters.
The standard example is indirect object identification, or IOI (Wang et al. 2022): “When Mary and John went to the store, John gave a drink to” should end with “Mary”. The measure is the logit difference: the score for “Mary” minus the score for “John”. In the corrupted prompt the second name is “Mary” instead, so the right answer flips to “John”.
Patching shows where the answer’s information lives, layer by layer
Click a cell to patch the clean stream into the corrupted run at that position and layer. Numbers are the percentage of the logit difference restored.
Interventions have a trap of their own: self-repair. In the IOI circuit, when the main heads that copy the name are removed, backup heads that normally contribute little start doing the job instead (Wang et al. 2022). Similar compensation shows up in larger models (McGrath et al. 2023). So “remove it and see what breaks” can understate how important a component is in the unmodified model.
08Putting it together: induction heads
The best-understood circuit in language models is the induction head (Elhage et al. 2021; Olsson et al. 2022). It completes a simple pattern: if the text so far contains [A][B] and the current token is [A] again, predict [B]. After “Mr. Dursley” appears once, “Mr. D” should continue with “ursley”.
One head cannot do this alone. At the second “D”, the head needs to find the earlier spot that came right after a “D”. But the stream at “urs” starts out knowing only that it is “urs”; nothing in it says what came before. So the work takes two steps in two layers. First, a previous-token head at “urs” attends one position back and writes “my previous token was D” into the stream at “urs”. Then, a few layers later, the induction head at the second “D” uses its query to search for “previous token was D”, finds “urs”, and copies it forward as the prediction.
Two heads, two layers: how a model continues a repeated pattern
Tick the box to remove the previous-token head and watch what happens to step 2.
A clean test uses random tokens. Take 50 random tokens and repeat them. On the first copy nothing is predictable; on the second copy, an induction head can predict every token. In GPT-2 Small, the average loss (a measure of surprise, lower is better) falls from 11.99 on the first copy to 0.41 on the second. In the attention pattern, induction heads show up as a diagonal stripe: each token in the second copy looks at the token just after its earlier match. Eleven heads in GPT-2 Small put more than 40% of their attention on that stripe.
“Induction head” is a role, not a part of the architecture. It is an ordinary attention head that learns this job during training, and Olsson et al. found that it appears in a sudden phase change early in training, at the same time as the model gets much better at using earlier context.
09What these tools can and can’t tell you
Each tool gives a different strength of evidence. It helps to think of them as rungs on a ladder:
- It is active. The neuron or head fires on the inputs you care about.
- It contributes directly. Its output pushes the answer the right way.
- Removing it hurts. Ablating it, ideally with a mean or resample, makes the behaviour worse.
- Patching it restores. Copying it from a clean run into a corrupted one brings the behaviour back.
- It holds up. The effect appears on new prompts you did not tune on, and is larger than for randomly chosen components.
Most claims you read sit on the first two rungs. Four pitfalls come up again and again. Labels from top examples are guesses: a neuron whose ten strongest examples mention France might really track something broader. Correlation is not causation, as Figure 5 shows. Parts depend on each other, and self-repair can hide importance. And one prompt is not a general claim: everything in Figures 5 and 6 is from a single example.
10Reading the source code
Put together, these tools are how researchers read a model’s “source code”. The residual stream gives the program a shared memory that every layer writes into. Attention heads are the instructions that move data between positions, and neurons the ones that transform it in place. Features are the variables, stored as directions and often packed tightly together. Watching tools tell you which parts are busy, and intervention tools tell you which parts matter. For one small model and one pattern, induction heads, the whole chain has been worked out. For most behaviours in large models it has not, and the honest answer to “what is the model doing?” is still a partial one.
To try these tools yourself, the TransformerLens main demo walks through them in code, and Neel Nanda’s Mechanistic Interpretability Quickstart Guide suggests where to start.
Appendix A: how the GPT-2 Small numbers were computed
All real numbers come from one script, exp/interp_gpt2.py, run on a laptop CPU with TransformerLens 3.9 and its default weight processing. Figure 5: the prompt is fed without a beginning-of-text token (with one prepended, “London” edges ahead of “Paris”, 8.1% to 6.9%). A neuron’s direct push is its activation times its output weights, projected onto the unembedding column for “Paris” and divided by the final LayerNorm scale. Because the unembedding is centred, a push is relative to the average token. Figure 6: the residual stream entering each layer is patched at one position, and the restored share is (patched − corrupted) ÷ (clean − corrupted) on the logit difference; the clean and corrupted differences are +3.36 and −2.48. Section 08: 20 sequences of 50 random tokens, each repeated once. The strongest previous-token head is L4H11 and the strongest induction head L5H5. Replacing L4H11’s output with its mean cut L5H5’s induction score from 0.91 to 0.65 and raised the loss on the second copy from 0.41 to 0.64. Exact values are in data/figures.js.
References
- Bricken, Templeton, Batson, Chen, Jermyn, et al. (2023). Towards Monosemanticity: Decomposing Language Models With Dictionary Learning. Transformer Circuits Thread. transformer-circuits.pub/2023/monosemantic-features
- Elhage, Nanda, Olsson, et al. (2021). A Mathematical Framework for Transformer Circuits. Transformer Circuits Thread. transformer-circuits.pub/2021/framework
- Elhage, Hume, Olsson, et al. (2022). Toy Models of Superposition. Transformer Circuits Thread. arXiv:2209.10652
- Geva, Schuster, Berant, Levy (2021). Transformer Feed-Forward Layers Are Key-Value Memories. EMNLP 2021. arXiv:2012.14913
- Heimersheim & Nanda (2024). How to use and interpret activation patching. arXiv:2404.15255
- Hendrycks & Gimpel (2016). Gaussian Error Linear Units (GELUs). arXiv:1606.08415
- Kantamneni, Engels, Rajamanoharan, Tegmark, Nanda (2025). Are Sparse Autoencoders Useful? A Case Study in Sparse Probing. arXiv:2502.16681
- McGrath, Rahtz, Kramár, Mikulik, Legg (2023). The Hydra Effect: Emergent Self-repair in Language Model Computations. arXiv:2307.15771
- Meng, Bau, Andonian, Belinkov (2022). Locating and Editing Factual Associations in GPT. NeurIPS 2022. arXiv:2202.05262
- nostalgebraist (2020). interpreting GPT: the logit lens. LessWrong. lesswrong.com/posts/AcKRB8wDpdaN6v6ru
- Olsson, Elhage, Nanda, et al. (2022). In-context Learning and Induction Heads. Transformer Circuits Thread. transformer-circuits.pub/2022/in-context-learning-and-induction-heads
- Park, Choe, Veitch (2024). The Linear Representation Hypothesis and the Geometry of Large Language Models. ICML 2024. arXiv:2311.03658
- Wang, Variengien, Conmy, Shlegeris, Steinhardt (2022). Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small. arXiv:2211.00593