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.
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.
- 1. Superposition stores…
- 2. Superposition works best when features are…
- 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).
- 1. TopK SAEs fix…
- 2. Open SAEs for Gemma are called…
- 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))- 1. A library for training SAEs:
- 2. Pick L0 by…
- 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.
- 1. Interference scales with…
- 2. Typical |cos| between random directions in d dimensions:
- 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.
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
- N. Elhage et al. (2022). “Toy models of superposition.” Transformer Circuits Thread.
- T. Bricken et al. (2023). “Towards monosemanticity: decomposing language models with dictionary learning.” Transformer Circuits Thread.
- A. Templeton et al. (2024). “Scaling monosemanticity.” Transformer Circuits Thread.
- L. Gao et al. (2024). “Scaling and evaluating sparse autoencoders.” arXiv.