What mechanistic interpretability can establish about a transformer

← Back to Blog & Articles

Running this prints one line per layer, each reporting the vocabulary token the projected logits currently favor most and that token’s logit value; because the increments here are random rather than trained, the favored token typically jumps around unpredictably from layer to layer rather than converging, which is exactly the expected behavior for an untrained stream and the point of contrast with a real model’s characteristically smoother, sharpening trajectory.

the companion book (The Transformer Block and Full Architecture) introduced the residual stream view of a pre-norm Transformer: writing 𝐡(l)=𝐡(0)+∑l′=1lΔ(l′)\mathbf{h}^{(l)} = \mathbf{h}^{(0)} + \sum_{l'=1}^{l} \Delta^{(l')} for the cumulative sum of the initial embedding and every sublayer’s additive contribution up to layer ll, every attention and feedforward sublayer reads from and additively writes into a single, shared, fixed-width channel, with no sublayer able to delete what an earlier sublayer wrote — only to add a further, possibly opposing, contribution. That chapter derived three structural consequences of this additive form: information is never architecturally deleted, only suppressed by interference; a feature written at any layer is, in principle, equally available to every later layer’s read, regardless of the distance between them; and the stream’s fixed width becomes an increasingly scarce shared resource as the number of sublayers competing to use it grows with depth, which is the structural root of the phenomenon called superposition. Mechanistic interpretability is the research program that tries to turn these structural facts into actual, verified descriptions of what a specific trained network computes — and it is worth being direct from the outset that this is presently a young, actively contested field: the techniques below produce real, useful, and reproducible findings, but none of them yet delivers a complete, certified account of what a frontier-scale model is doing, and claims from this literature should be read with that caveat attached throughout.

Probing classifiers. The most direct way to ask “does the residual stream at layer ll contain information about property YY” is to try to extract it: freeze the trained model, collect its activations 𝐡(l)\mathbf{h}^{(l)} at some layer and position across many inputs labeled with the property of interest (part of speech, sentiment, the truth value of a factual claim, the current step of a multi-step computation), and train a separate, simple classifier — typically linear, i.e. logistic regression on top of 𝐡(l)\mathbf{h}^{(l)} — to predict YY from the frozen activations. Alain and Bengio (2016), who introduced this technique as “linear classifier probes” for image models and whose framing has since become standard practice for language models as well, motivate the specific choice of a linear probe carefully: a sufficiently powerful, non-linear probe can learn to extract almost any property from almost any intermediate representation regardless of whether that property is used, or even easily accessible, to the network’s own downstream computation, which would make a successful probe uninformative about what the network itself is doing with the representation. A linear probe’s success is a much more conservative, and correspondingly more meaningful, claim: it demonstrates that the property YY is linearly decodable from 𝐡(l)\mathbf{h}^{(l)} — recoverable by the same kind of operation (a linear projection) that a later sublayer’s own query, key, value, or feedforward-input projections are capable of applying — which is a necessary (though not sufficient) condition for the network’s own later layers to plausibly be using that information. A high probe accuracy is evidence a feature is represented in a usable form at that layer; it is not, by itself, evidence that any specific later layer actually reads and uses it, which is exactly the gap the companion book flagged between what the residual stream architecturally permits and what a trained model’s weights were actually found to exploit.

The logit lens. A second technique exploits the residual stream’s additive structure even more directly. Because 𝐡(l)\mathbf{h}^{(l)} is being built up, increment by increment, toward the same representation that the final layer normalization and unembedding matrix 𝐖U\mathbf{W}_U eventually consume to produce next-token logits, nostalgebraist (2020) observed that there is nothing stopping an investigator from applying that same final unembedding projection to an intermediate 𝐡(l)\mathbf{h}^{(l)}, well before the network’s last layer — producing a distribution over the vocabulary that can be read as “what the model would predict if generation stopped here,” at every layer of the network simultaneously. This technique, dubbed the logit lens, requires no additional training and no modification to the model: it is purely a different way of reading out an already-computed intermediate quantity. On real trained models, the logit lens characteristically shows early layers producing high-entropy, generic, or syntactically-driven guesses, with the predicted distribution sharpening and becoming semantically specific in later layers — a direct, visualizable illustration of the residual stream being progressively refined, layer by layer, toward its final prediction, and a technique that is only sensible in the first place because of the additive residual-stream structure the companion book derives; it would produce meaningless output on an architecture where each layer’s representation were an unrelated transformation of the previous one rather than an increment on a running total.

