Foundations to Frontier
Tests
F. NLP and Large Language Models › F15 Interpretability of LLMs

Superposition and sparse autoencoders

Neural networks represent more features than they have neurons by storing them as nearly orthogonal directions: superposition. This works when features are sparse, because two features rarely need the same space at the same moment. The cost is that single neurons respond to several unrelated things (polysemanticity), so reading neurons one by one fails. Sparse autoencoders (SAEs) try to undo superposition. They learn an overcomplete dictionary of directions in which each activation is a sparse combination, and many of those directions turn out to be interpretable features. This page covers the toy model of superposition, SAE training (L1, TopK and JumpReLU), the sparsity–reconstruction trade-off, dead latents, feature splitting, and evaluation. In the exercises you measure interference and compute SAE outputs, L0 and variance explained. You then reproduce the toy model: in 5 dimensions it represented 5 features when they were dense and 17 when they were 99% sparse. You also train SAEs on activations built from 64 known features in 16 dimensions. With a weak penalty the SAE recovered almost none of the features while explaining 99% of the variance. A penalty of 1 recovered 84% of them while explaining 74%.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

More ideas than neurons

Imagine a small notice board where hundreds of messages must fit. If only a few messages matter on any day, you can overlap them faintly and still read today’s ones. Networks do the same with features, so a single neuron ends up mixing several meanings. A sparse autoencoder is a tool that learns a larger, cleaner set of directions where each activation uses only a few of them, pulling the overlapping messages apart again. The demo shows how little random directions interfere in many dimensions.

Interpretability lab
1000 features in 64 dimensions (15.6 per dimension). Random directions interfere with typical |cos| ≈ 0.100; sparse features tolerate this, so models store more features than dimensions.
Why engineers care

SAE features have been used to find and turn off representations such as deception or unsafe topics in large models; the same tools could inspect controllers’ internal states.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Superposition stores…
  2. 2. Superposition works best when features are…
  3. 3. A sparse autoencoder learns…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Toy model (Elhage et al., 2022): n sparse features in d < n dimensions; as sparsity rises, the model stores more features in superposition, arranged in geometric patterns (antipodal pairs, pentagons).
  • Polysemantic neurons: neurons fire for unrelated concepts because features are not aligned with the neuron basis.
  • SAEs: encoder ReLU(W_e(x − b) + b_e), decoder W_d f + b; loss reconstruction + λ‖f‖₁; dictionary 4× to 256× the width. Variants: TopK (fix L0), JumpReLU, gated SAEs; transcoders replace MLPs.
  • Results: monosemantic features in one-layer models (Bricken et al., 2023), millions of features in Claude 3 Sonnet (Templeton et al., 2024) and GPT-4 (Gao et al., 2024); Gemma Scope open SAEs.
  • Trade-offs and issues: L0 vs reconstruction; shrinkage from L1; dead latents; feature splitting and absorption with dictionary size; errors left in the reconstruction; features are not guaranteed to be the model’s own units.
  • Evaluation: L0, variance explained, downstream loss when splicing in the reconstruction, interpretability scores, and use in tasks (steering, probing).
📝 Quick check (Level 1)
0/3 answered
  1. 1. TopK SAEs fix…
  2. 2. Open SAEs for Gemma are called…
  3. 3. Larger dictionaries can cause…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Training and using SAEs

Exercise 1.

  • Interference between feature directions.
  • The SAE forward pass.
  • L0 and fraction of variance explained.

Practice.

  • Use SAELens or dictionary_learning to train on cached residual-stream activations; or load pretrained SAEs (Gemma Scope, Llama Scope).
  • Normalise activations; keep decoder columns unit norm; resample dead latents.
  • Choose L0 by downstream loss when the SAE reconstruction replaces the activation, not only by variance explained.
  • Interpret latents with top-activating examples and automated explanations; check with steering.
  • Report L0, variance explained, downstream loss increase and dead fraction.
