Trains sparse autoencoders on the MLP activations of a one-layer transformer and finds features more interpretable than its neurons; one neuron fires on citations, dialogue, HTTP requests and Korean text.
Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
Sparse autoencoders rewrite each model activation as a sparse combination of learned directions, which are often easier to interpret than individual neurons.
Intuition
The idea in plain words, before the symbols.
Individual neurons in language models are often hard to interpret because many of them respond to several unrelated things. Bricken et al. (2023) describe a neuron in a small transformer that fires on a mixture of academic citations, English dialogue, HTTP requests and Korean text. Such neurons are called polysemantic.
One explanation is superposition (Elhage et al., 2022): a layer can represent more features than it has neurons by giving each feature its own direction in activation space. The directions are nearly, but not exactly, orthogonal, and they need not line up with individual neurons. Reading one neuron then mixes several features.
A sparse autoencoder (SAE) tries to recover those feature directions from the activations (Bricken et al., 2023; Huben et al., 2024).
- The encoder maps an activation vector to a much longer vector of latent values, one per candidate feature.
- The decoder rebuilds the activation as a weighted sum of learned directions, one direction per latent.
- A sparsity penalty or constraint keeps only a few latents active for each token.
If it works, each activation is described by a short list of active latents, each with its own direction, instead of thousands of mixed neuron values. The main design choice is how many latents an activation may use: too few and the reconstruction loses information; too many and each activation is again a dense mixture that is hard to read. Whether an individual latent is interpretable has to be checked separately, for example by inspecting the inputs that activate it most.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Mathematics
Definitions, assumptions and the derivation.
Let be an activation vector from one layer of a model, often the residual stream of a transformer.
Encode to sparse latents, decode back to the activation
An SAE maps into a sparse latent code , usually with much larger than , and reconstructs it as :
The columns of form a learned dictionary of feature directions. If , the th direction contributes times itself to the reconstruction. Subtracting before encoding and adding it back after decoding follows Bricken et al. (2023).
Reconstruction plus sparsity
The classic objective balances faithfulness and simplicity:
- asks the dictionary to explain the real activation.
- penalizes large and numerous active latents.
The decoder columns are usually constrained to unit norm. Without that, the model could shrink and grow the columns to escape the penalty. If is too small, the code is dense. If it is too large, reconstruction worsens and some latents stop firing on any input ("dead" latents). The penalty also pulls every active value toward zero, an effect called shrinkage.
Top-k sparse coding
Gao et al. (2025) replace the penalty with a hard rule that keeps only the largest latents, the -sparse autoencoder of Makhzani and Frey (2014):
Here keeps the largest nonnegative activation scores and sets the rest to zero.
Now the number of active latents, , is set directly to (at most) instead of being tuned through . Gao et al. report that this removes the shrinkage caused by the penalty and gives lower reconstruction error at the same sparsity. They write the encoder as , without , and apply a ReLU in their code so that activations stay nonnegative.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
import numpy as np
rs = np.random.RandomState(0)
n, d, m, k = 256, 10, 24, 3
D_true = rs.randn(d, m); D_true /= np.linalg.norm(D_true, axis=0, keepdims=True)
Z_true = np.zeros((n, m))
for row in Z_true:
row[rs.choice(m, k, replace=False)] = rs.uniform(0.5, 1.5, k)
X = Z_true @ D_true.T + 0.02 * rs.randn(n, d)
def train_sae(lam, steps=500, lr=0.05):
W_enc, W_dec = 0.1 * rs.randn(m, d), 0.1 * rs.randn(d, m)
for _ in range(steps):
pre = X @ W_enc.T
Z = np.maximum(pre, 0.0)
X_hat = Z @ W_dec.T
err = 2 * (X_hat - X) / n # gradient of the mean squared L2 reconstruction loss
grad_dec = err.T @ Z
grad_z = err @ W_dec + lam * (Z > 0) / n
W_enc -= lr * ((grad_z * (pre > 0)).T @ X)
W_dec -= lr * grad_dec
W_dec /= np.linalg.norm(W_dec, axis=0, keepdims=True) + 1e-9
Z = np.maximum(X @ W_enc.T, 0.0)
X_hat = Z @ W_dec.T
return np.mean((X - X_hat) ** 2), np.mean(np.count_nonzero(Z > 1e-3, axis=1))
faithful = train_sae(lam=0.0005)
sparse = train_sae(lam=0.30)
print("low lambda: mse %.4f, avg active latents %.1f" % faithful)
print("high lambda: mse %.4f, avg active latents %.1f" % sparse)
assert sparse[1] < faithful[1] and sparse[0] > faithful[0]
The code builds synthetic "activations" from 24 random unit directions in 10 dimensions, three active per example, and trains an SAE on them twice. Raising makes the code sparser on average, and the reconstruction error rises: the tradeoff described above.
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability, then open its guide.
The demo draws reconstruction error against the number of active latents for three kinds of SAE: , TopK, and gated SAEs, which separate the decision of which latents fire from how large they are and apply the penalty only to the first (Rajamanoharan et al., 2024). Use it to see:
- how reconstruction error falls as more latents are allowed to fire,
- why comparisons are fair only at the same number of active latents,
- and that better reconstruction is not the same as cleaner, more interpretable features.
The curves are drawn by hand to illustrate these tradeoffs; they are not results from trained SAEs.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Concept: Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
What is the smallest example of Sparse Autoencoders you can work through by hand, and what does it show?
DetailsRepresentation Learning
Reference id
concept:representation-learning/sparse-autoencodersAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
Sparse autoencoders rewrite each model activation as a sparse combination of learned directions, which are often easier to interpret than individual neurons.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
Sparse autoencoders rewrite each model activation as a sparse combination of learned directions, which are often easier to interpret than individual neurons.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Uses TopK sparse autoencoders to set the number of active latents directly, avoiding L1 shrinkage, and trains a 16-million-latent autoencoder on GPT-4 activations (ICLR 2025).
Shows in small ReLU networks that models can represent more features than they have dimensions, which the authors call superposition, and that this can produce polysemantic neurons. Transformer Circuits Thread.
Finds, by automated scoring, that sparse-autoencoder features of language-model activations are more interpretable than directions from other methods (ICLR 2024). The 2023 arXiv preprint lists Cunningham first.
Introduces autoencoders whose hidden layer keeps only the k largest activations (ICLR 2014).
Separates choosing which latents are active from estimating their sizes and applies the L1 penalty only to the choice, reducing shrinkage (NeurIPS 2024; arXiv title: Improving Dictionary Learning with Gated Sparse Autoencoders).
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
Sparse autoencoders rewrite each model activation as a sparse combination of learned directions, which are often easier to interpret than individual neurons.
The checks were made by this site, not by an independent reviewer.
Bricken et al. ground SAEs as dictionary-learning tools for decomposing model activations into learned features. Gao et al. describe SAEs as reconstructing language-model activations from a sparse bottleneck...
Covers only reconstruction and sparsity. It does not show that features are always monosemantic, causally complete or interpretable, that they help with steering or circuit analysis, or that TopK or gated SA...
Bricken et al. support SAE dictionary learning over transformer activations with a ReLU encoder, decoder/dictionary reconstruction, MSE plus L1 sparsity, and hidden activations as learned features. Gao et al. support language-model activation reconstruction from sparse bottlenecks, L0/MSE evaluation, and reconstruction-sparsity plus TopK direct sparsity control. The equations and the code on this page illustrate the mechanism; the hand-drawn demo is not covered.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
Try the idea in your own words
Sparse autoencoders rewrite each model activation as a sparse combination of learned directions, which are often easier to interpret than individual neurons.
Concept · Selected for practice
Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
What it rests on: Sources: Towards Monosemanticity: Decomposing Language Models With Dictionary Learning; Scaling and evaluating sparse autoencoders; Toy Models of S...
Context and links
Representation Learning
Explain the mechanism
For Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability: What is the smallest example of Sparse Autoencoders you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
assert sparse[1] < faithful[1] and sparse[0] > faithful[0]Your question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
Sparse Autoencoders: Feature Dictionaries for Mechanistic Interpretability
What is the smallest example of Sparse Autoencoders you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 6 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 6 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/representation-learning/sparse-autoencoders
concept:representation-learning/sparse-autoencoders