Mechanistic interpretability: circuits, features, SAEs¶
Mechanistic interpretability tries to reverse-engineer a trained network into human-understandable parts: the features it represents and the circuits that compute with them. The central obstacle is superposition, networks packing more concepts than they have neurons, and the central tool of 2023–2026 is the sparse autoencoder, which unpacks them. This page builds the whole stack: the residual-stream view of transformers, induction heads, superposition, SAEs, activation patching and attribution graphs, with the maths and a working SAE in NumPy.
10,000 ft
We train networks whose behaviour we can measure (benchmarks) but whose internals we did not design. Interpretability asks how a model produces its outputs, and the mechanistic school asks for answers at the level of an engineer reading a program: these weights implement this algorithm. It matters for safety because behaviour alone cannot distinguish a model that is honest from one that has learned to look honest (the alignment problem); for science, because a working mechanism is the strongest kind of explanation; and for engineering, because finding the part that does something lets you monitor, steer or remove it. It builds on attention, the transformer block and the geometry of embeddings, and it borrows heavily from linear algebra and sparse coding. As of 2026 it is a young field with real wins (induction heads, refusal directions, feature maps of production models, attribution graphs) and real doubts about whether its main tools scale to full explanations.
2,000 ft
The working loop is: look at activations, decompose them into interpretable variables, find which variables matter for a behaviour, and prove it by intervening.
- The residual stream is a shared vector that every attention head and MLP reads from and adds to, so a transformer's computation can be written as a sum of paths.
- Features are directions in activation space (the linear representation hypothesis).
- Networks represent more features than dimensions by using nearly orthogonal directions (superposition), so individual neurons are polysemantic.
- Sparse autoencoders learn an overcomplete dictionary that turns each activation into a few active, often interpretable features.
- Circuits are found by causal interventions: patch, ablate or steer a component and measure the effect; attribution graphs chain features into end-to-end mechanisms.
Ground level¶
What "mechanistic" adds¶
There are three broad ways to explain a model's output:
- Behavioural. Vary the input, watch the output. Says what the model does, not how.
- Attributional. Assign each input feature a share of credit: saliency maps, integrated gradients (Sundararajan et al., 2017), attention weights. Cheap and widely used, and often misleading: some saliency methods produce nearly the same maps for a trained network and a randomly initialised one (Adebayo et al., 2018), and attention weights can be rearranged without changing predictions (Jain and Wallace, 2019).
- Mechanistic. Identify the internal variables and the computation that connects them, and test the story by intervening. This is the program-reading ambition.
The research programme was set out in Zoom In (Olah et al., 2020), which made three speculative claims about vision networks: features are the fundamental unit of a network and correspond to directions; features are connected by weights into circuits that can be read like code; and analogous features and circuits recur across models (universality). Most of what follows is the attempt to make those claims precise and true for language models.
The residual stream: a transformer as a sum of paths¶
In a transformer each layer adds its output to a running vector, the residual stream (transformer block). Anthropic's Mathematical Framework for Transformer Circuits (Elhage et al., 2021) took that seriously as an organising view:
Three consequences follow, each used constantly in practice:
- The final residual is a sum. \(x_L = x_0 + \sum_{\text{heads}} h(x) + \sum_{\text{MLPs}} m(x)\), so the logits \(W_U x_L\) decompose into a contribution from every component. This is direct logit attribution: which heads and MLPs pushed the logit of "Paris" up?
- Each head is independent and low-rank. A head's effect factors into a QK circuit \(W_{QK} = W_Q^\top W_K\), which decides where to attend, and an OV circuit \(W_{OV} = W_O W_V\), which decides what gets moved. Both are \(d_{\text{model}}\times d_{\text{model}}\) matrices of rank at most \(d_{\text{head}}\).
- Layers communicate through subspaces. A later head can read what an earlier head wrote. When a head's queries, keys or values read an earlier head's output, the paper calls it Q-, K- or V-composition; composed heads behave like "virtual attention heads".
A zero-layer transformer (embed, then unembed) can only learn bigram statistics, \(W_U W_E\). A one-layer attention-only model adds "skip-trigram" paths (a token attends to an earlier token and changes the next-token prediction). The first genuinely algorithmic behaviour appears with two layers, through composition.
A cheap way to look inside, before any of this machinery, is the logit lens: apply the unembedding to an intermediate residual stream and see what the model "would say" at that depth (nostalgebraist, 2020). The tuned lens learns a small affine map per layer to make those readouts faithful (Belrose et al., 2023).
Induction heads: a circuit for in-context learning¶
The best-understood circuit in language models completes patterns of the form \([A][B] \dots [A] \to [B]\): having seen "Mr Dursley" earlier, on seeing "Mr" again, predict "Dursley". It needs two heads in different layers.
A previous-token head in layer 1 writes, at each position, information about the token before it. An induction head in layer 2 forms its keys from that information (K-composition), so the current token "Mr" attends to positions preceded by "Mr", which is the position of "Dursley"; its OV circuit then copies "Dursley" towards the output. Olsson et al. gave six lines of evidence that induction heads are a major mechanism of in-context learning: they form at exactly the point in training where in-context learning improves sharply, visible as a bump in the loss curve; the evidence is causal for small attention-only models and correlational for large ones (Olsson et al., 2022).
Features as directions¶
The linear representation hypothesis says a model represents a concept as a direction in activation space: the concept's strength is a projection onto that direction, and concepts combine by vector addition. The evidence is broad. Word-vector arithmetic was the first hint (embeddings). Linear probes recover many properties from hidden states (Alain and Bengio, 2016). Truth and falsehood of simple statements separate along a direction (Marks and Tegmark, 2023). Refusal in 13 open chat models up to 72B parameters is mediated by a single direction: erase it and the model stops refusing harmful requests; add it and the model refuses harmless ones (Arditi et al., 2024). Park et al. formalise the hypothesis and show that the right inner product for these directions is not always the Euclidean one (2023).
Two cautions. A probe that decodes a property shows the information is present, not that the model uses it; a sufficiently powerful probe can decode almost anything, which is why Hewitt and Liang compare probes against control tasks with random labels (2019). And a direction found by correlation must be tested by intervention: adding or removing it should change behaviour in the predicted way. The difference of means between activations on two contrasting sets of prompts is the simplest way to find a candidate direction and is used in steering, refusal and truthfulness work alike (Turner et al., 2023; Li et al., 2023; Zou et al., 2023). You will build one below.
Polysemanticity and superposition¶
If features were directions aligned with neurons, interpretation would be easy: read off each neuron. In practice many neurons are polysemantic: one neuron responds to academic citations, English dialogue, HTTP requests and Korean text. Why?
Toy Models of Superposition (Elhage et al., 2022) gave the answer with a model small enough to solve completely. Take \(n\) features, compress them into \(m < n\) dimensions with a matrix \(W\), and reconstruct with \(\operatorname{ReLU}(W^\top W x + b)\). When features are dense (usually active), the model behaves like PCA: it represents the \(m\) most important features on orthogonal axes and drops the rest. When features are sparse (rarely active), it represents more features than dimensions by giving them nearly orthogonal directions, accepting a little interference when two happen to be active at once and using the ReLU and a negative bias to filter small interference out.
This explains polysemanticity: if the network stores many sparse features along directions that are not aligned with neurons, every neuron sees a mix of several. It also explains why the neuron basis is the wrong place to look and why you need a method that finds the feature directions themselves. In the residual stream, nothing privileges the neuron basis at all: the stream is only ever read and written by linear maps, so rotating it (and every matrix that touches it) leaves the network unchanged. MLP neurons are a privileged basis, because the elementwise nonlinearity acts on each coordinate separately, but superposition still smears features across them.
How much room is there? In high dimensions, random directions are nearly orthogonal: the cosine between two random unit vectors in \(d\) dimensions has standard deviation \(1/\sqrt d\), and the number of directions you can fit with all pairwise overlaps below \(\varepsilon\) grows exponentially in \(d\varepsilon^2\). A residual stream of a few thousand dimensions can host vastly more nearly orthogonal feature directions than it has dimensions; the code below puts 4,096 random directions in 1,024 dimensions with no pair closer than cosine 0.16.
Sparse autoencoders: dictionary learning for activations¶
If activations are sparse combinations of many feature directions, \(x \approx b + \sum_i f_i\, \mathbf{d}_i\) with most \(f_i = 0\), then finding the \(\mathbf d_i\) is sparse dictionary learning, a problem neuroscience and signal processing have studied since the 1990s. A sparse autoencoder (SAE) learns it with a wide, one-hidden-layer network:
The decoder's columns are the learned feature directions, the encoder computes how much of each is present, and the sparsity penalty forces each activation to be explained by few features. Two 2023 papers showed it works on real language models. Cunningham et al. found SAE features more interpretable than neurons and other decompositions, and used them to localise behaviour in the indirect-object task. Anthropic's Towards Monosemanticity (Bricken et al., 2023) trained SAEs on the 512-neuron MLP layer of a one-layer transformer, using 8 billion samples of its MLP activations, with dictionaries from 512 to 131,072 features. Its detailed 4,096-feature run found features for Arabic script, DNA sequences, base64 strings and Hebrew, many of them not visible in any single neuron; pinning a feature on steered generation (the base64 feature made the model write base64). Of those 4,096 features, 168 were "dead" (never active on 100 million examples).
The next steps were about scale.
- Claude 3 Sonnet (Templeton et al., 2024). SAEs with about 1M, 4M and 34M features on the residual stream at the model's middle layer. On average fewer than 300 features were active per token, and the reconstructions explained at least 65% of the activations' variance. Features were often multilingual and multimodal, and included safety-relevant ones: unsafe code, backdoors, bias, deception and power-seeking, sycophancy, dangerous content. Clamping a "Golden Gate Bridge" feature to ten times its maximum made the model start describing itself as the bridge. The cost of scale was visible too: about 2%, 35% and 65% of features were dead in the 1M, 4M and 34M SAEs.
- GPT-4 (Gao et al., 2024). TopK SAEs keep exactly the \(k\) largest pre-activations, which sets sparsity directly instead of tuning an L1 weight; with training changes that keep few latents dead, the authors found clean scaling laws and trained a 16-million-latent SAE on GPT-4 activations for 40 billion tokens.
- Better activations. Gated SAEs (Rajamanoharan et al., 2024) and JumpReLU SAEs (Rajamanoharan et al., 2024) separate the decision "is this feature on?" from "how strongly?", fixing the L1 penalty's systematic shrinkage (derived below). Gemma Scope released JumpReLU SAEs for every layer and sub-layer of Gemma 2 2B and 9B (Lieberum et al., 2024), browsable on Neuronpedia.
How do you know an SAE is good? There is no ground truth, so people use proxies: reconstruction (fraction of variance unexplained, or better, how much the model's loss rises when the SAE's reconstruction replaces the real activation), sparsity (\(L_0\), the average number of active features), interpretability (often scored automatically: an LLM writes an explanation of a feature from its top activations and then predicts activations from the explanation, as in Bills et al., 2023 and Paulo et al., 2024), and usefulness on downstream tasks (SAEBench). The proxies trade off, and the frontier between reconstruction and sparsity is the curve the code below traces.
Features are not uniquely defined
Train a larger SAE and a feature often splits: one "mathematics" feature becomes several for different branches. Which size is "right"? Towards Monosemanticity described different sizes as different resolutions of the same object. Leask et al. argue more strongly that SAEs do not find canonical units of analysis at all (2025). Treat a feature as a useful, testable variable, not as a natural kind the model "really" uses.
Circuits: proving that a component matters¶
Seeing a feature light up is correlational. To show a component causes a behaviour you intervene. The workhorse is activation patching (also called causal tracing or interchange intervention): run the model on a clean prompt and on a corrupted one that changes the answer, then copy one component's activation from one run into the other and measure how much the output moves.
- Causal tracing of facts. Meng et al. corrupted the subject of a factual prompt and restored activations one at a time, finding that mid-layer MLPs at the subject's last token carry the fact; they then edited one such MLP with a rank-one update to change the fact (ROME) (2022).
- Indirect object identification. In "When Mary and John went to the store, John gave a drink to", GPT-2 small predicts "Mary". Wang et al. explained this with 26 attention heads in 7 classes (heads that detect the duplicated name, heads that inhibit it, heads that move the remaining name to the output), validated by faithfulness, completeness and minimality tests (2022).
- Automation. Patching every component is expensive. ACDC prunes edges of the computational graph automatically (Conmy et al., 2023), and attribution patching replaces each patch with a first-order Taylor estimate from one backward pass (Nanda, 2023; Syed et al., 2023). Getting patching right involves real methodological choices, such as how to corrupt and which metric to use (Zhang and Nanda, 2023; Heimersheim and Nanda, 2024).
Circuits over heads and neurons inherit polysemanticity. The 2024–2025 move was to build circuits over features: sparse feature circuits (Marks et al., 2024), transcoders, which replace an MLP with a wider, sparse MLP that imitates it so that circuits can be read through the MLP's weights (Dunefsky et al., 2024), and cross-layer transcoders. Anthropic's Circuit Tracing (Ameisen et al., 2025) replaces all of a model's MLPs with a cross-layer transcoder to get an interpretable "replacement model", then computes an attribution graph for a single prompt: which features caused which, ending at the output. The companion On the Biology of a Large Language Model (Lindsey et al., 2025) applied it to Claude 3.5 Haiku:
- Two-hop reasoning in one forward pass. For "the capital of the state containing Dallas is", the graph shows an internal "Texas" step alongside a direct shortcut. Swapping the "Texas" features for "California" features taken from an Oakland prompt made the model answer "Sacramento".
- Planning. Writing a rhyming couplet ending "…grab it", the model represents candidate rhyming words such as "rabbit" at the newline before writing the second line, and intervening on those features changes how the line ends.
- Arithmetic. Adding 36 + 59, the model runs parallel pathways, one estimating the rough magnitude and one computing the last digit, and combines them.
The authors are explicit about limits: the replacement model is an approximation, attention is only partly explained, and they found satisfying insight for "about a quarter" of the prompts they tried. The tooling has been released as open-source circuit-tracer with graphs on Neuronpedia.
What interpretability is used for¶
- Steering. Add a feature or a direction to the residual stream to change behaviour: the Golden Gate demo, activation addition (Turner et al., 2023), inference-time intervention for truthfulness (Li et al., 2023).
- Removing behaviours. Directional ablation of the refusal direction disables refusals, which is a jailbreak for open-weight models and a warning about how shallow safety training can be (Arditi et al., 2024). The same localisation helps targeted editing and unlearning (Guo et al., 2024).
- Monitoring. Linear probes on activations are cheap detectors for harmful intent or deception, and can run on every request.
- Model diffing. Crosscoders learn features shared across two models (for example a base model and its chat version) to see what fine-tuning changed (Anthropic, 2024).
- Science of models. Grokking was explained by reverse-engineering a small transformer that learned modular addition with discrete Fourier transforms and trigonometric identities (Nanda et al., 2023). Anthropic reported that Claude Opus 4 and 4.1 noticed a concept injected into their activations about 20% of the time under the right conditions, a limited and unreliable form of introspective access (Lindsey, 2025).
The state of the field, and the doubts¶
As of 2026, three lines of criticism shape research priorities:
- Do SAEs beat simple baselines? Google DeepMind's interpretability team reported that SAE features did worse than plain linear probes at detecting harmful intent out of distribution, and announced in March 2025 that it was deprioritising fundamental SAE research while keeping SAEs as one tool among several (Smith et al., 2025). Kantamneni et al. found that SAE-based probes did not consistently beat baselines across data-scarce, imbalanced, noisy and shifted settings (2025).
- Is the dark matter large? An SAE whose reconstruction explains, say, 65% of the variance leaves a residual that still matters to the model's loss, and a mechanism that ignores it may be incomplete.
- Are explanations faithful and complete? A circuit that reproduces a behaviour on a handful of prompts may not be how the model computes it on others; attribution graphs work for a minority of prompts.
The response is a mix of better decompositions, end-to-end training of dictionaries on what matters to the model's output (Braun et al., 2024), and different bets: OpenAI trained weight-sparse transformers, in which most weights are zero, whose task circuits were about 16 times smaller than those of dense models of comparable loss, while noting that scaling the approach beyond tens of millions of non-zero parameters remains hard (Gao et al., 2025). The field's own map of what is unsolved is Open Problems in Mechanistic Interpretability (Sharkey et al., 2025).
Hold this picture
A model is a stack of linear maps that add into one shared vector, punctuated by nonlinearities. Inside that vector live far more nearly orthogonal feature directions than there are dimensions, each rarely active. An SAE is a microscope that separates the overlapping directions; patching and steering are the experiments that test whether what you see is what the model uses.
History¶
Interpretability began with vision: saliency maps (Simonyan et al., 2013) and deconvolution visualisations (Zeiler and Fergus, 2013), then feature visualisation by optimisation (Olah et al., 2017). Lipton's Mythos of Model Interpretability (2016, arXiv) asked what the word even meant. The circuits programme started on InceptionV1 in Zoom In (2020) and moved to transformers with the 2021 Mathematical Framework and the 2022 papers on induction heads, superposition, IOI and ROME. Neel Nanda's open problems lists, the TransformerLens library and the ARENA curriculum turned it into a field many people could enter. 2023 brought sparse autoencoders; 2024 scaled them to production models (Claude 3 Sonnet, GPT-4) and released open suites (Gemma Scope); 2025 brought attribution graphs, the first serious negative results on SAEs, and alternative bets such as weight-sparse models.
First principles¶
Why should a trained network be interpretable at all?¶
Nothing forces it to be. But three pressures push towards structure we can read. Linear readout: downstream layers read the residual stream through linear maps, so information a later layer needs is cheapest to provide as a linearly decodable direction. Compression: the world has far more concepts than a layer has dimensions, and most are rare in any given context, which is exactly the regime where superposition is efficient. Reuse: gradient descent finds components that help on many inputs; a general mechanism (an induction head) beats memorising each case once the data contains enough instances, which is what the induction-head phase change and grokking show.
Why superposition happens: a cost–benefit argument¶
Representing a feature has a benefit proportional to how often it is active and how important it is. Giving two features overlapping directions has a cost only when both are active, because that is when one corrupts the other's readout. If each feature is active with probability \(p = 1 - S\) (\(S\) is sparsity), the benefit of adding a feature scales like \(p\) while the expected interference cost scales like \(p^2\). As features get sparser (\(p \to 0\)), the cost falls faster than the benefit, and at some point it pays to squeeze in more features than dimensions. The ReLU helps by filtering small, negative interference to zero. This is why the toy model shows a phase change from "drop the extra features" to "superpose them" as sparsity rises.
Correlation is not mechanism¶
A feature that activates on deceptive text is not evidence that the model is deceiving; it may just represent the concept, as Templeton et al. warned. The standard of evidence is interventional: if the story says component \(c\) computes variable \(v\) that causes behaviour \(b\), then setting \(c\) to the value it takes when \(v\) is different must change \(b\) accordingly, and removing everything outside the claimed circuit must leave \(b\) intact (faithfulness and completeness).
The maths¶
Attention heads as QK and OV circuits¶
Use column vectors. For head \(h\) with \(W_Q^h, W_K^h, W_V^h \in \mathbb R^{d_h\times d}\) and \(W_O^h\in\mathbb R^{d\times d_h}\), the attention score from destination \(i\) to source \(j\) is
and the head adds to position \(i\)
\(W_{QK}^h\) is a bilinear form deciding which source a destination attends to; \(W_{OV}^h\) is a linear map deciding what is written once it does. Both are \(d\times d\) with rank \(\le d_h\).
For a one-layer attention-only transformer with token one-hot \(t\), embedding \(W_E\) and unembedding \(W_U\), stacking positions gives the logits as a sum of paths:
The matrices \(W_U W_E\) and \(W_U W_{OV}^h W_E\) are vocabulary-by-vocabulary tables you can read directly. With two layers, a layer-2 head's keys can read a layer-1 head's output: \(W_{QK}^{h_2}\) acts on \(W_{OV}^{h_1} W_E t\) instead of \(W_E t\). That is K-composition, and the induction head is its canonical example.
The superposition toy model¶
Features \(x\in[0,1]^n\), each zero with probability \(S\) and otherwise uniform; importances \(I_i\); a projection \(W\in\mathbb R^{m\times n}\) with columns \(W_i\) (feature directions), \(m<n\):
The reconstruction of feature \(i\) is \(\operatorname{ReLU}\big(\|W_i\|^2 x_i + \sum_{j\ne i} (W_i\cdot W_j)\, x_j + b_i\big)\). The sum is the interference term. If \(W^\top W\) is invertible there is no superposition; superposition means \(W^\top W\) is not invertible, so more than \(m\) features share \(m\) dimensions.
How many nearly orthogonal directions fit?¶
For independent uniformly random unit vectors \(u, v \in \mathbb R^d\), \(u\cdot v\) has mean 0 and variance \(1/d\), and it concentrates: \(\Pr[|u\cdot v| > \varepsilon] \le 2e^{-d\varepsilon^2/2}\). A union bound over all \(\binom{m}{2} < m^2/2\) pairs shows that \(m\) random directions are pairwise \(\varepsilon\)-orthogonal with positive probability whenever \(m^2 e^{-d\varepsilon^2/2} < 1\), that is, for
The count grows exponentially in the dimension (this is the Johnson–Lindenstrauss phenomenon). The bound is loose; the simulation in Build it finds 4,096 directions in 1,024 dimensions with maximum overlap 0.16, far better than the bound promises. The mean absolute cosine, \(\sqrt{2/(\pi d)}\), matches the simulation to three decimals (\(0.025\) at \(d = 1024\)).
The SAE objective and L1 shrinkage¶
With \(x\in\mathbb R^d\), encoder \(W_{\text{enc}}\in\mathbb R^{m\times d}\), decoder \(W_{\text{dec}}\in\mathbb R^{d\times m}\) (columns \(\mathbf d_i\), the feature directions):
The \(\|\mathbf d_i\|\) factor (used by Templeton et al.) stops the model from cheating the L1 penalty by shrinking \(f\) and growing \(\mathbf d_i\); the alternative is to fix \(\|\mathbf d_i\| = 1\), as the code below does.
Derivation: the L1 penalty shrinks every active feature by λ/2
Take an input that is exactly one feature with magnitude \(a > 0\), \(x = a\,\mathbf d_i\), with unit-norm \(\mathbf d_i\), and suppose only latent \(i\) is active. The loss as a function of its activation \(f \ge 0\) is
Setting \(\ell'(f) = -2(a-f) + \lambda = 0\) gives
the soft-thresholding operator. Every active feature is under-estimated by \(\lambda/2\), and features weaker than \(\lambda/2\) are switched off entirely. That is the trade-off in Build it: raising \(\lambda\) improves sparsity and feature recovery but inflates reconstruction error, because magnitudes are biased low. TopK and JumpReLU SAEs decouple whether a feature fires (a threshold or rank) from how much (the unpenalised magnitude), removing the shrinkage. JumpReLU uses \(f = z\cdot\mathbb 1[z > \theta]\) and an \(L_0\) penalty trained with straight-through estimators.
Activation patching and its linear approximation¶
Let \(m(\cdot)\) be a metric on the output (say, logit difference between the right and wrong answer), \(a^{\text{clean}}\) and \(a^{\text{corr}}\) a component's activations on the clean and corrupted prompts. Activation patching measures
Doing this for every component costs one forward pass each. Attribution patching takes a first-order Taylor expansion around the corrupted run:
so one forward and one backward pass score every component at once. It is accurate when the patch is a small change and breaks down where the metric is saturated or the component's effect is strongly nonlinear (for example, through attention's softmax).
Directions: difference of means and ablation¶
Given activations on two prompt sets, the candidate direction is
which is the maximum-likelihood discriminant direction when the two classes are Gaussian with equal, isotropic covariance. Directional ablation removes it from every activation,
a projection onto the orthogonal complement; steering adds \(\alpha \hat r\). Arditi et al. apply the projection at every layer and position, and also orthogonalise the weights that write to the residual stream, \(W \leftarrow (I - \hat r\hat r^\top) W\), so the edit is permanent.
Build it¶
Three NumPy experiments: the geometry that makes superposition possible, a sparse autoencoder that recovers features PCA cannot, and finding and ablating a behaviour direction.
1. How many nearly orthogonal directions fit in d dimensions?
import numpy as np
rng = np.random.default_rng(0)
# How orthogonal are random directions? m unit vectors in d dimensions.
for d in (16, 128, 1024):
m = 4 * d # four times more directions than dimensions
W = rng.standard_normal((m, d))
W /= np.linalg.norm(W, axis=1, keepdims=True)
G = W @ W.T
off = np.abs(G[~np.eye(m, dtype=bool)])
print(f"d={d:5d} m={m:6d} mean|cos|={off.mean():.3f} "
f"max|cos|={off.max():.3f} 1/sqrt(d)={1/np.sqrt(d):.3f}")
d= 16 m= 64 mean|cos|=0.202 max|cos|=0.774 1/sqrt(d)=0.250
d= 128 m= 512 mean|cos|=0.071 max|cos|=0.371 1/sqrt(d)=0.088
d= 1024 m= 4096 mean|cos|=0.025 max|cos|=0.160 1/sqrt(d)=0.031
In 16 dimensions, 64 directions collide badly; in 1,024 dimensions, 4,096 directions never overlap by more than 0.16.
2. A sparse autoencoder recovers superposed features. Forty-eight ground-truth feature directions are squeezed into 16 dimensions, each feature active 4% of the time. We train SAEs with 96 latents at four sparsity penalties and compare with PCA.
import numpy as np
rng = np.random.default_rng(0)
d, F, m = 16, 48, 96 # 48 true features squeezed into 16 dims; SAE with 96 latents
V = rng.standard_normal((F, d)); V /= np.linalg.norm(V, axis=1, keepdims=True)
def batch(B): # each feature fires 4% of the time with size in [0.5, 1.5]
on = rng.random((B, F)) < 0.04
return (on * rng.uniform(0.5, 1.5, (B, F))) @ V
def train_sae(lam, steps=6000, lr=3e-3, B=512):
P = {"We": rng.standard_normal((m, d)) * 0.3, "be": np.zeros(m),
"Wd": rng.standard_normal((d, m)), "bd": np.zeros(d)}
P["Wd"] /= np.linalg.norm(P["Wd"], axis=0)
M = {k: 0 * v for k, v in P.items()}; S = {k: 0 * v for k, v in P.items()}
for t in range(1, steps + 1): # Adam on ||x - x_hat||^2 + lam * sum_i f_i
x = batch(B); xc = x - P["bd"]
pre = xc @ P["We"].T + P["be"]; f = np.maximum(pre, 0)
dx = 2 * (f @ P["Wd"].T + P["bd"] - x) / B
df = (dx @ P["Wd"] + lam / B) * (pre > 0)
G = {"Wd": dx.T @ f, "We": df.T @ xc, "be": df.sum(0),
"bd": dx.sum(0) - (df @ P["We"]).sum(0)}
for k in P:
M[k] = 0.9 * M[k] + 0.1 * G[k]; S[k] = 0.999 * S[k] + 0.001 * G[k] ** 2
P[k] -= lr * (M[k] / (1 - 0.9**t)) / (np.sqrt(S[k] / (1 - 0.999**t)) + 1e-8)
P["Wd"] /= np.linalg.norm(P["Wd"], axis=0) # unit-norm decoder columns
return P
x = batch(20000)
_, _, pcs = np.linalg.svd(x - x.mean(0), full_matrices=False)
print(f"PCA (16 directions): true features with a match cos>0.9: "
f"{np.mean(np.abs(V @ pcs.T).max(1) > 0.9):.0%}")
print(f"true features active per input: {0.04 * F:.2f}")
print("lambda L0 FVU recovered(cos>0.9) median best cos")
for lam in (0.05, 0.2, 0.5, 1.0):
P = train_sae(lam)
f = np.maximum((x - P["bd"]) @ P["We"].T + P["be"], 0)
fvu = ((x - f @ P["Wd"].T - P["bd"]) ** 2).sum() / ((x - x.mean(0)) ** 2).sum()
best = np.abs(V @ P["Wd"]).max(axis=1) # each true feature's best latent
print(f"{lam:5.2f} {(f > 0).sum(1).mean():5.2f} {fvu:.3f} {np.mean(best > 0.9):12.0%}"
f" {np.median(best):15.3f}")
PCA (16 directions): true features with a match cos>0.9: 0%
true features active per input: 1.92
lambda L0 FVU recovered(cos>0.9) median best cos
0.05 18.46 0.006 4% 0.762
0.20 10.91 0.068 44% 0.884
0.50 4.29 0.187 90% 0.966
1.00 2.43 0.376 92% 0.952
Read the table as the whole SAE story in miniature. PCA finds the 16 directions of greatest variance, none of which is a feature. A weakly penalised SAE reconstructs almost perfectly (FVU 0.006) with 18 active latents per input, smearing each true feature across many latents: good reconstruction, no interpretability. As \(\lambda\) rises, \(L_0\) approaches the true 1.92 features per input and 90% or more of the features are recovered almost exactly. But reconstruction gets worse, because the L1 penalty shrinks every magnitude by \(\lambda/2\): at \(\lambda = 1\) that is 0.5, a third of a typical feature's size. That shrinkage is what TopK and JumpReLU SAEs remove.
3. Find a behaviour direction and ablate it. Synthetic "residual stream" activations for harmful and harmless prompts, with a downstream readout that triggers a refusal.
import numpy as np
rng = np.random.default_rng(5)
d, n = 256, 500
r_true = rng.standard_normal(d); r_true /= np.linalg.norm(r_true) # the model's "refusal" direction
def acts(harmful, n): # residual-stream activations: noise + concept along r_true
x = rng.standard_normal((n, d))
return x + (4.0 if harmful else 0.0) * r_true
readout = r_true + 0.3 * rng.standard_normal(d) / np.sqrt(d) # downstream "refuse" logit
refuses = lambda X: np.mean(X @ readout > 2.0)
Xh, Xb = acts(True, n), acts(False, n)
r_hat = Xh.mean(0) - Xb.mean(0) # difference of means: no training at all
r_hat /= np.linalg.norm(r_hat)
print(f"cos(r_hat, r_true) = {r_hat @ r_true:.3f}")
# A linear probe would also find it; difference-of-means is the closed-form, causal-friendly one
print(f"refusal rate harmful: {refuses(Xh):.0%} harmless: {refuses(Xb):.0%}")
ablate = lambda X: X - np.outer(X @ r_hat, r_hat) # project the direction out
print(f"after ablating r_hat harmful: {refuses(ablate(Xh)):.0%}")
print(f"after adding 4*r_hat harmless: {refuses(Xb + 4 * r_hat):.0%}")
rand = rng.standard_normal(d); rand /= np.linalg.norm(rand)
print(f"control: ablate a random direction, harmful: "
f"{refuses(Xh - np.outer(Xh @ rand, rand)):.0%}")
cos(r_hat, r_true) = 0.968
refusal rate harmful: 98% harmless: 3%
after ablating r_hat harmful: 0%
after adding 4*r_hat harmless: 96%
control: ablate a random direction, harmful: 98%
The control matters as much as the result: ablating a random direction does nothing, so the effect is specific to the direction found.
Things to try:
- In experiment 2, raise feature density from 4% to 20%. Superposition stops paying and the SAE struggles: features co-occur too often to be separated.
- Replace the ReLU with TopK (keep the 2 largest pre-activations, no L1 term) and compare FVU and recovery with the \(\lambda = 0.5\) row.
- Give the 48 features different importances and frequencies; which ones does a small SAE (\(m = 32\)) drop first?
- In experiment 3, add a second, correlated concept direction. How does the difference of means mix them, and does ablation now damage the other behaviour?
- With a real model, TransformerLens or nnsight let you hook GPT-2 small's residual stream and repeat experiment 3 on real prompts.
In practice¶
- Start with cheap tools. Logit lens, direct logit attribution and attention patterns answer many questions in minutes. Reach for SAEs when you need variables nobody labelled in advance.
- Prefer probes for known concepts. If you know what you are looking for (harmful intent, a language, a topic), a linear probe or difference of means is cheaper and, on current evidence, often better than searching SAE features.
- Use pre-trained dictionaries. Gemma Scope and other open SAEs, browsable on Neuronpedia, and SAELens for training your own.
- Always intervene. Activation and attribution patching, ablation and steering, each with a random-direction or random-component control.
- Check the reconstruction cost. Splice the SAE into the forward pass and measure the loss increase; an SAE that hurts the model a lot is explaining a different model.
- Expect partial answers. A circuit that explains 80% of a behaviour on your prompt set is a good result; say what the remaining 20% might be.
Common misconceptions¶
- "Attention weights explain the model." They show where information moved, not what was moved or whether it mattered; the OV circuit and downstream use matter as much.
- "One neuron, one concept." Most neurons are polysemantic because of superposition; features are directions, usually not neurons.
- "An SAE feature is what the model really uses." It is a variable in a learned approximation. Feature sets change with dictionary size and training run, and some of the model's computation lives in what the SAE fails to reconstruct.
- "A probe that decodes X means the model uses X." It means X is linearly decodable. Use interventions to show use.
- "Interpretability is just for safety researchers." Steering, editing, debugging data problems and monitoring are engineering uses, and probes are already cheap production monitors.
Check yourself¶
Why does a two-layer attention-only transformer have capabilities a one-layer one cannot, in the residual-stream picture?
In one layer every head reads only token embeddings, so it can implement bigram-like and skip-trigram rules. In two layers, a layer-2 head's queries, keys or values can read what a layer-1 head wrote (composition). An induction head needs K-composition: its keys must encode "which token preceded this position", information that only exists after a layer-1 previous-token head has written it.
In the superposition toy model, why does sparsity make it worthwhile to store more features than dimensions?
Interference between two overlapping features only costs loss when both are active, which happens with probability about \(p^2\), while the benefit of representing each feature scales with \(p\). As \(p \to 0\) the benefit dominates, so the model packs in extra features along nearly orthogonal directions and uses ReLU with a negative bias to filter small interference.
Derive the activation an L1-penalised SAE assigns to a single unit-norm feature of true magnitude a, and explain why TopK SAEs avoid the problem.
Minimise \((a-f)^2 + \lambda f\) over \(f\ge 0\): \(f^\star = \max(0, a-\lambda/2)\), so magnitudes are biased low by \(\lambda/2\) and weak features vanish. TopK chooses which latents are active by rank and applies no penalty to their magnitude, so active features are estimated without shrinkage; sparsity is set by \(k\) instead of \(\lambda\).
You find an SAE feature that fires on text about lying. Does the model lie? What experiment would tell you more?
The feature shows the model represents the concept, not that it uses it to produce deceptive outputs. Test causally: find prompts where the model's output is false although it 'knows' the truth (probe or ground truth), measure the feature there, then ablate or clamp it and check whether the false outputs change, with a random-feature control.
Why is the residual stream's basis not privileged, while an MLP's hidden layer is?
The residual stream is only read and written by linear maps, so applying a rotation \(R\) to it and replacing every adjacent weight \(W\) by \(RW\) or \(WR^\top\) gives an identical network: no coordinate is special. The MLP applies an elementwise nonlinearity, which is not invariant to rotation, so its coordinates (neurons) carry meaning in the computation. (Normalisation layers and optimisers like Adam can break the residual stream's symmetry slightly in practice.)
Attribution patching estimated a head's effect at nearly zero, but activation patching shows it is large. What happened?
Attribution patching is a first-order approximation around the corrupted run. If the head's effect passes through a saturated nonlinearity (a softmax near 0 or 1, a ReLU just below its threshold), the local gradient is near zero even though a full change of activation has a large effect. Use full patching for the components that matter, or integrate the gradient along the path (as integrated gradients does).
Why did the difference-of-means direction in experiment 3 need a random-direction control, and what would a real-model version need beyond it?
Ablating any direction removes some variance and could reduce the readout by chance; the control shows the effect is specific. In a real model you would also check that ablation does not damage unrelated capabilities (perplexity, benchmark scores), test on held-out prompts, and check that adding the direction induces the behaviour on harmless prompts.
Name two concrete reasons the field moved some effort away from SAEs in 2025, and two things SAEs are still good for.
Reasons: SAE-based probes did not beat simple linear probes for detecting harmful intent out of distribution (GDM, 2025) or across difficult probing regimes (Kantamneni et al.); features are not canonical across dictionary sizes; reconstruction leaves important "dark matter". Still good for: unsupervised discovery of unexpected variables (no labels needed), building feature circuits and attribution graphs, debugging datasets, and model diffing with crosscoders.
Go deeper¶
Papers
- A Mathematical Framework for Transformer Circuits — Elhage et al., 2021. The residual-stream view, QK/OV circuits and composition. Read the one- and two-layer sections slowly.
- In-context Learning and Induction Heads — Olsson et al., 2022. Six lines of evidence; a model of how to argue for a mechanism.
- Toy Models of Superposition — Elhage et al., 2022. Why neurons are polysemantic; the first half is essential, the geometry sections are optional.
- Towards Monosemanticity — Bricken et al., 2023. SAEs on a one-layer model, with detailed feature case studies.
- Scaling Monosemanticity — Templeton et al., 2024. SAEs on Claude 3 Sonnet; safety-relevant features and steering.
- Scaling and evaluating sparse autoencoders — Gao et al., 2024. TopK SAEs, scaling laws and new evaluation metrics.
- Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small — Wang et al., 2022. The classic circuit paper and its faithfulness, completeness, minimality tests.
- Locating and Editing Factual Associations in GPT — Meng et al., 2022. Causal tracing and ROME.
- Circuit Tracing and On the Biology of a Large Language Model — Ameisen, Lindsey et al., 2025. Cross-layer transcoders, attribution graphs and case studies on Claude 3.5 Haiku.
- Refusal in Language Models Is Mediated by a Single Direction — Arditi et al., 2024. The cleanest demonstration that a linear direction controls a safety behaviour.
- Progress measures for grokking via mechanistic interpretability — Nanda et al., 2023. A complete reverse-engineering of a learned algorithm.
- Open Problems in Mechanistic Interpretability — Sharkey et al., 2025. The field's own map of what is unsolved.
Videos and lectures
- A Walkthrough of A Mathematical Framework for Transformer Circuits — Neel Nanda. Three hours with one of the authors; pair with the paper.
- An Introduction to Mechanistic Interpretability — Neel Nanda, IASEAI 2025. The field's state and open questions in one talk.
- How might LLMs store facts — 3Blue1Brown, Deep Learning Chapter 7. MLPs as fact stores and superposition, beautifully animated.
- Tracing the thoughts of a large language model — Anthropic. A short visual tour of attribution graphs.
Articles and blog posts
- Zoom In: An Introduction to Circuits — Olah et al., 2020. The founding essay: features, circuits, universality.
- A Comprehensive Mechanistic Interpretability Explainer and Glossary — Neel Nanda. Every term on this page and many more.
- Negative Results for SAEs On Downstream Tasks — Smith, Rajamanoharan et al. (Google DeepMind), 2025. Why one major team changed priorities.
- Mechanistic Interpretability, Variables, and the Importance of Interpretable Bases — Chris Olah, 2022. A short essay on why the basis question is the central one.
Courses
- ARENA — The standard hands-on curriculum; its transformer-interpretability chapter takes you from TransformerLens to circuits and SAEs.
- How to become a mechanistic interpretability researcher — Neel Nanda, 2025. A reading and project path: learn the minimum basics, then do mini-projects.
Code
- TransformerLens — Hooks into every activation of GPT-2-style models; the default library for circuit work.
- SAELens — Train and load sparse autoencoders.
- circuit-tracer — Attribution graphs on open models.
- Neuronpedia — Browse SAE features and attribution graphs for open models.
Where this leads¶
- The alignment problem: why being able to read a model's internals matters for knowing whether it is aligned.
- Red-teaming and dangerous-capability evals: behavioural testing, the complement to looking inside.
- Reward models and Constitutional AI: the training that installs the behaviours (like refusal) that interpretability then finds.
- Open problems: where interpretability sits among the field's unsolved questions.