Skip to content

Eliciting Latent Predictions from Transformers with the Tuned Lens

optionalextendedfundamentalpaperrubric 8/122023 · ~25 min

Nora Belrose, Igor Ostrovsky, Lev McKinney, …, Jacob Steinhardt

Status

TL;DR. The logit lens, an informal 2020 LessWrong technique, decodes an intermediate hidden state by applying the final layer norm and unembedding to it. That works poorly on many models. The tuned lens learns one affine “translator” per layer and trains it to match the model’s own final distribution. The result is a cleaner, more reliable picture of how the prediction forms layer by layer.

TunedLensℓ(hℓ)=LogitLens(Aℓhℓ+bℓ),min⁡Aℓ, bℓ Ex DKL(f>ℓ(hℓ) ∥ TunedLensℓ(hℓ)).\mathrm{TunedLens}_\ell(h_\ell) = \mathrm{LogitLens}(A_\ell h_\ell + b_\ell), \qquad \min_{A_\ell,\, b_\ell}\ \mathbb{E}_x\, D_{\mathrm{KL}}\big(f_{>\ell}(h_\ell)\,\|\,\mathrm{TunedLens}_\ell(h_\ell)\big).

Here f>ℓf_{>\ell} is the rest of the network. The bias bℓb_\ell stands in for the expected sum of later residual updates, which the logit lens implicitly sets to zero. The matrix AℓA_\ell corrects for representational drift, where the hidden-state covariance changes with depth (§3).

The paper shows that intermediate layers already contain a smoothly sharpening prediction once you translate their basis. Lenses also transfer: a lens trained on LLaMA 13B works on its fine-tuned descendant Vicuna 13B with little increase in KL (§5, App. A). The causal basis test finds no direction that is influential for the lens but not for the model (§4.1).

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Starting from the residual-stream identity h_L = h_ℓ + Σ over later layers of their outputs F_ℓ′(h_ℓ′), derive the logit lens as "set the remaining residual updates to zero", then show step by step how the debiased lens and the tuned lens (A_ℓ h_ℓ + b_ℓ) relax that assumption. Why is KL to the final layer, rather than cross-entropy to the true next token, the right training target?

    What a strong answer covers
    • Logit lens: LogitLens(h_ℓ) = LayerNorm(h_ℓ) W_U, which equals the final readout if all later residual updates sum to zero.
    • If later layers add a nonzero average residual, zero is an arbitrary replacement; the debiased lens adds a learned constant b_ℓ standing in for that expected sum.
    • Hidden-state covariance drifts across layers (including rogue high-variance dimensions), so a learned change of basis A_ℓ maps layer ℓ's space into the final layer's input space.
    • Training minimises KL(final-layer distribution ‖ lens distribution), a distillation target; using true labels would let the probe learn information the model itself does not use at that layer (the Hewitt & Liang concern).
  2. Mechanism

    The paper checks that the tuned lens is causally faithful with "causal basis extraction": it finds directions that matter for the lens and erases them from the model. Explain what this test measures and why a Spearman ρ of 0.89 between lens influence and model influence (Pythia 410M, layer 18) is evidence that the lens reads features the model actually uses.

    What a strong answer covers
    • For each extracted direction, erase it from the hidden state and measure the change in the lens output (influence on the lens) and in the model's final output (influence on the model).
    • A faithful lens should depend on the same directions as the model; a high rank correlation means directions that matter to one matter to the other.
    • The paper reports no features that are influential for the lens but not for the model, which would indicate the lens relies on directions the model ignores.
    • Limit: correlation over a set of extracted directions is evidence of alignment, not proof that every lens readout reflects the model's computation.
  3. Design

    The authors detect prompt injections by running an anomaly detector on tuned-lens prediction trajectories. Design a similar trajectory-based monitor for a RAG system that flags when a retrieved passage overrides the model's parametric answer.

    What a strong answer covers
    • Record per-layer tuned-lens distributions for the answer tokens, with and without the retrieved passage in context.
    • Features: the layer at which the top prediction changes, KL between consecutive layers, and the late-layer divergence between the with-context and without-context trajectories.
    • Train an anomaly detector or classifier on labelled cases (passage agrees, passage conflicts, injected instruction) and evaluate with AUROC on held-out passages.
    • Caveat: the lens is trained on pretraining-style text and may need retraining on the chat or RAG distribution; validate that trajectories differ for the right reason with patching.

Done with this page?

Status