TL;DR
A transcoder is a sparse model that takes the input to one feedforward block of a transformer, called an MLP, and tries to predict that block's output. It uses a large set of features, and only a few are active for any one input. Because the target is the block's output rather than its input, each feature shows what the block computes, not only what the model happens to represent.
Builds on: Sparse Autoencoder, Transformer · Leads to: circuit tracing
Where it's used
Tracing circuits across layers. Interpretability researchers want to know how a language model turns an input into an answer, which requires following information from one layer to the next. Transcoders give each MLP block a set of named features, so a researcher can ask which feature in one block feeds which feature in the next. This is the main use the transcoder was built for.
Auditing a single layer. When a model behaves oddly, researchers can look at one MLP block and see which features it writes when a given input arrives. A feature that reads a certain pattern and writes a certain output direction is a candidate explanation for that behaviour, to be tested by changing the feature and watching the output.
Comparing with sparse autoencoders on the residual stream. A sparse autoencoder trained on the residual stream finds features of the stream as a whole. A transcoder finds features of one computation inside the stream. Teams that want both views run the two kinds of model side by side and check which features explain the behaviour they are studying.
How it works
A Transformer block has two parts, attention and an MLP. The MLP is a small two-layer network that runs at each position. It reads a vector from the residual stream, applies a nonlinearity such as ReLU, and writes a new vector back into the stream. A transcoder is trained to predict what the MLP writes, from what the MLP reads.
We trace a tiny instance with two-dimensional vectors. The MLP reads and writes . The transcoder has three features with decoder directions , and .
- Start with the MLP input. The MLP reads from the residual stream. Check: it has two coordinates, one per dimension of the stream.
- Record the MLP output. The real MLP computes and writes it back into the stream. This is the target the transcoder must predict. Check: the transcoder never sees the MLP's internal neurons, only and .
- Encode the input into features. Each feature reads with its own weights and a ReLU keeps the result zero or positive. Feature 1 reads the first coordinate and gives . Feature 2 reads the second coordinate with weight and gives . Feature 3 gives , because its input is negative. Check: the code is , with two features on.
- Decode the features into a prediction. The predicted output is . Check: the prediction equals , so the error is zero.
- Score the code with a sparsity penalty. The loss adds the prediction error to , the total of the feature activations. With , the penalty is . Check: a denser code would be penalised more, so training prefers the sparser one.
- Read the features. Feature 1 fires on inputs along the first coordinate and writes . Feature 2 fires on inputs along the second coordinate and writes . Because the target is the MLP output, each feature describes a change the block makes, not only a pattern it senses.
flowchart LR A["MLP input x (from residual stream)"] --> B["Transcoder encoder: sparse features f"] A --> C["MLP itself: output y"] B --> D["Transcoder decoder: prediction y-hat"] D --> E["Loss: prediction error plus sparsity penalty"] C --> E
The math
Let the MLP be the map , where is the normalised input to the block and is its output. A transcoder with features has an encoder with weights and biases , and decoder directions . Its activations and prediction are
Training minimises
where sets how strongly sparsity is rewarded. Because each is zero or positive, the penalty equals the norm .
Here is the block, is the length of a vector, and is the dot product. Real transcoders use many more features and dimensions, and they add their own bias terms, but the structure is the same as in the definition.
Step 1 and 2 in symbols
The input is and the target is . The transcoder is trained to match this , not . This is the difference from a Sparse Autoencoder, which would reconstruct itself.
Step 3 in symbols
With , and , all biases zero, the activations are , and .
Step 4 and 5 in symbols
The prediction is , so the squared error is . The sparsity term is , and the loss is .
Worked examples
- The MLP reads and writes . It acts as multiplication by 3.
- One feature with encoder weight and bias gives .
- Decoder direction gives , which equals . The error is .
- If the decoder were instead, and the error would be .
- With , the sparsity term is in both cases, so the decoder choice is what changes the loss.
Interpretation: the decoder direction carries the output, and the training loss rewards the one that matches what the block writes.
Keep the decoder atoms from the walkthrough. Now the MLP writes . Solving gives and . So and , for any between 0 and 1.
- Choose . Then and , so , and .
- Choose . Then and , so , and .
- Both codes reconstruct exactly, so the error is zero in both cases.
- The penalty with is for the first code and for the second.
- Training prefers the second code, which uses feature 1 not at all.
Interpretation: the sparsity term chooses among codes that are equally accurate. This is how the penalty turns many possible explanations into one readable one.
Suppose a transcoder trained on a language model has a feature with decoder direction , and on one input the feature activates with value 1.5. Its contribution to the block's output is .
- The feature's activation is , so it contributes to the predicted output.
- The rest of the features together predict , so the full prediction is .
- Setting the feature to zero removes that contribution and changes the prediction from back to .
- Interpretation: this feature moves the block's output by whenever it is active. A researcher who wants to test the feature would turn it off and check whether the model's answer changes in the way the feature's direction suggests.
Try it: a second feature has activation and decoder direction . What does it add to the predicted output?
Answer: . The feature adds 2 to the first coordinate and subtracts 2 from the second.
Common mistakes and tradeoffs
It is tempting to think a transcoder is just a sparse autoencoder with a different input. In fact the target is different. A sparse autoencoder reconstructs the vector it reads, so its features describe what the stream contains. A transcoder predicts what a block writes from what it reads, so its features describe a computation.
It is tempting to think transcoder features are the true features of the network. In fact they are an approximation, and the prediction error is never zero on real data. Behaviour can hide in that error, so researchers check the error and test features by changing them in the model itself.
It is tempting to think a sparser code is always easier to read. In fact too much sparsity loses accuracy, and too little leaves each feature doing many jobs. The weight is a tradeoff, and the right value depends on the question being asked.
When to use it: to study what one MLP block computes, or to trace features from one block to the next.
When not to use it: when the question is about what the residual stream represents as a whole. A sparse autoencoder on the stream is then the better tool. Transcoders also do not give exact model behaviour, so they cannot replace the model.
Alternatives: sparse autoencoders on the residual stream, analysis of individual neurons, and attribution methods that measure how much each part contributes to an output.
History
In 2022 Elhage and colleagues published "Toy Models of Superposition", which showed that a network can pack more features than it has neurons, so single neurons often mix unrelated concepts. In 2023 Bricken and colleagues used sparse autoencoders on a small transformer, in the work "Towards monosemanticity", to recover features that were easier to read than neurons. In the same year Cunningham and colleagues showed that sparse autoencoders trained on language model activations find interpretable features. In 2024 the transcoder idea appeared in work by Dunefsky, Chlenski and Nanda, who trained models that predict an MLP block's output from its input and showed that such features can be chained into circuits. The idea caught on because it targets the computation itself, which is what researchers need to follow a model's reasoning from layer to layer.
Recap
- A transcoder predicts the output of one MLP block from the block's input, using sparse features.
- Its training loss adds a sparsity penalty to the prediction error, so it prefers codes with few active features.
- Because the target is the block's output, its features describe what the block computes.
- Transcoders approximate the block, so their error has to be checked before any feature is trusted.
- Read next: mechanistic interpretability explains the wider goal of finding circuits, and the superposition paper explains why features need this kind of decomposition.
Check yourself
QuestionWhat is the input and what is the target of a transcoder, and how do they differ from a sparse autoencoder on the residual stream?Show answer
The input is the normalised input to one MLP block, and the target is that block's output. A sparse autoencoder on the residual stream takes the stream vector as both input and target. So the transcoder describes a computation, while the autoencoder describes a representation.
QuestionA transcoder has activations and decoder directions , , . What is the predicted output, and what is the sparsity term when ?Show answer
The prediction is . The sum of activations is , so the sparsity term is .
QuestionWhy does the sparsity penalty matter when two codes reconstruct the block output equally well?Show answer
The penalty is the only part of the loss that differs between them, so training chooses the code with the smaller total activation. This selects the explanation that uses fewer features, which is easier for a researcher to read.
QuestionA researcher finds a transcoder feature that is active on many different inputs and writes a similar direction each time. Why would they still check the prediction error before drawing a conclusion?Show answer
The feature is only an approximation of the block, and the prediction error is never zero on real data. If the error is large on the inputs where the feature is active, the feature may not describe what the block actually does there, so the conclusion needs to be tested by changing the feature in the model.