from sae_lens import SAE
from transformer_lens import HookedTransformer
model = HookedTransformer.from_pretrained("gemma-2-2b")
sae, cfg, _ = SAE.from_pretrained("gemma-scope-2b-pt-res-canonical", "layer_12/width_16k/canonical")
_, cache = model.run_with_cache("The rocket engine ignited", names_filter=sae.cfg.hook_name)
feats = sae.encode(cache[sae.cfg.hook_name])        # sparse latents per token
print(feats[0, -1].topk(5))
🐍 Exercise 1: interference and SAE metrics
Measure interference, run an SAE forward pass and compute L0 and variance explained.
📝 Quick check (Level 2)
0/3 answered
  1. 1. A library for training SAEs:
  2. 2. Pick L0 by…
  3. 3. Dead latents should be…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why sparsity permits superposition. Reading feature i along its direction w_i picks up interference Σ_j x_j (w_i · w_j) from other active features. If features are active with probability p, the expected interference scales with p; when p is small, the benefit of representing more features outweighs the rare interference, and ReLU with a negative bias filters small interference.

Near-orthogonality. Random unit vectors in d dimensions have |cos| ≈ √(2/(πd)); in thousands of dimensions, exponentially many nearly orthogonal directions exist.

SAE trade-off. The L1 penalty pushes most latents to zero but also shrinks the active ones, hurting reconstruction. Too weak a penalty lets the SAE reconstruct with dense, mixed latents that do not match features; too strong a penalty drops real features. Dictionary size below the true number of features forces latents to merge features.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Interference scales with…
  2. 2. Typical |cos| between random directions in d dimensions:
  3. 3. L1 penalty also causes…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Does sparsity drive superposition in the toy model, and can sparse autoencoders recover features hidden in superposition?

History.

  • N. Elhage et al., “Toy models of superposition” (2022).
  • T. Bricken et al., “Towards monosemanticity” (2023); H. Cunningham et al., “Sparse autoencoders find highly interpretable features” (2023).
  • A. Templeton et al., “Scaling monosemanticity” (2024).

Exercise 2. Two experiments.

  • Toy model: 20 features with importance 0.9^i into 5 dimensions; reconstruction ReLU(WᵀW x + b); Adam. A feature counts as represented if its column norm exceeds 0.5.
  • SAE: 64 known unit feature directions in 16 dimensions; each active with probability 0.03 (about 1.9 active per example) with exponential size; small noise.
  • SAE training: L1 penalty λ; 32, 64 or 128 latents; 800 Adam steps on a fixed pool of 8000 examples.
  • Recovery: a true feature counts as recovered if some decoder column has |cos| > 0.9 with it.
toy model sparsity features represented (of 20)
0 5
0.7 10
0.9 13
0.99 17
SAE features recovered L0 variance explained
64 latents, λ 0.1 0.0 15.7 0.985
64 latents, λ 1 0.875 1.97 0.733
64 latents, λ 3 0.562 0.65 0.409
32 latents, λ 1 0.281 1.87 0.729
128 latents, λ 1 0.734 2.37 0.724
  • Superposition grew with sparsity, as in Elhage et al.
  • No neuron (basis direction) matched any true feature with |cos| > 0.9.
  • The SAE trade-off was stark: high variance explained with dense latents meant no recovered features; recovery needed an L0 near the true 1.9 and cost a quarter of the variance (shrinkage).
  • Dictionary size: 32 latents could not hold 64 features; 128 latents did not beat 64 (0.734 here, 0.844 and 0.891 on other seeds). Too strong a penalty (λ 3) also lost features.
  • Seeds 1 and 2: λ 1 recovery 0.797 and 0.891; 128 latents 0.844 and 0.891; toy at 0.99 sparsity 17 and 16.
  • Caveat: linear ground truth with known features; in real models true features are unknown and SAE latents may split or absorb them.
🐍 Exercise 2 (research): does sparsity drive superposition in the toy model, and can sparse autoencoders recover features hidden in superposition?
Train the toy model of superposition at several sparsities; train sparse autoencoders of different sizes and penalties on activations built from known features and measure recovery.

Superposition and SAEs in AI, robotics and aerospace

  • Safety features: SAE latents for unsafe or deceptive content can be monitored or suppressed in deployed assistants.
  • Robot policies: SAEs on policy activations reveal features for objects, contacts and failure states.
  • Anomaly detection: unusual combinations of SAE features can flag out-of-distribution inputs.

References

  1. N. Elhage et al. (2022). “Toy models of superposition.” Transformer Circuits Thread.
  2. T. Bricken et al. (2023). “Towards monosemanticity: decomposing language models with dictionary learning.” Transformer Circuits Thread.
  3. A. Templeton et al. (2024). “Scaling monosemanticity.” Transformer Circuits Thread.
  4. L. Gao et al. (2024). “Scaling and evaluating sparse autoencoders.” arXiv.