The code below implements the logit-lens projection mechanics directly. Because this book has no access to a trained model’s actual weights, the residual-stream increments Δ(l)\Delta^{(l)} here are random rather than learned — the point of the listing is to make the linear algebra of the technique fully concrete and runnable, not to reproduce the smoothly-sharpening prediction pattern a real trained model shows; applying the same logit_lens function to real hidden states captured via forward hooks on a trained Transformer is a direct extension of exactly this code.

Running this prints one line per layer, each reporting the vocabulary token the projected logits currently favor most and that token’s logit value; because the increments here are random rather than trained, the favored token typically jumps around unpredictably from layer to layer rather than converging, which is exactly the expected behavior for an untrained stream and the point of contrast with a real model’s characteristically smoother, sharpening trajectory.

Superposition and sparse autoencoders. The third structural fact from the companion book — that the residual stream’s width is fixed while the number of sublayers competing to write distinguishable signals into it grows with depth — is the setting for the interpretability challenge known as superposition: individual coordinates, or even individual neurons within the network’s wider intermediate representations, frequently respond to multiple, semantically unrelated concepts rather than to one cleanly interpretable feature each, a phenomenon usually called polysemanticity. Elhage, Hume, Olsson, et al. (2022) argue and demonstrate on small toy models that this is a natural, near-unavoidable consequence of a network needing to represent more distinct, sparsely-active features than it has literal dimensions available: if the true underlying features of the data are individually rare (active on only a small fraction of inputs) and only a few are ever simultaneously relevant, a network can pack many more such features into a fixed-width space than its dimensionality would naively allow, by assigning them to an overcomplete set of almost-orthogonal directions rather than to individual coordinates — at the cost of interference whenever two superposed features happen to be active together, and at the cost of making any single coordinate or neuron’s activation reflect a blend of unrelated concepts rather than one clean, human-nameable one.

Sparse autoencoders (SAEs) are a current, actively developed approach to reversing this compression and recovering individually interpretable features. Cunningham, Ewart, Riggs, et al. (2023) apply the technique directly to language model activations: an SAE is trained, entirely separately from the language model itself and without altering it, to reconstruct a layer’s activation vector 𝐱\mathbf{x} from a much higher-dimensional, sparsely-active intermediate code, using a loss of the conceptual form

ℒ(𝐱)=∥𝐱−𝐱̂∥22+λ∥𝐟(𝐱)∥1, \mathcal{L}(\mathbf{x}) = \big\| \mathbf{x} - \hat{\mathbf{x}} \big\|_2^2 \;+\; \lambda \big\| \mathbf{f}(\mathbf{x}) \big\|_1,

where 𝐟(𝐱)\mathbf{f}(\mathbf{x}) is the SAE’s overcomplete latent code (typically several times wider than 𝐱\mathbf{x} itself), 𝐱̂\hat{\mathbf{x}} is the reconstruction decoded back from 𝐟(𝐱)\mathbf{f}(\mathbf{x}), and the ℓ1\ell_1 penalty, weighted by λ\lambda, encourages each input to activate only a small number of the available latent directions rather than spreading activation broadly across all of them. The premise, directly motivated by the superposition argument above, is that if the network’s true features really are individually sparse and only approximately orthogonal in the original activation space, an overcomplete, sparsity-regularized basis has room to assign each one something closer to its own dedicated direction, undoing — to a degree measured empirically, not guaranteed by the method — the compression that produced polysemantic neurons. Cunningham et al. report that the resulting features are substantially more interpretable, as judged by automated interpretability-scoring methods, than either raw neurons or other non-sparse decompositions of the same activations, and that specific learned features can be tied to previously-known causal circuits with finer granularity than earlier decomposition methods achieved.

This should be presented, accurately, as promising and unfinished rather than solved: SAE-derived features still require a human (or an automated proxy) to inspect and label them, the method’s hyperparameters trade off reconstruction fidelity against interpretability empirically rather than by derivation, there is active debate about whether the features an SAE discovers are the network’s own true computational units or a convenient re-encoding of the same information, and scaling the technique to frontier-model width and depth remains an open engineering problem. Mechanistic interpretability, across all three techniques surveyed here, is a set of real, quantitatively validated tools for asking specific, falsifiable questions about a trained network’s internals, operating within the structural constraints the residual stream view makes precise — not yet a general, reliable procedure for reading a model’s “true beliefs” or “reasoning process” off of its weights.

Continue with the book

Explore the full treatment, worked examples, and exercises in LLMs Derived.


Companion article for LLMs Derived, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top