Neural networks are notoriously difficult to interpret, largely because their internal states are represented as dense, continuous vectors. In these continuous spaces, many different concepts are commingled together—a phenomenon known as superposition. This paper introduces codebook features, a method to refactor neural networks into sparse, discrete states by finetuning them with vector quantization bottlenecks. By replacing dense, continuous internal vectors with a small sum of interpretable "codes," the authors demonstrate that we can understand and causally steer model behavior with only modest performance trade-offs.
The Problem: Continuous States Hinder Understanding
In traditional software engineering, the principle of separation of concerns dictates that specific variables or states have clear, isolated meanings. If a program is tracking temperature, there is a discrete variable for it. Neural networks violate this principle. A single neuron might contribute to dozens of unrelated features, making it incredibly difficult to interpret what the model is "thinking" at any given layer or to control its behavior precisely without retraining.
The authors ask a fundamental question: Can we force a network to use a discrete, sparse "vocabulary" of internal states that are easier for humans to audit and manipulate, bridging the gap between the emergent algorithms of neural networks and the interpretable discrete states of traditional software?
Methods: The Codebook Bottleneck
To achieve this, the researchers introduce a structural constraint called a codebook layer. Instead of allowing a hidden layer to output any continuous vector, they force it to choose a sparse combination of vectors (codes) from a learned library (the codebook).
- The Bottleneck: For any given activation, the model identifies the top-$k$ most similar vectors in its codebook and replaces the original activation with their sum.
- Sparsity: The value of $k$ is kept very small (often $<1\%$ of the codebook size), creating a tight information bottleneck.
- Training via Finetuning: Rather than training from scratch, the authors take a pretrained model and finetune it using a dual loss function: the original task loss (e.g., next-word prediction) plus a reconstruction loss to ensure the codes stay close to the original activations.
- Optimization: To handle the non-differentiable "choice" of discrete codes, they employ a straight-through estimator, allowing gradients to bypass the discrete selection step during backpropagation.
Experimental Validation
The approach was evaluated across three distinct scales and domains:
- TokFSM: A synthetic dataset based on a Finite State Machine with 100 states, used to test if codebooks could resolve superposition in a controlled algorithmic environment.
- TinyStories: A dataset of simple children's stories used to train a 21-million parameter Transformer.
- WikiText-103: A larger corpus of Wikipedia articles used to finetune a 410-million parameter Transformer (Pythia-410m).
Key Insights and Results
- Resilience to Extreme Bottlenecks: Surprisingly, Transformers maintain high performance even when their internal communication is restricted to just a few discrete codes. Codebooks transmit far fewer bits of information than even 4-bit quantized activations, yet the models continue to function effectively.
- Solving Superposition: In the FSM task, the model successfully assigned distinct codes to specific states. While individual neurons were "messy" and overlapped (70.5% precision), the discrete codes were monosemantic—representing exactly one state—achieving 97.1% precision.
- Features as Points, Not Directions: Most interpretability research treats features as continuous "directions" in latent space. This paper treats them as discrete "points." This prevents "information smuggling," where a model hides extra data in low-magnitude, continuous activations.
- Causal Control and Steering: These codes are not just passive labels; they act as steering wheels. On WikiText-103, the authors identified codes for specific topics (e.g., "Video Games," "Football"). By manually activating these codes during text generation, they increased the frequency of those topics from a baseline of ~2-7% to 75-95%.
- Controlling Gender Bias: In the 410M parameter model, the researchers found 16 codes that control pronoun gender. Activating "male" codes shifted pronoun usage from a balanced baseline to 75% male, while activating "female" codes shifted it to 70% female.
Limitations and Future Directions
While promising, the codebook approach has limitations. The largest model tested was 410M parameters; it remains to be seen if the performance gap stays "modest" at the scale of frontier models (70B+ parameters). Additionally, like many vector quantization methods, the models suffer from "dead" codes—vectors in the library that never activate. Finally, while concrete concepts like "dragon" or "month of the year" are easy to isolate, more abstract reasoning steps might be harder to pin down to a single discrete code. Future work may explore applying this technique to multimodal models to investigate whether visual concepts can be similarly discretized.
Summary updated