Abstract
Transformer models have become the backbone of modern natural language processing, yet their internal decision-making processes remain opaque. This paper introduces a novel framework for interpreting Transformer predictions by decomposing final logits into layer-wise contributions from specific input tokens. By utilizing the "residual stream" perspective and the ALTI (Aggregation of Layer-wise Token Interactions) method, the authors provide a linguistically grounded explanation of how context drives model decisions. Experimental results across various benchmarks, including BLiMP and Indirect Object Identification, demonstrate that this approach significantly outperforms traditional gradient-based saliency methods in faithfulness and alignment with human intuition.
Introduction
While Transformers have revolutionized NLP, they remain largely "black boxes." We can see what they predict, but understanding why—specifically, which parts of the preceding text influenced a choice—is difficult. Existing "saliency" or "attribution" methods often produce noisy results that do not align well with human linguistic intuition. This research addresses this gap by proposing a method to trace the influence of preceding text through the model's layers to its final output, focusing on the complex objective of language modeling.
Methodology: Logit Decomposition and ALTI
The core of the proposed framework lies in viewing the Transformer as a series of modules—Self-Attention and Multi-Layer Perceptrons (MLPs)—that "write" updates to a central information highway known as the residual stream.
The authors show that the final prediction score (the logit) for a word is the sum of updates from every layer's blocks plus the initial embedding. To handle the mixing of information that occurs in middle layers, where a token representation becomes a mixture of many previous tokens, the authors employ ALTI (Aggregation of Layer-wise Token Interactions). This allows them to track mixed signals back to original input tokens. Furthermore, the framework utilizes contrastive explanations, asking why the model chose a specific word $w$ instead of a "foil" $f$ (e.g., "has" vs. "have"), pinpointing the exact context tokens that favored the correct grammatical choice.
Experimental Setup
The researchers evaluated their method across several benchmarks designed to test specific linguistic capabilities:
- BLiMP (Benchmark of Linguistic Minimal Pairs): A collection of 67,000 sentence pairs differing by a single grammatical feature (e.g., "The cat sits" vs. "The cat sit").
- Subject-Verb Agreement (SVA): Testing long-distance dependencies between subjects and verbs.
- Indirect Object Identification (IOI): Sentences where the model must identify the correct recipient (e.g., "Alice gave a book to Bob; Alice gave it to...").
- NMT Alignments: A German-English translation dataset used to see if the model's internal logic matches human-annotated word alignments.
Results and Discussion
The ALTI-Logit method demonstrates superior alignment with linguistic evidence compared to standard baselines like Gradient Norm or Input Erasure.
Key findings from the evaluation include:
- Linguistic Alignment: The method correctly identifies that the model relies on the "head" of a subject to determine verb agreement. On the GPT-2 Small model, ALTI-Logit achieved higher Mean Reciprocal Rank (MRR) alignment scores across almost all BLiMP categories.
- The Role of MLPs: MLP layers are not just random processing units; they learn specific "features" that promote grammatical correctness, such as pushing for singular nouns after seeing a singular determiner.
- Layer-wise Evolution: Predictions are not formed instantly; the model's "confidence" (the logit difference) often peaks in specific middle-to-late layers once enough contextual information has been integrated.
- NMT Breakthrough: For machine translation, the proposed method achieved an Alignment Error Rate (AER) of 26.0, a massive improvement over raw attention weights (48.6) and other specialized alignment extraction methods.
Conclusion and Future Work
This framework provides a powerful "debugging tool" for researchers to understand the internal mechanics of Transformers. While currently focused on English and well-defined linguistic rules, the authors suggest that this method is best suited for researchers to explore how logit updates change during fine-tuning or RLHF. Future work aims to extend this analysis to even larger models like GPT-4 or Llama-3 and explore more abstract or creative generation tasks.
Summary updated