Skip to content

Towards Monosemanticity: Decomposing Language Models With Dictionary Learning

Skip →Axiomatic causal interventions
main track #9corefundamentalblogrubric 11/122023 · ~75 min

Trenton Bricken, Adly Templeton, Joshua Batson, …, Chris Olah

Read first: Toy Models of Superposition

Status

TL;DR. Neurons are polysemantic because of superposition. This Anthropic paper trains a sparse autoencoder (SAE) on the 512-neuron MLP layer of a one-layer transformer and recovers thousands of features, most of them far more monosemantic than any neuron. Examples include Arabic script, DNA and base64. It also documents the two big practical issues of L1 SAEs: the choice of dictionary size, which causes feature splitting, and dead latents. Read it together with Gao et al. (2024), whose TopK SAE drops the L1 penalty and scales to 16M latents on GPT-4.

Why it matters now. SAEs became the default decomposition for mechanistic interpretability. Scaling Monosemanticity, Gemma Scope and the transcoders behind attribution graphs all build on them. Any plan to use model internals to monitor reward hacking, detect harmful intent, or explain a retriever or reranker has to understand what SAE objectives optimise and where they fail.

The SAE subtracts a decoder bias, encodes into a wide ReLU layer, and decodes with a dictionary of unit-norm directions:

xˉ=x−bd,f=ReLU(Wexˉ+be),x^=Wdf+bd,\bar{x} = x - b_d,\qquad f = \mathrm{ReLU}(W_e \bar{x} + b_e),\qquad \hat{x} = W_d f + b_d, L=E[∥x−x^∥22]+λ∥f∥1.\mathcal{L} = \mathbb{E}\big[\lVert x - \hat{x} \rVert_2^2\big] + \lambda \lVert f \rVert_1 .

The decoder is untied from the encoder, and its columns are kept at unit norm. Without that, the L1 term could be shrunk for free by scaling the decoder up and the activations down. The pre-encoder bias is initialised to the geometric median of the data. The dictionary is overcomplete: from 512 (1×) to 131,072 (256×) features. The main run A/1 uses 4,096 (8×).

The L1 term has a known cost. Take one active feature with unit-norm decoder direction dd, no interference from other features, and residual r=d⋅(x−bd)r = d \cdot (x - b_d) along it. The loss along dd is (r−f)2+λf(r - f)^2 + \lambda f for f≥0f \ge 0; setting the derivative −2(r−f)+λ-2(r - f) + \lambda to zero gives f∗=max⁡(0,r−λ/2)f^* = \max(0, r - \lambda/2). Every active feature is therefore shrunk by λ/2\lambda/2. Worked example: with r=1.0r = 1.0 and λ=0.4\lambda = 0.4, the SAE outputs f∗=0.8f^* = 0.8, so the reconstruction along dd is 20% too small; a weaker true activation r=0.15r = 0.15 is zeroed out entirely.

TopK variant (Gao et al., 2024; code):

z=TopK(Wenc(x−bpre)),L=∥x−x^∥2+α∥e−e^∥2.z = \mathrm{TopK}\big(W_{\mathrm{enc}}(x - b_{\mathrm{pre}})\big),\qquad \mathcal{L} = \lVert x - \hat{x} \rVert^2 + \alpha \lVert e - \hat{e} \rVert^2 .

TopK sets the sparsity directly as L0=kL_0 = k, removes λ and the shrinkage it causes, and trains only on MSE. The auxiliary term (AuxK) reconstructs the error e=x−x^e = x - \hat{x} using only the top kauxk_{\mathrm{aux}} dead latents. Its settings are kaux=512k_{\mathrm{aux}} = 512 and α=1/32\alpha = 1/32.

