Improving Dictionary Learning with Gated Sparse Autoencoders

Senthooran Rajamanoharan, Arthur Conmy, Lewis Smith, Tom Lieberum, Vikrant Varma, János Kramár, Rohin Shah, Neel Nanda

Abstract

Recent work has found that sparse autoencoders (SAEs) are an effective technique for unsupervised discovery of interpretable features in language models' (LMs) activations, by finding sparse, linear reconstructions of LM activations. We introduce the Gated Sparse Autoencoder (Gated SAE), which achieves a Pareto improvement over training with prevailing methods. In SAEs, the L1 penalty used to encourage sparsity introduces many undesirable biases, such as shrinkage -- systematic underestimation of feature activations. The key insight of Gated SAEs is to separate the functionality of (a) determining which directions to use and (b) estimating the magnitudes of those directions: this enables us to apply the L1 penalty only to the former, limiting the scope of undesirable side effects. Through training SAEs on LMs of up to 7B parameters we find that, in typical hyper-parameter ranges, Gated SAEs solve shrinkage, are similarly interpretable, and require half as many firing features to achieve comparable reconstruction fidelity.

Introduction: The Challenge of Shrinkage

Mechanistic interpretability aims to decompose the complex activations of Large Language Models (LLMs) into interpretable features. Sparse Autoencoders (SAEs) are a leading technique for this, leveraging the superposition hypothesis—the idea that models represent more concepts than they have dimensions by using sparse, non-orthogonal directions.

However, standard SAEs face a fundamental trade-off. To enforce sparsity, they employ an L1 penalty during training. This penalty acts as a "tax" on feature activations, systematically pushing their magnitudes toward zero. This phenomenon, known as shrinkage, results in a systematic underestimation of feature strengths, which degrades reconstruction fidelity. Essentially, the model is forced to choose between being sparse and being accurate.

Illustration of shrinkage: the L1 penalty (black dashed line) shifts the optimal reconstruction away from the true value (red dot), introducing bias.

Methodology: Decoupling Detection and Estimation

The Gated SAE architecture addresses shrinkage by separating the encoder's functionality into two distinct roles:

  1. Gating (Detection): Determining which features are active.
  2. Magnitude (Estimation): Estimating how strong those active features are.

By using a gated architecture (inspired by Gated Linear Units), the L1 sparsity penalty is applied only to the gating path. This allows the magnitude path to estimate feature strengths without the biasing pressure of the L1 "tax." Mathematically, this architecture is equivalent to using a Jump ReLU activation function—a discontinuous function that stays at zero until a threshold is met, then "jumps" to a linear activation.

Because the gating function (a Heaviside step) has no gradient, the authors use an auxiliary loss that forces the gating path's pre-activations to be useful for reconstruction, ensuring the "gate" learns to open for the right features.

Results: Pareto Improvements Across Activation Sites

The researchers evaluated Gated SAEs across several models, including Pythia-2.8B and Gemma-7B, testing various activation sites such as MLP outputs, attention layer outputs, and residual stream activations.

Pareto curves showing Gated SAEs (red) consistently outperforming baseline SAEs (blue) across different activation sites. Gated SAEs achieve higher reconstruction fidelity with significantly fewer active features (L0).

Key findings include:

  • Pareto Improvement: Gated SAEs consistently outperform baselines, typically requiring half as many active features (L0) to achieve comparable reconstruction fidelity.
  • Solving Shrinkage: Quantitative analysis confirms that Gated SAEs produce virtually unbiased reconstructions, effectively eliminating the shrinkage observed in baseline models.
  • Interpretability: Blinded human evaluations indicate that features discovered by Gated SAEs are at least as interpretable as those from standard SAEs, ensuring that performance gains do not compromise clarity.
  • Compute Trade-off: While Gated SAEs require about 50% more compute per training step due to the auxiliary loss, this is a small price to pay for the massive gain in feature quality and sparsity.

Conclusion

Gated SAEs represent a significant advancement in dictionary learning for mechanistic interpretability. By decoupling feature detection from magnitude estimation, they overcome the inherent biases of L1 regularization. While the training process is more complex, the resulting improvement in feature quality provides a more accurate and efficient lens into the internal representations of LLMs. Future work will explore applying these techniques to even larger models and complex circuit-finding tasks.

Reference: Rajamanoharan, S., Conmy, A., et al. (2024). Improving Dictionary Learning with Gated Sparse Autoencoders. arXiv:2404.16014v2.

Summary updated

BibTeX
@inproceedings{rajamanoharan2024improving,
  author = {Senthooran Rajamanoharan and Arthur Conmy and Lewis Smith and Tom Lieberum and Vikrant Varma and János Kramár and Rohin Shah and Neel Nanda},
  title = {{Improving Dictionary Learning with Gated Sparse Autoencoders}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=zLBlin2zvW},
}
Figure