AI Glossary / Natural language and speech / Advanced

Logit lens

Definition

The logit lens is an interpretability technique that maps intermediate language-model representations into vocabulary scores using the model's output readout. It lets researchers inspect token predictions suggested by selected internal states. The result is a diagnostic projection, not a complete transcript of the model's reasoning.

What it means

A transformer language model normally produces its final token distribution after passing information through many layers. The logit lens applies a similar vocabulary readout at earlier points, showing which tokens receive high scores at those points.

The technique was introduced under this name by nostalgebraist in a 2020 post about GPT-2. It offers an accessible way to visualize changes across network depth, such as when a particular candidate becomes prominent in the projected distribution.

The interpretation requires care. An earlier representation was not necessarily trained to be read directly by the final output head. Strange early-layer predictions may reflect a poor match between representation and readout rather than an absence of useful information in that layer.

How it works

A researcher chooses a model, prompt, token position and set of internal checkpoints. For a common pre-normalized transformer formulation, the lens applies the appropriate final normalization to a residual-stream state, then the vocabulary projection or unembedding. Softmax can convert the resulting scores into a distribution.

Repeating this at successive layers produces a sequence of diagnostic readouts. A visualization might show the highest-ranked token, a selected token's rank, or distance from the final distribution. Those summaries emphasize different information; showing only the top token hides near-ties and the rest of the distribution.

Implementation details matter, including whether the state is captured before or after a block and how normalization is handled. A successful final-layer consistency check helps detect mistakes in the readout procedure.

The tuned lens is a related extension that learns layer-specific transformations before applying the output readout. It addresses some mismatches identified in research, but it is a different probe with additional training and evaluation requirements.

Three practical examples

  • An interpretability researcher tracks when a candidate next token becomes highly ranked in a specified model's projected states.
  • A model-debugging team compares lens trajectories for two carefully controlled prompts before investigating a difference with additional methods.
  • A teaching notebook illustrates vocabulary projections across transformer layers while explicitly separating those projections from causal explanations.

Think of it this way

Think of viewing work in progress through a display designed for the finished product. The display can reveal useful patterns, but some intermediate material may not fit its expected format.

The analogy has limits: model states are vectors, not draft sentences written by an inner author. A visible token label is produced by the chosen readout, and useful information can remain invisible through that particular lens.

Worked example

Reading a small diagnostic distribution

Consider an entirely invented toy vocabulary containing only A, B and C. At one intermediate checkpoint, suppose the lens returns logits [0, ln(2), ln(3)]. Softmax produces probabilities [1/6, 2/6, 3/6], so C ranks first with probability 0.5.

At a later checkpoint, suppose the readout is [0, ln(5), ln(4)]. The probabilities become [0.1, 0.5, 0.4], and B now ranks first. This demonstrates a change in the projected ranking; it does not show that the model consciously changed its mind or that B is factually correct.

The toy vocabulary makes normalization explicit. If A, B and C were merely three selected tokens from a larger vocabulary, normalizing only their scores would produce a conditional comparison within that subset, not their actual full-vocabulary probabilities. A real lens report must state which distribution it displays.

Illustrative case study

A fictional research team investigates why a model completes two nearly identical prompts differently. Its logit-lens plots show a candidate rising earlier for one prompt than for the other. The first interpretation attributes the difference to a particular layer having learned a fact.

The team revises that claim after checking the readout convention and examining more examples. It treats the plot as a hypothesis generator and designs controlled interventions to test which computations affect the final output. It also compares a trained probe because intermediate representations may not match the final readout well.

The lesson is that a clear visualization can direct investigation without establishing a causal mechanism. The fictional comparison does not report an actual model finding or claim that either probe fully explains the behavior.

Common misconceptions and mistakes

  • The logit lens reveals every internal computation. It exposes only information visible through a particular projection.
  • A top token at one layer proves the model believes a proposition. A vocabulary readout does not establish a belief or factual endorsement.
  • Nonsensical early output proves the layer is useless. The readout may be poorly matched to the representation.
  • A trajectory alone proves causation. Additional controlled evidence is needed to explain why an output occurred.

Business use

For organizations, the logit lens is mainly a research and diagnostic tool. It can make internal-state comparisons easier to inspect, but it should not be presented as a ready-made audit certificate or a complete explanation for end users.

Require reports to name the model, prompt, token position, layer convention, normalization and readout method. Check whether the observed pattern holds across relevant examples and whether the method is informative for that architecture. If a claim concerns causal influence, ask for evidence beyond a sequence of projected token labels. Preserve the distinction between the model's final prediction and the probe's intermediate readout.

People also ask

Does the basic logit lens need a newly trained probe?

It reuses the model's output readout; unlike a tuned lens, it does not learn separate layer translators.

Does it work equally well on every model?

No. Research documents substantial variation and biased or uninformative intermediate readouts.

Is it the same as reading attention weights?

No. It projects hidden representations into vocabulary space rather than displaying attention relationships.

Check your understanding

A token is absent from a layer's top-five lens readout. Does that prove the layer contains no information relevant to that token?

Answer: No. The information may not be accessible through this readout, and a top-five display also hides lower-ranked distribution information.

Related terms

  • Logit
  • Residual stream
  • Unembedding
  • Interpretability
  • Probing
  • Softmax
  • layer normalization
  • tuned lens
  • causal intervention

Learn next

Inspect a small lens visualization alongside the final token distribution. Identify the checkpoint and normalization conventions, then formulate a testable hypothesis while separating the observed projection from any causal explanation.

More in Natural language and speech

  • Log probabilities - Log probabilities are logarithms of probabilities.
  • Logic form - A logic form, in the NLP convention covered here, is a structured representation of a sentence using predicates and shared arguments.
  • Logistic function - The logistic function maps a real-valued input to an S-shaped output.
  • Lookahead in regex - Lookahead in a regular expression checks whether a pattern does or does not match at the current position without consuming the characters inspected.
  • Loudness - Loudness is the perceived strength of a sound, from quiet to loud.
  • Low frame rate - Low frame rate in speech recognition means processing or emitting acoustic-model representations at fewer time steps per second than a reference configuration.

Sources

nostalgebraist, interpreting GPT: the logit lens: https://www.lesswrong.com/posts/AcKRB8wDpdaN6v6ru/interpreting-gpt-the-logit-lens. Original method and caveats. Belrose and colleagues, Eliciting Latent Predictions from Transformers with the Tuned Lens: https://arxiv.org/pdf/2303.08112. Readout bias, representation mismatch and trained translators. Toy distributions are original calculations.

Previous: Logit Next: Logits

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer