Out of Sample
about

Part II, Sparse autoencoders

Training one

Watch a sparse autoencoder learn, see what the penalty, the width and the random seed do to it, and then the practical details that make training work on billions of activations.

Assumes pieces 5 and 6, and the Adam optimiser.

Here is a complete SAE, the architecture of piece 6, trained by Adam in your browser on the toy superposition data of piece 5: features in the plane, each active 10%10\% of the time with a magnitude drawn uniformly from 0 to 1. Everything in the real recipe is here at small scale: a ReLU encoder initialised to the decoder’s transpose, unit-length decoder columns, an L1 penalty and a learned decoder bias.

What to look for

The penalty. At λ=\lambda = 0.30 the decoder directions settle onto the true features, and L0L_0 falls close to the data’s own. Lower it and L0L_0 rises: the SAE reconstructs better by spreading each input over several latents, and the directions drift off the features. Raise it and the error climbs while latents die or merge. The penalty sets a point on the sparsity–fidelity frontier. Only part of that frontier recovers the features, and in real models we cannot see the dashed lines that tell us which part.

The width. With 8 latents for 5 features, the spare latents usually die. With fewer latents than features, some latent ends up between two features and represents both, the small-scale version of feature hedging (piece 12). With many more, spare latents survive by duplicating or splitting features.

The seed. Press draw again several times. The same settings sometimes recover every feature and sometimes get stuck with one latent covering two. This is the toy version of the finding that SAEs trained with different seeds on the same activations share only part of their features.Paulo and Belrose, 2025: about 30% shared between two 131K-latent SAEs on a Llama 3 8B MLP.

Density. Raise the chance a feature is active. As features co-occur more often, interference grows and recovery gets harder at every penalty, just as the toy model of piece 5 predicts.

The recipe at scale

The figure skips the parts that only matter at scale. The published recipes share most of the following.Sources: Bricken et al., 2023, appendix on training; Anthropic’s circuits updates through 2024; Gao et al., 2024; Rajamanoharan et al., 2024. Exact hyperparameters vary by paper and are not reproduced here.

Data. Activations from one site, such as the residual stream after layer ℓ\ell, collected over hundreds of millions to billions of tokens and shuffled in a large buffer so that each batch mixes many documents. Positions with outsized norms, such as the first token of a context, are often excluded.

Scale. Inputs are rescaled to a fixed average norm, often n\sqrt{n}, so that a value of λ\lambda means the same thing at different layers and in different models.

The decoder bias. Initialised to the geometric median or mean of the data, so the SAE starts by modelling deviations from a sensible centre.

Decoder norms. Without a constraint, the L1 penalty can be dodged: shrink a latent by cc and lengthen its decoder column by 1/c1/c. The original fix fixes every column to unit length and removes the gradient component parallel to it. Later Anthropic work dropped the constraint and penalised λ∑ifi∥di∥\lambda \sum_i f_i \lVert d_i\rVert instead, which removes the incentive directly.

Warm-up. λ\lambda is ramped up from zero over the early steps, and the learning rate is decayed at the end.

Dead latents. A latent that never fires gets no gradient and stays dead. Fixes include resampling dead latents toward inputs the SAE reconstructs badly (Bricken et al.), ghost gradients, and the TopK paper’s auxiliary loss, which asks the top dead latents to model the residual error.

Monitoring. During training, track L0L_0, FVU, loss recovered, the fraction of dead latents, and a histogram of how often each latent fires, on a log scale. Bricken et al. found a separate cluster of ultra-rare latents in that histogram, a useful sign that something has gone wrong.

Exercise

Prove the claim about decoder norms: without a constraint, for any trained SAE and any c>1c \gt 1, there is another with the same reconstructions and an L1 penalty cc times smaller. Why does penalising fi∥di∥f_i\lVert d_i\rVert instead remove the problem?

Solution

Scale row ii of WencW_{\mathrm{enc}} and benc,ib_{\mathrm{enc},i} by 1/c1/c and column did_i by cc. ReLU commutes with positive scaling, so fi→fi/cf_i \to f_i/c and fidif_i d_i is unchanged, while ∑fi\sum f_i falls by the factor cc. The product fi∥di∥f_i \lVert d_i\rVert is invariant to this rescaling, so the penalty no longer depends on it.

Exercise

In the figure, set the true features to 4 and the latents to 3. Which features does the SAE merge, and why those?