Abstract
DecoderLens is a zero-training interpretability technique designed for encoder-decoder Transformer architectures. By redirecting the decoder's cross-attention mechanism to intermediate encoder layers, the method projects abstract internal representations into human-readable text. This approach reveals how models progressively solve complex tasks such as logical reasoning, factual retrieval, and speech-to-text translation, providing a window into the iterative refinement process of large-scale models.
Introduction
While interpretability techniques like LogitLens have become standard for "reading the minds" of decoder-only models (e.g., GPT), encoder-decoder architectures like T5 or Whisper have remained relatively opaque. In these models, the encoder generates a complex representation that the decoder interprets. Because there is no direct link between the encoder's intermediate layers and the output vocabulary, understanding how a representation evolves through the encoder is challenging. Previous methods often relied on "probing"—training separate classifiers—which can be biased or unfaithful to the model's actual internal logic. DecoderLens addresses this by using the model's own decoder as a lens into its encoder.
Methodology
DecoderLens is a simple, zero-training method inspired by the LogitLens but adapted for cross-attention. In standard operation, a decoder attends to the final output of the encoder. DecoderLens swaps this final output for the output of an intermediate encoder layer. By running the full, pre-trained decoder on these "partial" representations, the model is forced to "explain itself" in natural language using its existing weights.
Experimental Setup
The researchers evaluated DecoderLens across four distinct domains:
- Factual Trivia: Predicting country capitals using Flan-T5 (large, xl, xxl).
- Propositional Logic: Assigning truth values to variables in complex logical formulas using the PropRandom dataset.
- Machine Translation: Using the NLLB-600M model on the Flores-101 benchmark.
- Speech-to-Text: Using Whisper (base, small, medium) on the CoVoST 2 dataset for transcription and translation.
Key Insights and Analysis
Iterative Refinement and the "Middle Layer Peak"
Analysis reveals that Transformers do not solve problems in a single step. Instead, they iteratively refine their hypotheses across layers. Surprisingly, for factual trivia, models like Flan-T5 often encode geographical information more accurately in their middle layers than in their final layers. This suggests that the final layers may be more focused on formatting the output for the specific prompt rather than retrieving the underlying facts.
Task-Specific Layer Dynamics
- Logic Tasks: Semantic accuracy is near-random for the first two layers but improves significantly at layer 4, where the model begins to prune irrelevant variables and focus on the core logical structure.
- Speech Processing: In models like Whisper, transcription (what was said) is resolved much earlier than translation (what it means). For a 24-layer model, coherent transcription typically emerges around layer 15, while the final layers are necessary to refine the translation and correct minor errors.
- Translation Syntax: Syntax and word order tend to stabilize very early in the encoder. However, for low-resource languages, the lens often produces repetitions, suggesting the decoder struggles to interpret intermediate representations it hasn't encountered during training.
Discussion and Limitations
The primary challenge for DecoderLens is representational drift. Because the decoder was trained exclusively on the final encoder layer, intermediate layers may appear as "gibberish," leading to hallucinations or empty strings even if the information is present. While tuning the lens could mitigate this, the authors maintain a "pure" approach to ensure the results remain faithful to the original model's weights. Future work may involve using DecoderLens as a diagnostic tool to pinpoint where models fail during complex calculations or applying it to Universal Transformers to study weight-shared representations.
Summary updated