Dictionary Learning at Scale
Superposition, sparse autoencoder variants and transcoders, and how to evaluate the features they find.
In 2023 a sparse autoencoder turned the 512 neurons of a one-layer transformer's MLP into thousands of features, for things like Arabic script and base64 text. Within a year the method ran on the middle layer of a production language model with dictionaries of up to 34 million features, and an autoencoder with 16 million latents was trained on GPT-4's activations. This lesson asks how much room superposition leaves, how such dictionaries are trained and improved, how transcoders and attribution graphs turn features into circuits, and how anyone can tell whether the features are the model's own.
What you’ll learn
- Prove that exponentially many almost-orthogonal directions fit in dimensions, and state the compressed-sensing limit on how many sparse features a layer can carry.
- Describe how sparse autoencoders are trained at scale (dictionary size, dead latents, scaling laws), and compute their size and the concept frequency a dictionary can resolve.
- Compare L1, TopK, gated and JumpReLU autoencoders, and derive the JumpReLU threshold's pseudo-gradient as a kernel density estimate.
- Explain transcoders, crosscoders and attribution graphs, and why replacing MLPs makes feature-to-feature attributions input-invariant.
- Evaluate dictionaries by reconstruction, sparsity, interpretability and downstream use, and weigh the evidence on splitting, absorption, seed dependence and simple baselines.
How many features fit?
The superposition hypothesis (Elhage et al., 2022) says a layer of width represents many more than sparse features, each along its own direction, accepting interference between them. Interpretability: Looking Inside Networks showed it happening in a toy model, and the Artificial Intelligence course's lesson Mechanistic Interpretability derives when sharing a dimension beats dropping a feature. The question here is quantitative: how much room is there? Exact orthogonality allows only directions, but interference only needs to be small.
Measure concentration on the sphere (Ball, 1997, Lemma 2.2): for uniform on the unit sphere of and any fixed unit vector , the cap where has probability at most . By symmetry,
Draw independent uniform unit vectors. A union bound over the pairs bounds the chance that any pair is too close:
A random draw therefore succeeds with positive probability, so such a set exists. For and the guarantee is directions, 22 times the dimension, and the random construction is far from the best packing. Interference, though, still adds up: a readout of one feature picks up a little of every other active feature, which is why sparsity matters.
How many features can a layer carry and recover? Compressed sensing answers for the strongest possible decoder: an -dimensional vector with nonzero entries can be recovered from linear measurements, in various standard settings, only if . Elhage et al. applied such a bound to their toy model. If each of features is active with probability , about are active at once, and the bound becomes
The number of features is linear in the width, with a factor that grows as features get sparser: up to constants, about at , at and at . A network reads features with a few linear maps and nonlinearities, not an optimization algorithm, so this is a ceiling, not an estimate. Where Scaling Laws Come From shows how strong superposition can make a language model's loss fall like in its width.
Training dictionaries at scale
A sparse autoencoder learns an overcomplete dictionary, , from a layer's recorded activations (Interpretability: Looking Inside Networks gives the objective; the Artificial Intelligence course derives the shrinkage its L1 penalty causes). Four papers set the pace.
- Bricken et al. (2023), the 512-neuron MLP of a one-layer transformer: dictionaries of 512 to 131,072 latents trained on 8 billion activations. Latents that stopped firing were periodically resampled. Features split into finer families as the dictionary grew (one base64 feature became three), and dictionaries trained on two different transformers found mostly similar features, more similar to each other than to either model's neurons.
- Cunningham, Ewart, Riggs, Huben & Sharkey (2024), activations of small open language models such as Pythia-70M (residual stream, MLP or attention outputs): dictionary features scored as more interpretable, by automated methods, than directions from PCA, ICA or the neurons themselves, and pinpointed the features responsible for indirect-object behavior more finely than a PCA decomposition did.
- Templeton et al. (2024), the middle-layer residual stream of the production model Claude 3 Sonnet: dictionaries of 1,048,576, 4,194,304 and 33,554,432 features, with fewer than 300 active per token on average and at least 65% of the variance explained. Features were often multilingual, multimodal and abstract, and clamping one steered the model. About 2%, 35% and 65% of the three dictionaries' features were dead (never active in tokens).
- Gao et al. (2025), TopK autoencoders: a 16-million-latent dictionary trained on GPT-4 activations for 40 billion tokens. Without countermeasures up to 90% of latents died; initializing the encoder as the decoder's transpose and adding an auxiliary loss that makes dead latents model the reconstruction error left only 7% dead. Reconstruction error then followed clean power laws in the number of latents and the number of active latents .
A sparse autoencoder on GPT-2 small's residual stream (width 768) has an expansion factor of 32: 32 latents per dimension. How many million weights do its encoder and decoder have together, ignoring biases?
Show the answer
37.7 million
The dictionary has latents. Encoder and decoder are each , so weights, about 37.7 million: roughly 30% of the whole of GPT-2 small (about 124 million parameters), for one layer. Dictionaries for every layer of a model, or with millions of latents, cost more to train and store than the model they explain.
What a bigger dictionary buys. Templeton et al. measured which concepts (chemical elements, cities, animals, foods) had a dedicated feature. The frequency in the training data at which a dictionary became more than 50% likely to contain a concept was consistently slightly lower than the inverse of its number of alive features; the 34-million dictionary had only about 12 million. A concept that appears once per billion tokens may need on the order of a billion alive features before one is devoted to it, although a smaller dictionary can still represent it by combining related features.
import torch
import torch.nn as nn
import torch.nn.functional as F
class TopKSAE(nn.Module):
def __init__(self, d, n_latents, k):
super().__init__()
self.k = k
self.W_dec = nn.Parameter(F.normalize(torch.randn(n_latents, d), dim=1))
self.W_enc = nn.Parameter(self.W_dec.data.T.clone()) # encoder starts as the decoder's transpose
self.b_enc = nn.Parameter(torch.zeros(n_latents))
self.b_dec = nn.Parameter(torch.zeros(d))
def forward(self, x):
pre = (x - self.b_dec) @ self.W_enc + self.b_enc # (batch, n_latents)
top = pre.topk(self.k, dim=-1) # keep the k largest, zero the rest
f = torch.zeros_like(pre).scatter(-1, top.indices, F.relu(top.values))
return f @ self.W_dec + self.b_dec, fTrain on the reconstruction error alone: sparsity is enforced by the selection, , so no penalty shrinks the active latents. Renormalize the rows of W_dec after each step. On synthetic data like the toy model's, 48 sparse directions in 16 dimensions, and 128 latents recover all 48 directions. Gao et al. also add the auxiliary loss on dead latents described above.
A concept occurs about once every 10 million tokens in the training data. By Templeton et al.'s finding, roughly how large must a dictionary be before it is likely to contain a feature dedicated to that concept?
- About 10,000 features, since features are shared across concepts
- About 10 million alive features, which can take a dictionary several times that size if many latents die
- About 10 billion features, a thousand times the inverse frequency
- Any size, since dictionary features do not depend on frequency
Show the answer
B. About 10 million alive features, which can take a dictionary several times that size if many latents die
The 50% threshold frequency sat slightly below the inverse of the number of alive features, consistently across concept categories and dictionary sizes. Dead latents do not count: the 34-million dictionary had about 12 million alive, so it resolved concepts down to roughly one in 12 million tokens.
Beyond the L1 penalty
The L1 penalty does two jobs badly at once: it decides which latents fire and it shrinks the ones that do, so every active feature is underestimated and sparsity and fidelity are tied to a single knob. The newer variants separate which from how much:
| Variant | How a latent fires | What enforces sparsity | Reported result |
|---|---|---|---|
| ReLU + L1 (Bricken et al.; Templeton et al.) | the baseline; shrinkage and dead latents | ||
| TopK (Gao et al., 2025) | keep the largest pre-activations | the selection itself, | better reconstruction at equal sparsity; clean scaling laws |
| Gated (Rajamanoharan et al., 2024a) | a gate path decides which latents fire, a magnitude path how strongly | L1 on the gate path only | no shrinkage; about half as many firing features for the same fidelity, in models up to 7B parameters |
| JumpReLU (Rajamanoharan et al., 2024b) | : zero below a learned threshold , identity above | directly | best fidelity at a given sparsity on Gemma 2 9B among gated, TopK and JumpReLU |
A JumpReLU autoencoder minimizes , and with pre-activations the penalty is , a sum of step functions. The thresholds appear only inside steps, so their gradient is zero almost everywhere:
The expected loss is smooth in , though. For one latent whose pre-activation has density :
So the gradient needs the density of pre-activations at the threshold. Rajamanoharan et al. define pseudo-derivatives for the backward pass, straight-through estimators with a kernel (they use the rectangle for ) and a bandwidth :
Averaged over a batch , the first is exactly minus the kernel density estimate of , the true derivative of the expected penalty; the second estimates . For , , and batches of , the estimate lands within about (one standard deviation across batches) of the exact . Only latents whose pre-activation lands within of the threshold move it, and trades bias against variance like a bandwidth.
From features to circuits
Dictionary features at two layers are connected through the MLPs between them. With sparse autoencoders on both sides, the attribution of an earlier feature to a later one through the MLP output is , and changes with the input: it describes one prompt, not the MLP. A transcoder (Dunefsky, Chlenski & Nanda, 2024) is trained to imitate the MLP itself, predicting its output from its input through a wide, sparse hidden layer. Replace every MLP by its transcoder, and the contribution of feature of the layer- transcoder to the pre-activation of feature at a later layer , along the residual stream at the same token, factors:
Crosscoders (Lindsey, Templeton, Marcus, Conerly, Batson & Olah, 2024, a preliminary research update) read from and write to several layers at once, so a feature can live across layers; trained jointly on two models, they yield shared and model-specific features for model diffing. Attribution graphs (Ameisen et al., 2025) combine these ideas. A cross-layer transcoder has features that read the residual stream at one layer and write to the outputs of all later MLPs. For one prompt, a local replacement model freezes the attention patterns and normalization denominators of the real forward pass and adds an error node wherever the transcoder misses the true MLP output; feature-to-feature effects are then linear, with edge weight from a source feature's activation and a virtual weight. The resulting graph of features, token embeddings, error nodes and logits is pruned, typically to a tenth of its nodes while losing about a fifth of the behavior explained, and its hypotheses are checked by intervening on the real model.
The replacement is only partial. The largest cross-layer transcoder in that work matched an 18-layer model's next-token completion on 50% of a diverse set of pretraining-style prompts; error nodes carry whatever the features miss; and with attention patterns frozen, why a head attends where it does is outside the graph. Each graph explains one prompt.
Are the features the model’s own?
A dictionary is judged on several axes at once. Sparsity: the average number of active latents, . Fidelity: the fraction of variance unexplained, and the increase in the language model's loss when an activation is replaced by its reconstruction, which exposes the "dark matter" the dictionary misses. Interpretability: in automated interpretability (Bills et al., 2023), a language model writes an explanation of a unit from its top activations, a simulator predicts activations from the explanation alone, and the explanation is scored by how well the simulated activations match the real ones; such pipelines now label millions of features (Paulo, Mallen, Juang & Belrose, 2025). Gao et al. added whether hypothesized features are recovered (probe loss), whether explanations have both precision and recall, and whether ablating a latent has sparse downstream effects. And dead latents.
Growing the dictionary makes features split, a "math" feature into "algebra" and "geometry". Chanin et al. (2025) found a less benign twin, feature absorption: in hundreds of autoencoders, including the Gemma Scope ones, latents that seemed to track a token's first letter failed to fire on some tokens because token-specific latents had absorbed the letter direction.
Faithful dictionary . An input with only is : one latent at 1. An input with both is : two latents at 1, so and .
Absorbing dictionary , where the first latent fires on -without- inputs and the second on -inputs. Both reconstruct exactly, and on -inputs a single latent at suffices:
-only inputs cost the same in both. Any positive weight on sparsity therefore prefers the absorbing solution, and in it the "starts with S" latent no longer fires on "short": a seemingly monosemantic latent with a hole. The hierarchy itself is what the objective exploits, which is why changing the dictionary's size or sparsity did not remove absorption in Chanin et al.'s experiments.
Three more findings temper the enthusiasm. Seed dependence: for a 131,000-latent autoencoder on an MLP of Llama 3 8B, only about 30% of features were shared between runs differing only in the random seed, with TopK autoencoders more seed-dependent than L1 ones (Paulo & Belrose, 2025). Baselines: on probing tasks with scarce data, class imbalance, label noise or distribution shift, probes built on autoencoder latents did not consistently beat ordinary probes, even when ensembled with them (Kantamneni, Engels, Rajamanoharan, Tegmark & Nanda, 2025); on the AxBench benchmark, autoencoders were not competitive for steering or concept detection (Wu et al., 2025). Random networks: autoencoders trained on randomly initialized Pythia transformers often reached automated-interpretability scores and reconstruction metrics similar to those of trained ones (Heap, Lawson, Farnik & Aitchison, 2025), so high aggregate scores do not by themselves show that computationally relevant features were found.
On the other side stand interpretable features invisible in the neuron basis, steering by single features, circuits traced through transcoders and verified by intervention, and the irreducible circular features of Probing & the Linear Representation Hypothesis, found by clustering dictionary features. The working view as of the mid-2020s: a dictionary is a pragmatically useful decomposition of activation space, one of many, rather than an exhaustive list of the features the model truly uses.
Key takeaways
- In dimensions at least unit vectors have pairwise cosines below , so superposition has room; recovering -sparse features limits a layer to roughly features, linear in width and growing with sparsity.
- Sparse autoencoders scaled from a 512-neuron MLP to production models and GPT-4 activations, with dictionaries of millions of latents. Dead latents, compute and storage are the practical limits, and a concept gets its own feature roughly once its frequency exceeds the inverse of the number of alive features.
- TopK, gated and JumpReLU autoencoders separate which latents fire from their magnitudes, removing L1 shrinkage; JumpReLU thresholds are trained through pseudo-derivatives whose batch average is a kernel density estimate of the true gradient.
- Transcoders replace MLPs with sparse, wide approximations, so feature-to-feature attributions factor into an activation times an input-invariant weight; cross-layer transcoders and attribution graphs extend this to per-prompt circuit diagrams of large models.
- The features are useful but not unique or complete: they split and absorb, depend on the seed, leave unexplained variance, score similarly on random networks by some metrics, and often fail to beat simple baselines on downstream tasks.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
What does the random-packing argument guarantee about unit vectors in whose pairwise cosines are all below ?
- At most of them exist, as with exactly orthogonal vectors
- About of them exist
- At least of them exist: exponentially many in the dimension
- Infinitely many exist for any
Show the answer
C. At least of them exist: exponentially many in the dimension
Each random pair is too close with probability at most , and a union bound over fewer than pairs stays below 1 while . For and that is about 22,000 directions. Whether features can be recovered from such a packing is a separate question, answered by the compressed-sensing bound.
Why do TopK and JumpReLU autoencoders avoid the shrinkage of the classic L1-penalized autoencoder?
- They use a larger learning rate
- They decide which latents fire separately from how large they are, so no penalty pulls the active latents' magnitudes toward zero
- They have more latents, which spreads the penalty thinner
- They normalize the decoder, which the L1 autoencoder does not
Show the answer
B. They decide which latents fire separately from how large they are, so no penalty pulls the active latents' magnitudes toward zero
An L1 penalty charges every unit of activation, so the optimal code underestimates each active feature. TopK enforces sparsity by selection and trains only reconstruction; JumpReLU penalizes the number of active latents, which does not depend on their size, and learns a threshold for each latent. Gated autoencoders apply the L1 penalty only to a separate gate path.
An autoencoder latent that seems to mean "starts with S" fires on most S-words but not on "short", and the latent for "short" has a decoder direction that includes the starts-with-S direction. What is going on, and will a bigger dictionary fix it?
- The model does not represent that "short" starts with S; no
- It is noise from training; yes, a bigger dictionary averages it out
- Feature splitting into finer features; yes, it makes the dictionary more precise
- Feature absorption: the sparsity objective prefers one latent for "short" that absorbs the parent feature; varying size or sparsity was not enough to remove it
Show the answer
D. Feature absorption: the sparsity objective prefers one latent for "short" that absorbs the parent feature; varying size or sparsity was not enough to remove it
When one feature implies another, a latent for the specific feature whose decoder includes the general direction reconstructs just as well with fewer active latents, so sparsity penalties favor it, and the general latent develops holes. Chanin et al. measured absorption across hundreds of autoencoders and found that changing size or sparsity was insufficient; it is a consequence of the objective.
Two autoencoders trained on the same activations of the same model, differing only in their random seed, share about 30% of their features. What is the most defensible reading?
- An autoencoder's features are one useful decomposition among many, not a unique list of the features the model truly uses
- One of the two runs failed and should be discarded
- The model itself changes from run to run
- Seed dependence proves that autoencoders learn nothing about the model
Show the answer
A. An autoencoder's features are one useful decomposition among many, not a unique list of the features the model truly uses
Paulo & Belrose found this for a 131,000-latent dictionary on an MLP of Llama 3 8B, and more seed dependence for TopK than for L1 autoencoders. The reconstructions are similarly good, so the activations admit many sparse decompositions. That limits claims of having found the features, without making the dictionaries useless.
Further reading
- T. Bricken et al., "Towards monosemanticity: Decomposing language models with dictionary learning," Transformer Circuits Thread (2023).
- A. Templeton et al., "Scaling monosemanticity: Extracting interpretable features from Claude 3 Sonnet," Transformer Circuits Thread (2024).
- L. Gao, T. Dupré la Tour, H. Tillman, G. Goh, R. Troll, A. Radford, I. Sutskever, J. Leike & J. Wu, "Scaling and evaluating sparse autoencoders," ICLR (2025).
- S. Rajamanoharan, T. Lieberum, N. Sonnerat, A. Conmy, V. Varma, J. Kramár & N. Nanda, "Jumping ahead: Improving reconstruction fidelity with JumpReLU sparse autoencoders," arXiv:2407.14435 (2024).
- L. Sharkey et al., "Open problems in mechanistic interpretability," Transactions on Machine Learning Research (2025).