The Logit Lens is a mechanistic interpretability technique that applies a transformer's final unembedding matrix directly to the residual stream activations at each intermediate layer. By multiplying the hidden state at layer L by the output projection matrix, it decodes the model's current 'best guess' for the next token before the computation has completed, revealing how predictions crystallize through the network's depth.
Glossary
Logit Lens

What is Logit Lens?
A diagnostic method for interpreting transformer language models by projecting intermediate residual stream states into vocabulary space to reveal the model's evolving next-token predictions layer by layer.
Unlike the Tuned Lens, which learns an affine transformation per layer for more accurate decoding, the raw Logit Lens uses the unmodified unembedding matrix. This makes it a zero-overhead diagnostic tool for identifying where specific linguistic or factual knowledge emerges. It is a foundational method in circuit analysis and transformer mechanistic analysis, allowing researchers to observe the iterative refinement of predictions from generic priors to context-specific outputs.
Key Characteristics of the Logit Lens
The logit lens is a mechanistic interpretability technique that applies the final unembedding matrix directly to intermediate residual stream activations, revealing the model's evolving next-token predictions layer by layer.
Direct Unembedding of Hidden States
The core mechanism bypasses the final layer norm and unembedding step. For each layer l, the residual stream activation h<sub>l</sub> is multiplied directly by the unembedding matrix W<sub>U</sub> to produce logits. This reveals what the model would predict if it stopped early, exposing the iterative refinement process. The technique requires no additional training or learned parameters, making it a zero-cost diagnostic tool.
Layer-wise Prediction Trajectory
Applying the logit lens across all layers produces a trajectory of predictions. Early layers typically output nonsensical or low-confidence tokens, reflecting local syntactic processing. Middle layers often converge on the correct semantic category. Final layers refine the exact token identity. This trajectory visualizes the progressive sharpening of the output distribution as information flows through the residual stream.
Distinction from the Tuned Lens
The logit lens applies the unembedding matrix without any learned transformation, which can produce noisy or distorted logits due to representational drift across layers. The tuned lens improves on this by learning an affine transformation for each layer's hidden state before unembedding. This distinction is critical: the logit lens reveals raw representational content, while the tuned lens provides a more accurate but less direct projection.
Identifying the 'Logit Lens' Layer
Researchers often identify a specific layer where the logit lens output most closely matches the model's final prediction. This 'logit lens layer' is where the model has effectively settled on its answer, with subsequent layers performing minor refinements or confidence calibration. In GPT-2 style models, this often occurs around layers 10-14 out of 24, indicating that substantial computation is dedicated to output polishing rather than core reasoning.
Causal Intervention for Circuit Analysis
The logit lens enables causal experiments by patching intermediate activations. An analyst can take the residual stream from a corrupted input at layer l and patch it into a clean forward pass, then use the logit lens to observe how the prediction shifts. This isolates the causal contribution of specific layers to the final output without requiring full ablation studies, accelerating circuit discovery workflows.
Detecting Hallucination Precursors
By examining logit lens outputs during factual recall tasks, researchers can identify early divergence points where the model begins predicting incorrect tokens. This divergence often occurs in middle layers, well before the final output, providing a potential signal for real-time hallucination detection. The technique reveals that factual errors are not sudden final-layer mistakes but the culmination of an incorrect trajectory initiated much earlier.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
A technical deep dive into the logit lens technique for decoding intermediate transformer representations. These answers address the most common questions from researchers and engineers applying mechanistic interpretability to audit model behavior.
A logit lens is a mechanistic interpretability technique that decodes a transformer's intermediate residual stream activations into next-token probability distributions by applying the model's final unembedding matrix directly to those activations. The core mechanism works as follows: at any given layer L, you take the residual stream vector h_L (the accumulated representation after layer L's output has been added) and multiply it by the unembedding matrix W_U (also called the output embedding or lm_head). This produces logits—raw scores for every token in the vocabulary—which can be softmaxed into a probability distribution. The insight is that the residual stream is a linear accumulation of information, and the unembedding matrix is a linear map from representation space to vocabulary space. Because both operations are linear, you can project any intermediate state into token space to see what the model 'believes' at that point in its forward pass. This technique was popularized by the nostalgebraist blog and has become a foundational tool for understanding how predictions evolve layer by layer in large language models.
Related Terms
Core techniques and concepts for decoding the internal computations of transformer models using the logit lens and related methods.
Tuned Lens
A direct refinement of the logit lens that learns an affine transformation for each layer's residual stream before applying the unembedding matrix. This corrects for systematic biases in intermediate representations, producing more accurate next-token predictions and revealing sharper, less noisy logit distributions at early layers.
Residual Stream
The central information highway in a transformer where each layer reads from and writes its output back to a shared, accumulating state vector. The logit lens operates by applying the unembedding matrix directly to this stream at each layer, treating it as a progressively refined prediction that converges toward the final output distribution.
Direct Logit Attribution
A linear decomposition technique that attributes the final logit output for a token to the individual contributions of each attention head and MLP layer. Unlike the logit lens which decodes the residual stream state, this method isolates the exact additive contribution each component makes to the final prediction.
Probing Classifier
A simple supervised model trained on a network's internal activations to predict a specific linguistic or world property. While the logit lens uses the model's own unembedding matrix to decode predictions, probing classifiers test whether arbitrary information—like part-of-speech or sentiment—is linearly encoded in intermediate representations.
Activation Patching
A causal intervention technique that replaces a model's internal activation at a specific layer and position with a value from a corrupted forward pass. Used alongside the logit lens to verify whether decoded intermediate predictions causally influence the model's final output, rather than being epiphenomenal artifacts.
Unembedding Matrix
The final linear transformation in a transformer that maps the residual stream vector to a vocabulary-sized logit distribution. The logit lens exploits this matrix by applying it prematurely to intermediate layer activations, revealing how the model's next-token prediction evolves layer by layer before the final softmax.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us