Eliciting Latent Predictions from Transformers with the Tuned Lens
The logit lens reads a transformer's intermediate residual stream by pushing it straight through the final unembedding, but on many models this gives biased or meaningless early-layer predictions. Belrose et al. train a small affine 'translator' per layer so each intermediate state can be decoded into a next-token distribution, test that the directions the lens relies on are also ones the model uses, and apply the resulting prediction trajectories to detecting malicious inputs.
Ready to ace your system design interview?
This article is just one piece. StackSweep gives you structured, interview-focused practice across every topic that comes up in senior engineering rounds.
- 1,000+ quiz questions across system design and ML/AI
- Spaced repetition to lock in what you learn
- Full case study walkthroughs of real interview topics
- Track streaks, XP, and progress over time
TL;DR
- The logit lens decodes hidden states at every layer with the model's own final unembedding; it works surprisingly well on GPT-2 but poorly or misleadingly on several other model families.
- The tuned lens adds one learned affine map per layer, trained so the decoded distribution matches the model's final output distribution (a KL divergence objective), not the true next token.
- Tuned lens predictions are more accurate and less biased than the logit lens, and they sharpen smoothly toward the final answer across layers.
- Causal basis extraction checks that the directions the lens relies on also matter to the model, addressing the worry that a trained probe just learns its own features.
- The sequence of per-layer predictions (the trajectory) can be used to detect prompt injection and similar anomalous inputs, and to estimate how hard an example is.
Why this paper matters
Lens methods are a cheap first look inside a model and show up constantly in interpretability work and in debugging. A research engineer should be able to explain why the logit lens can mislead, what training a lens changes, and why a trained readout raises the 'is this the probe or the model?' question.
Breakdown
1.The logit lens and why it breaks
Recall that the residual stream is a running sum: each layer adds its output, and the final state goes through a layer norm and the unembedding matrix to produce logits. The logit lens, introduced in a 2020 blog post by nostalgebraist, simply applies that final layer norm and unembedding to the residual stream at an earlier layer. If the residual stream has a stable 'meaning' across layers, this should show what the model would predict if it stopped there.
On GPT-2 the results are striking: the correct next token often surfaces several layers before the end. But the authors show that on other model families the logit lens gives early-layer predictions that are close to nonsense, and that even where it works, its predictions are systematically biased toward certain tokens relative to the final output.
The underlying reason is that nothing forces intermediate layers to use the same basis as the last layer. Later layers can rotate, rescale or shift the representation, and some directions in early layers carry information the unembedding was never trained to read. This is what the authors call representational drift across layers.
Discussion angle: A good question is why the logit lens works at all. The residual connection biases layers toward small incremental updates, so later states stay roughly aligned with earlier ones. Then ask: on which architectures would you expect it to fail, and how would you detect failure without ground truth?
2.The tuned lens: a learned translator per layer
The fix is minimal. For each layer, learn an affine map (a matrix and a bias) that translates that layer's residual state into something the final layer norm and unembedding can decode. The map is initialized to the identity, so the tuned lens starts as the logit lens and only learns corrections.
The training objective matters. The lens is not trained to predict the true next token. It is trained to minimize the KL divergence between its decoded distribution and the model's own final output distribution. In words: 'given only what is in the residual stream at layer l, what will the model end up predicting?' That keeps the lens a readout of the model rather than a separate predictor of the data.
The model itself is frozen; only the small per-layer translators are trained. The results are lower perplexity at every layer than the logit lens, predictions that converge smoothly to the final output, and much less of the token bias the logit lens shows. The authors released code and pretrained lenses for many open models.
Discussion angle: Interviewers probe the objective: why distill toward the model's final distribution rather than train on labels? Training on labels could let the lens become a better predictor than the model at that layer, reading information the model never uses. Ask also: an affine map is more expressive than identity; how much could it be inventing?
3.Is the lens reading the model, or doing its own work?
Any trained readout raises the classic probing worry: the probe might extract information that is present in the activations but not used by the model. A lens with a full matrix per layer has real capacity, so this concern is serious.
The authors address it with causal basis extraction (CBE). The method finds a set of directions in the residual stream that most influence the lens's output, then intervenes on those directions in the actual model and measures how much the model's final output changes. If the directions the lens depends on also strongly affect the model, the lens is plausibly reading features the model uses.
They report a strong correlation between a feature's influence on the lens and its influence on the model, which they call causal fidelity. They also show the tuned lens transfers reasonably to fine-tuned versions of the same base model, suggesting it captures something about the network's internal format rather than quirks of one checkpoint.
This does not make the lens a ground-truth readout. It is evidence that the lens's view is aligned with the model's computation on average, measured in the specific way CBE measures it.
Discussion angle: A strong researcher asks what result would falsify causal fidelity: directions that change the lens output a lot but barely move the model. They also ask whether fidelity holds equally at early layers, where the gap between lens and logit lens is largest and the translator does the most work.
4.Prediction trajectories as a signal
Running the tuned lens at every layer gives a trajectory: a sequence of next-token distributions that evolves from vague to confident. The authors use these trajectories for two applications.
First, anomaly detection. Inputs that hijack the model, such as prompt injection, can produce trajectories that look different from normal inputs even when the final output looks plausible. Feeding trajectory features into a simple anomaly detector, the authors report near-perfect detection on several prompt-injection tasks in their test settings, though a simpler baseline detector they compare against does as well or better on most tasks. The appeal is that the detector uses internal states, not just the output text.
Second, example difficulty. The layer at which the lens's prediction first settles on the final answer (prediction depth) correlates with how hard the example is, echoing earlier findings in vision models.
For safety, the first application is the interesting one. It is an early instance of monitoring a model's internal computation to catch inputs or behavior that the output alone might hide.
Discussion angle: Ask how the anomaly detector would fare against an adversary who knows about it. Detection on known attack types in a fixed setting says little about adaptive attacks. A good experiment: optimize injections to keep the trajectory in-distribution and see whether they still work.
5.Limits and where lens methods fit
A lens decodes the residual stream into the vocabulary. That is both its strength and its limit. It answers 'what token is this layer leaning toward?', not 'what intermediate concept is represented here?'. Much of what a model computes in middle layers (a person's birthplace, a plan for a later word, a syntactic role) is not a next-token prediction, so a vocabulary-shaped readout can miss it entirely.
The lens also gives one view per position and layer. It does not explain how a prediction was formed, only how it evolves. And the affine translators need training data from roughly the same distribution as the inputs you want to analyze.
In practice, lens methods are a fast, cheap first diagnostic: they show where in depth a behavior emerges, which narrows where to apply more expensive tools like activation patching or sparse autoencoders. Later work extends the idea in different directions, for example decoding hidden states by patching them into another forward pass, so the model itself describes what is encoded.
Discussion angle: Expect: 'The tuned lens shows the answer appears at layer 20. Does that mean the computation happens at layer 20?' Not necessarily: the information could be present earlier in a form the lens cannot decode, or the lens could be picking up a correlate. Confirm with patching at nearby layers.
Reading the evidence
What it shows
- The logit lens can give biased or meaningless intermediate predictions on several model families.
- A per-layer affine translator trained to match the model's final distribution gives more accurate and less biased intermediate predictions.
- Directions the tuned lens relies on also influence the model's output, by the causal basis extraction test.
- Per-layer prediction trajectories carry signal for detecting some anomalous inputs, such as prompt injections, in the settings tested.
What it does not show
- Where a computation happens: the lens shows when a decodable prediction appears, not which components produce it.
- Intermediate concepts that are not next-token candidates, which a vocabulary-space readout cannot see.
- That trajectory-based detection is robust to attackers who adapt to the detector.
- That a trained lens never invents structure; causal fidelity is evidence on average, not a guarantee per input.
The most boring explanation
The deflationary reading is that the tuned lens is just a well-regularized probe: give any affine map enough data and it will decode something predictive, so its smooth trajectories say more about the probe than the model. The authors take this seriously, which is why they train toward the model's own outputs and use causal basis extraction to show the lens's key directions also drive the model.
Key Concepts
Logit lens
Decoding an intermediate residual stream state with the model's final layer norm and unembedding, with no training.
Tuned lens
The logit lens plus a learned affine translator per layer, trained to match the model's final output distribution.
Analogy: Like reading a draft written in a slightly different dialect. The logit lens reads it as if it were the final language; the tuned lens learns a small phrasebook per draft stage first.
Representational drift
The tendency for the meaning of directions in the residual stream to change across layers, which breaks the logit lens's assumption of a shared basis.
Distillation objective (KL to final output)
Training each translator to reproduce the model's own final distribution rather than the true next token, keeping the lens a readout of the model.
Causal basis extraction
Finding directions that most influence the lens, then intervening on them in the model to check the model also depends on them.
Analogy: If a translator claims a word in the draft matters, you erase it from the actual draft and see whether the final text changes. If it does not, the translator was relying on something the author ignored.
Prediction trajectory
The sequence of per-layer decoded distributions for one input; its shape can flag anomalous inputs and indicate example difficulty.
Lessons that use this paper
Knowledge Check
10 questions — your answers are saved locally so you can come back anytime.