A transformer language model produces its next-token prediction only after many layers of computation. When that prediction is wrong or surprising, developers often want a more specific question answered: how did the model’s candidate tokens change as the input moved through the network?
The logit lens is a simple interpretability technique for exploring that question. Instead of waiting for the final layer, it takes an intermediate representation and passes it through the model’s final decoding machinery to obtain vocabulary logits. Repeating this across layers gives a rough view of how token predictions evolve with depth.
The technique is easy to implement, but easy to overinterpret. An intermediate hidden state was not necessarily trained to behave like a final hidden state, so its decoded token rankings are observations through a convenient projection, not a literal transcript of the model’s reasoning.
This article builds the logit-lens mental model from one next-token prediction, explains the projection step, and shows how to use layer-wise results without claiming more than they establish.
Start with the model’s normal output path
Consider an autoregressive transformer processing this prompt:
The capital of France isAt the final token position, each transformer block updates a vector in the model’s residual stream. Let the vector after the final block be h_L, where L is the number of blocks.
A simplified final decoding path is:
h_L -> final normalization -> output projection -> vocabulary logitsIf the vocabulary contains V tokens and the model width is d, the output projection maps a d-dimensional hidden vector to V logits. A softmax can turn those logits into probabilities, although token ranking can be inspected directly from the logits.
Suppose the final top candidates are:
Paris 12.8
Lyon 8.1
France 7.6The exact values here are illustrative. What matters is that the normal output path converts the final internal representation into scores over vocabulary tokens.
The logit lens asks: what happens if we apply essentially that same decoding step earlier?
Reuse the output projection at intermediate layers
Let h_l be the residual-stream representation after layer l at the position whose next token we want to inspect. A basic logit-lens projection can be written as:
z_l = W_U * norm(h_l) + b_Uwhere:
normrepresents the final normalization used by the model, when applicable;W_Uis the model’s output or unembedding matrix;b_Uis an output bias if the architecture has one;z_lis a vector of vocabulary logits decoded from layerl.
Architecture details differ. Some language models tie the output projection to the input embedding matrix, some use a separate matrix, and not every output head has a bias. A correct implementation should follow the actual model’s final decoding path rather than assuming one universal formula.
Applying the projection to several layers might produce a teaching example like this:
layer 4: the, a, France
layer 12: Paris, France, Lyon
layer 20: Paris, Lyon, Marseille
layer 28: Paris, Lyon, FranceThis does not mean layer 4 “thought the answer was the.” It means that when the layer-4 representation is decoded through the final output mapping, the receives the highest score among the inspected tokens.
That wording matters because the projection is an analysis tool imposed on an intermediate state.
Read trajectories instead of isolated tokens
A single layer’s top token is usually less informative than the trajectory across layers.
For each inspected layer, you can record quantities such as:
rank of the eventual final token
logit of the eventual final token
top-k decoded tokens
entropy of the decoded distributionSuppose the final model predicts Paris. Its layer-wise rank might look like:
layer 4: rank 83
layer 8: rank 19
layer 12: rank 2
layer 16: rank 1
layer 20: rank 1
layer 24: rank 1This trajectory supports a modest observation: under this projection, Paris becomes increasingly favored and eventually remains the top decoded candidate.
Now consider a different prompt where the final answer is wrong:
layer 8: correct token rank 7
layer 12: correct token rank 1
layer 16: correct token rank 2
layer 20: correct token rank 14
final: wrong token rank 1That pattern can identify an interesting region for deeper investigation. It does not by itself establish which component caused the later change. Attention heads, MLPs, normalization effects, and interactions among them can all contribute.
The logit lens is therefore useful for locating where a decoded prediction changes, not proving why it changes.
Compare logits carefully
Developers often convert every intermediate logit vector to probabilities and then compare percentages across layers. That can be useful, but it adds an interpretation that needs care.
Softmax is:
p_i = exp(z_i) / sum_j exp(z_j)A token’s probability depends on all vocabulary logits, not only its own score. If the scale or distribution of decoded logits changes across layers, a probability change can reflect more than a simple increase in evidence for one token.
For exploratory work, ranks and logit differences are often easier to reason about. For two candidate tokens a and b, inspect:
margin_l = z_l[a] - z_l[b]A positive margin means the projection favors a over b at that layer. Tracking the margin across depth can show when their ordering changes without treating the projected distribution as perfectly calibrated.
If probability values matter to the analysis, validate what those intermediate probabilities represent rather than assuming they have the same reliability as the model’s final output distribution.
The main limitation is representation mismatch
The logit lens reuses a decoder intended for the end of the network. Earlier residual-stream states may not be arranged in exactly the form that decoder expects.
This creates a representation mismatch. An intermediate state can contain information useful to later layers without making that information cleanly readable by the final unembedding at that point.
A simple analogy is a compiler pipeline. An intermediate representation may already encode the information needed for the final machine code, but interpreting that intermediate structure as if it were already machine code would be misleading. The conversion tool matters.
This is why noisy or implausible early-layer token rankings should not automatically be interpreted as confusion inside the model. The lens itself may be a poor decoder for that layer.
A related method, the tuned lens, addresses this problem by learning a separate affine translator for each layer of a frozen model before mapping the translated state to vocabulary predictions. That extra training can make intermediate predictions more faithful to the model’s later behavior, but it also changes the method: the result now depends on learned probes and their training data rather than only on the pretrained model’s existing output mapping.
Use the basic logit lens when its simplicity is valuable. Use a trained probe when the mismatch between intermediate and final representations is important enough to justify additional machinery.
Do not confuse readability with causal importance
A token becoming visible through the logit lens does not prove that the decoded feature caused the final output.
Imagine layer 10 strongly decodes to Paris, and layer 11 preserves that ranking. From the lens alone, you cannot conclude that a particular attention head in layer 10 supplied the decisive fact. The observed representation is the result of accumulated computation, and later components may use or ignore different directions within it.
This distinction separates two kinds of question:
observational: what information can this projection read here?
causal: what computation changes the model's actual behavior?The logit lens primarily answers the first kind.
For causal claims, pair observations with interventions. Depending on the research question, that may involve activation patching, ablation, controlled replacement of internal states, or another intervention that measures how changing a component affects the output. Those methods have their own assumptions, but they test a different and stronger claim than visualization alone.
Use the lens to narrow debugging work
The logit lens is most useful when it reduces a broad debugging problem to a smaller hypothesis.
Suppose a model consistently completes a product-support prompt with an outdated product name. Inspecting the eventual correct and incorrect tokens across layers could reveal three broad patterns:
A. the incorrect token dominates from early to late layers
B. the correct token emerges, then is displaced late
C. neither token is clearly readable until the final layersThese patterns suggest different follow-up questions. Pattern A may motivate checking whether the prompt or model strongly favors the outdated association. Pattern B points attention toward later computation. Pattern C warns against constructing an elaborate story from noisy early projections.
The lens does not diagnose the root cause on its own. Its practical value is that it can tell you where to spend more expensive interpretability effort.
For repeated analysis, automate the measurement rather than manually reading token tables. Record the same positions, layers, candidate tokens, and metrics across a dataset of prompts. Aggregate behavior can distinguish a recurring pattern from an attractive one-off example.
Common mistakes produce confident stories
The biggest risk with interpretability tools is not a syntax error. It is a plausible explanation that the measurement does not support.
Treating top tokens as internal thoughts
Decoded vocabulary tokens are outputs of a projection. Hidden states are vectors, not sentences waiting to be revealed. Describe what the lens decodes rather than assigning human-like private thoughts to a layer.
Ignoring the model’s real output head
Applying an arbitrary embedding transpose or omitting the model’s final normalization can make the analysis differ from the architecture’s actual decoding path. Inspect the model definition and reproduce the final head correctly.
Looking only at one prompt
One striking trajectory may be an edge case. Use multiple prompts, including controls and counterexamples, before claiming a stable behavior.
Equating correlation with mechanism
A decoded token can track the final answer without being causally responsible for it. Use interventions when the question is mechanistic rather than descriptive.
Comparing different models as if layers aligned
Layer 12 in one architecture is not automatically comparable to layer 12 in another. Depth, width, normalization, training, and representation geometry differ. Normalize the experimental question, not merely the layer number.
Know when a simpler tool is enough
The logit lens requires access to intermediate activations and the output projection. If you only have a hosted text-generation API, those internals may not be exposed. In that setting, behavioral evaluation, controlled prompting, and output-level metrics are more appropriate.
Even with full model access, the logit lens is unnecessary when the question is simply whether a model performs a task well. A held-out evaluation set directly measures that outcome. Interpretability becomes useful when you need to investigate internal prediction development, compare hypotheses about failures, or choose where to run more targeted experiments.
It is also not the right tool for proving that a model stores a fact in one specific layer. Information can be distributed, transformed, and redundantly represented. A layer-wise vocabulary projection provides one view of that representation, not a complete map of model knowledge.
Conclusion
The logit lens turns intermediate transformer states into vocabulary logits by reusing the model’s final decoding machinery. Its strength is simplicity: with access to hidden states and the output head, you can trace how decoded token rankings change across depth and identify layers worth investigating.
Its limitation follows from the same simplicity. Intermediate states were not necessarily designed to look like final states, and readable token rankings do not establish causal mechanisms. Treat the lens as an observational probe, compare trajectories rather than inventing stories from individual tokens, and use stronger probes or causal interventions when the question demands stronger evidence.