Sparse Representations

Representation learning is one answer to the superposition problem. If a trained model stores more features than it has neurons, we need a new coordinate system: an overcomplete dictionary whose components recover the meaningful directions that are mixed together inside the model.

Dictionary learning represents each activation xx as a sparse combination of learned atoms:

xDαx \approx D\alpha

DD contains the dictionary directions. α\alpha says which directions are active and by how much. The classic optimization alternates between sparse coding, which solves for coefficients, and dictionary updates, which improve the atoms.

Dictionary learning

A dictionary can be overcomplete: it may contain more atoms than the original activation has dimensions. That is the point. The model activation can then be described by a few active atoms from a much larger vocabulary.

Most concepts are absent from most inputs. A random token is probably not about pizza. A random image probably does not contain a dog head at a particular angle. This makes real-world features sparse.

A sparse representation uses a large vocabulary of possible features while activating only a small subset for each input.

Sparsity

If zz is a feature code, sparsity means most entries of zz are zero or near zero for a given example. The active entries provide a compact account of that activation.

Sparsity makes monitoring manageable. Instead of inspecting thousands of dense values, an analyst can ask which few features were active for a suspicious response. Too much sparsity discards information, so reconstruction quality remains part of the objective.

Checkpoint

What happens if the sparsity penalty becomes too strong?

An autoencoder learns to compress an input into a latent representation and then reconstruct it. For mechanistic interpretability, the input is usually not raw text or pixels. It is a model activation from a chosen layer.

A sparse autoencoder learns to reconstruct that activation through a wider hidden layer. The encoder maps the original activation into feature coefficients. A sparsity penalty keeps only a few coefficients active. The decoder maps those coefficients back.

Hover or click any layer to explore
EncoderBottleneckDecoder

Width represents vector dimensionality — compression then expansion

Hover or click a layer

See how each layer compresses then reconstructs the data through a narrow bottleneck.

Input / Output (N dims)Encoder / Decoder layersLatent code z (bottleneck, K ≪ N)

Toggle between a standard autoencoder and a sparse autoencoder to compare their architectures layer by layer.

Training objective

L=xDz22+λz1L = \|x-Dz\|_2^2 + \lambda\|z\|_1

The first term preserves the original activation. The second makes the learned code sparse.

Diagram of a sparse autoencoder decomposing a model activation into sparse, interpretable features
A sparse autoencoder decomposes a dense activation into a sparse combination of interpretable feature directions. [Source]

Sparse regularization

There are two common sparsity pressures. L1 regularization penalizes the absolute size of hidden activations. KL-divergence regularization pushes each hidden unit's average activation toward a small target rate. In modern SAE work, the exact objective varies, but the central tradeoff is still reconstruction quality versus sparse, interpretable activations.

Sparse Autoencoder, Step by Step

Follow one model activation through an overcomplete dictionary. The sparsity penalty suppresses weak feature scores; the decoder tries to reconstruct the original activation.

1. Model activation

loss = reconstruction error + λΣ|zᵢ|

Active features

3 / 5

Reconstruction MSE

0.074

Input activation x

0.80

0.30

0.65

Raw encoder scores

0.82

0.18

0.56

0.08

0.41

Sparse code z = ReLU(raw - λ)

0.60

0.00

0.34

0.00

0.19

Reconstruction x-hat = Dz

0.50

0.12

0.33

The training objective balances reconstruction fidelity against sparse feature use. Push either side too hard and the representation becomes less useful.

The decoder columns act like feature directions. An activation can be approximated as a sparse sum of those directions. This creates an overcomplete basis: more candidate features than original dimensions, which is exactly what superposition asks us to recover.

Checkpoint

Why is the hidden layer often wider than the model activation being reconstructed?