Sparse autoencoder for dictionary learning: the L1 objective of Towards Monosemanticity and the TopK variant Top: MLP activations x are centred by subtracting the decoder bias, encoded by a linear map and ReLU into a wide, sparse feature vector f, and decoded by a dictionary of unit-norm directions plus the bias. The loss is mean squared reconstruction error plus lambda times the L1 norm of f. Bottom left: two failure modes of this objective, shrinkage of active features toward zero and dead latents that never fire, handled by periodic resampling. Bottom right: the TopK variant keeps only the k largest pre-activations, drops the L1 term, and adds an auxiliary loss in which dead latents try to reconstruct the remaining error. SAE on one layer's activations x 512 neurons − b_d ReLU(W_e x̄ + b_e) encoder f m ≫ 512 mostly 0 W_d f + b_d unit-norm columns x̂ L = mean ‖x − x̂‖² + λ‖f‖₁ dictionary size m: 512 (1×) to 131,072 (256×); A/1 uses 4,096 What goes wrong with L1 shrinkage: λ‖f‖₁ pulls every active feature toward 0, not just the noise dead latents: some features never fire A/1: 168 of 4,096 dead on 100M examples fix: resample dead rows toward badly reconstructed inputs, reset Adam state TopK SAE (Gao et al. 2024) z = TopK(W_enc(x − b_pre)), L = ‖x − x̂‖² set L0 = k directly; no λ, no shrinkage AuxK: L + α‖e − ê‖², e = x − x̂ ê uses the top k_aux dead latents only + encoder initialised as decoder transpose 16M-latent GPT-4 SAE: 7% dead
Original sketch. Top: the L1 sparse autoencoder on 512 MLP neurons. Bottom left: shrinkage and dead latents, with resampling as the fix. Bottom right: the TopK variant with the AuxK loss (Gao et al. 2024).

Setup. One-layer transformer with a 512-neuron MLP, trained on 100B tokens of the Pile. SAEs are trained on 8B MLP activation samples.

Interpretability. Features such as Arabic script, DNA, base64 and Hebrew are much more specific than any neuron. Activating a feature steers generation, for example base64 text or Arabic text.

Loss recovered. A/1 recovers 79% of the log-likelihood loss reduction provided by the MLP. A/5 (131,072 features, λ = 0.004) recovers 94.5%.

TopK (Gao et al.).

  • Without mitigations, ablations show up to 90% dead latents. A latent counts as dead if it has not fired in 10M tokens. For comparison, Templeton et al.’s 34M SAE had only 12M alive.
  • With the mitigations, the 16M-latent GPT-4 SAE has 7% dead.
  • Refining the nonzero activations after encoding improves reconstruction MSE and downstream cross-entropy for both ReLU and TopK SAEs. ReLU refinements tend to increase activations, consistent with L1 shrinkage; TopK refinements are smaller and not systematically positive (§5.1, Fig. 9).

Advanced: resampling schedule and scaling fit

Section titled “Advanced: resampling schedule and scaling fit”

These details matter when you train an SAE yourself; skip them on a first read.

Dead latents. Resampling procedure:

  1. At steps 25k, 50k, 75k and 100k, find latents dead for the last 12,500 steps.
  2. Compute the loss on 819,200 inputs and sample inputs with probability ∝ loss².
  3. Set each dead latent’s dictionary vector to a sampled input, unit-normalised.
  4. Set its encoder row to 0.2 × the average alive encoder norm, with zero bias.
  5. Reset the Adam state.

