Inferensys

Glossary

Logit Lens

A decoding technique that applies the unembedding matrix directly to intermediate residual stream states, allowing researchers to inspect a model's iterative token predictions before the final layer.
Engineer reviewing vector database search results on laptop, embeddings visualization on screen, home office coding session.
EARLY DECODING TECHNIQUE

What is Logit Lens?

A model probing method that applies the unembedding matrix directly to intermediate residual stream states to reveal a transformer's iterative token predictions before the final layer.

Logit Lens is a decoding technique that applies the unembedding matrix directly to the intermediate states of a transformer's residual stream, converting hidden representations into vocabulary probability distributions at every layer. This allows researchers to inspect the model's evolving "belief" about the next token throughout the forward pass, rather than only at the final output.

By revealing how predictions are iteratively refined, Logit Lens helps diagnose where specific knowledge is computed and how attention heads and MLP layers contribute to the final output. It is a foundational tool in mechanistic interpretability, often used alongside causal tracing and activation patching to localize factual recall and reasoning circuits.

INTERPRETABILITY TECHNIQUE

Key Characteristics of the Logit Lens

The Logit Lens is a diagnostic tool that applies the final unembedding matrix directly to intermediate residual stream states, revealing a model's evolving token predictions layer by layer.

01

Direct Residual Stream Decoding

The technique operates by taking the hidden state from a specific layer's output and multiplying it by the unembedding matrix (the final linear projection). This bypasses all subsequent layers, producing a probability distribution over the vocabulary as if the model stopped at that point. The core insight is that the residual stream is a linear space where the unembedding matrix can be meaningfully applied at any depth, not just the final layer.

02

Iterative Prediction Refinement

Applying the Logit Lens at successive layers reveals a model's progressive refinement of its final prediction. Early layers often show nonsensical or low-confidence tokens, while middle layers begin to surface semantically related candidates. The final layers typically perform confidence calibration, sharpening the probability distribution. This provides a window into the model's step-by-step construction of an answer before it is formally output.

03

Zero-Training Diagnostic

Unlike linear probing, the Logit Lens requires no auxiliary classifier training. It reuses the model's native unembedding matrix, making it a lightweight, immediate diagnostic. This eliminates the risk of the probe itself learning a task the model hasn't, providing a more faithful readout of the model's current belief state. It is a purely inference-time intervention that leaves all model weights frozen.

04

Early Exit Signal Analysis

By examining the top predicted tokens at each layer, researchers can identify the exact point where a model 'locks in' on a fact or a grammatical structure. For example, in a factual recall task, the correct answer token often first appears in the top predictions of middle layers, long before the final output. This helps localize where specific computations, such as entity binding or relation extraction, occur in the network.

05

Limitations and Norm Asymmetry

The Logit Lens assumes the residual stream's norm and geometry are consistent with the final layer's expectations, which is not guaranteed. Early layer representations often have a different L2 norm scale, leading to underconfident probability distributions. A common mitigation is to apply a learned temperature scalar or a norm correction factor to calibrate the logits before the softmax, improving the interpretability of early-layer predictions.

06

Contrast with Tuned Lens

The standard Logit Lens uses the same unembedding matrix for all layers, while the Tuned Lens variant addresses the norm mismatch by learning a separate, layer-specific affine transformation. This learned correction is trained via distillation to match the final layer's output distribution, providing a more calibrated view of intermediate states. The choice between them involves a trade-off between the Logit Lens's simplicity and the Tuned Lens's accuracy.

LOGIT LENS DECODING

Frequently Asked Questions

Direct answers to the most common technical questions about applying the unembedding matrix to intermediate residual stream states for early-exit interpretability.

A Logit Lens is an interpretability technique that applies a language model's final unembedding matrix directly to the intermediate hidden states of the residual stream, bypassing the final transformer layers. This allows researchers to decode the model's iterative token predictions at every layer, revealing how the probability distribution over the vocabulary evolves step-by-step. The mechanism works because the residual stream is a linear space where the unembedding matrix can project any intermediate state onto the vocabulary space, even if the model wasn't explicitly trained for early-exit predictions. By reading these 'early logits,' you can see that a model often settles on the correct answer many layers before the final output, providing a window into the model's internal reasoning timeline.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.