Foundation reference

Logit Lens: Probing Intermediate Representations

The logit lens applies a transformer’s output layer to its intermediate hidden states. It shows the token predictions those states produce at each layer, without additional training.

Concept 46 of 100RepresentationsStudy phase 5
Key equation
logits(l)=WU LNf(h(l))\text{logits}^{(l)} = W_U \, \mathrm{LN}_f\big(h^{(l)}\big)
Reading map and next steps

Study guide

Where to start

Concept 46 of 100Logit LensRepresentations · Study phase 5: Representation & interpretability
Question

Why can the unembedding matrix serve as a probe that needs no training, and what does that assume about how intermediate layers represent information?

How to study this pagePredict · Check · Generalize · Continue
PredictSay what you expect.

Pick a concrete input and say what the equation should give before you read the math.

CheckCheck against the math and the papers.

Work through the math, then read the cited papers for the original argument.

GeneralizeName what stays the same.

Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.

ContinueFollow the connections.

Use the prerequisites and related concepts at the end of the page to fill the next gap.

Why It Matters for Modern Models

  • The logit lens applies a transformer’s output layer to its intermediate hidden states. It shows the token predictions those states produce at each layer, without additional training.
  • In GPT-2 it showed predictions forming gradually, with intermediate layers often already close to the final answer (nostalgebraist, 2020).
  • It is the starting point for trained decoders such as the tuned lens, which Belrose et al. (2023) report to be more predictive and reliable than the raw logit lens.

Questions to Think About

  • Why do some layers, and some models, give meaningless tokens under the logit lens even though they carry useful information?
  • What does a learned affine map per layer (the tuned lens) correct for, and why does it work better than the raw logit lens?

Core Math

Key Equation
logits(l)=WU LNf(h(l))\text{logits}^{(l)} = W_U \, \mathrm{LN}_f\big(h^{(l)}\big)

The logit lens decodes an intermediate residual-stream state with the model's own output layer, as if the network ended at that layer:

logits(l)=WU LNf(h(l))\text{logits}^{(l)} = W_U \, \mathrm{LN}_f\big(h^{(l)}\big)

where h(l)h^{(l)} is the residual stream after layer ll, LNf\mathrm{LN}_f is the final layer normalization and WUW_U is the unembedding matrix. The corresponding next-token distribution is

p(l)(token)=softmax(logits(l))p^{(l)}(\text{token}) = \text{softmax}(\text{logits}^{(l)})

Following p(0)→p(L)p^{(0)} \to p^{(L)} shows how the prediction forms across layers. In GPT-2, nostalgebraist (2020) found that predictions move gradually toward the final output.

Tuned lens. Belrose et al. (2023) train a separate affine map for each layer before decoding,

logits(l)=WU LNf(Alh(l)+bl)\text{logits}^{(l)} = W_U \, \mathrm{LN}_f\big(A_l h^{(l)} + b_l\big)

which corrects for intermediate layers not representing information in exactly the same basis as the final layer.

Key Papers

interpreting GPT: the logit lens

nostalgebraist2020LessWrong
Read paper →

Eliciting Latent Predictions from Transformers with the Tuned Lens

Belrose et al.2023arXiv
Read paper →

Connections

Where to go next

Capability Elicitation builds directly on Logit Lens.

Capability Elicitation