TopK scaling fit (Gao et al.). Joint fit: L(n,k)=exp⁡(α+βklog⁡k+βnlog⁡n+γlog⁡klog⁡n)+exp⁡(ζ+ηlog⁡k)L(n,k) = \exp(\alpha + \beta_k \log k + \beta_n \log n + \gamma \log k \log n) + \exp(\zeta + \eta \log k), with γ=−0.042<0\gamma = -0.042 < 0, valid for small k.

  • The model is a one-layer toy, and 21% of the MLP’s loss reduction is unexplained at A/1.
  • There is no canonical dictionary size, so feature splitting makes “the features” depend on a hyperparameter.
  • Sparsity is a proxy for interpretability, not the goal itself.
  • TopK fixes shrinkage, but not the question of whether SAE latents capture the concepts you need. The GDM negative results suggest they often do not.
  • Open questions: how to evaluate SAEs by downstream use rather than MSE and L0, and whether features compose across layers.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Take the SAE loss ‖x − x̂‖² + λ‖f‖₁ and consider one active feature with a unit-norm decoder direction d and no interference, so the residual along d is r = d · (x − b_d). Solve for the loss-minimising activation f ≥ 0 and show that L1 systematically underestimates active features. How does TopK avoid this?

    What a strong answer covers
    • Along d the loss is (r − f)² + λf for f ≥ 0. Setting the derivative −2(r − f) + λ to zero gives f* = max(0, r − λ/2): soft thresholding.
    • Every active feature is shrunk by λ/2 relative to the value that reconstructs best; small true activations are zeroed out entirely. This is activation shrinkage.
    • Raising λ to get sparser codes makes shrinkage worse, so L1 trades reconstruction against sparsity through the same knob.
    • TopK sets sparsity by keeping the k largest pre-activations and has no L1 term, so the kept activations are fit only by MSE. Gao et al. show that refining the nonzero activations improves reconstruction MSE and downstream cross-entropy for both ReLU and TopK SAEs; ReLU refinements tend to increase activations (consistent with L1 shrinkage), while TopK refinements are smaller and not systematically positive.
  2. Mechanism

    Why must the decoder columns be constrained to unit norm when the sparsity penalty is λ‖f‖₁? What would gradient descent do without the constraint?

    What a strong answer covers
    • The reconstruction depends on the product W_d f, so scaling a decoder column by c and its activation by 1/c leaves x̂ unchanged.
    • The L1 term would fall by a factor c, so without a constraint the optimiser can make the penalty arbitrarily small by growing decoder norms and shrinking activations.
    • Then the code is not really sparse in any useful sense; the unit-norm constraint fixes the scale so λ‖f‖₁ is meaningful.
    • TopK does not need this argument for sparsity (L0 = k is fixed), though fixing decoder norms still makes activation magnitudes comparable across latents.
  3. Mechanism

    Explain how dead latents arise and compare the two fixes: Bricken et al.'s resampling procedure and Gao et al.'s encoder-transpose initialisation plus AuxK loss. What does each one do to a dead latent's parameters or gradients?

    What a strong answer covers
    • A latent whose pre-activation is negative on all inputs gets zero gradient through the ReLU or TopK, so it can never recover; causes include a high learning rate, small batches and redundant data. A/1 had 168 of 4,096 latents dead on 100M examples.
    • Resampling: at steps 25k, 50k, 75k and 100k, find latents dead for the last 12,500 steps, sample inputs with probability proportional to their squared loss, set the dictionary vector to the normalised input, set the encoder row to 0.2 × the average alive encoder norm with zero bias, and reset Adam state.
    • AuxK: add α‖e − ê‖², where e = x − x̂ and ê is reconstructed from the top k_aux dead latents only (k_aux = 512, α = 1/32), so dead latents get gradient toward explaining what the main SAE misses.
    • With encoder = decoder transpose at initialisation and AuxK, Gao et al.'s 16M-latent GPT-4 SAE has only 7% dead latents, compared with up to 90% in ablations without them.
  4. What if…

    The paper trains dictionaries from 512 (1×) up to 131,072 (256×) features on the same 512-neuron MLP. Describe feature splitting and explain whether it is a problem, a feature, or both for using SAEs as an analysis tool.

    What a strong answer covers
    • As the dictionary grows, one feature (for example a base64 feature) splits into several finer, still interpretable features, forming families that look like the same concept at different resolutions.
    • Feature: dictionary size acts as a resolution knob, and families show structure in the concept space.
    • Problem: there is no single canonical set of features; which concepts you find depends on an arbitrary size, and finer features may absorb parts of coarser ones.
    • Loss recovered also changes with size and λ: A/1 (4,096 features) recovers 79% of the MLP's loss reduction, A/5 (131,072 features, λ = 0.004) recovers 94.5%.
  5. Critique

    A/1 recovers 79% of the log-likelihood loss reduction that the MLP provides. Explain exactly what this metric measures and give two reasons it can overstate or understate how well the SAE explains the model.

    What a strong answer covers
    • Replace the MLP activations with the SAE reconstruction and measure the extra loss; the metric is 1 minus that extra loss divided by the extra loss from zero-ablating the MLP (here the extra loss is 21% of the zero-ablation loss).
    • Overstate: the reconstruction can preserve the loss through directions that are not interpretable, or through a few dense features.
    • Understate: small reconstruction errors can compound downstream even if every feature is interpretable; and the leftover 21% may contain rare but important features.
    • It does not measure interpretability itself, which the paper assesses separately (feature specificity, sensitivity, steering).
  6. Design

    You want SAE features on the final hidden states of a dense retriever to explain why it ranks some irrelevant documents highly. Choose between an L1 SAE and a TopK SAE, choose a dictionary size and k, and say how you will evaluate whether the features are useful for this goal.

    What a strong answer covers
    • TopK: sparsity is set directly by k, there is no shrinkage to distort similarity scores, and dead latents are controlled with AuxK; set k well below the embedding dimension.
    • Size: sweep the number of latents (for example 8× to 64× the dimension) and use the Gao et al. scaling-law view (MSE falls with n and k) to pick a point before returns flatten; expect feature splitting as size grows.
    • Check reconstruction in the downstream metric: ranking quality (for example nDCG) when replacing embeddings with reconstructions, not just MSE.
    • Usefulness: find features over-active on false positives, ablate or steer them, and measure ranking changes; compare with a dense linear probe as a baseline.

Done with this page?

Status