Introduction
While Transformer models have fundamentally changed natural language processing, they remain largely "black boxes." Understanding why a model predicts a specific word in a sequence is critical for diagnosing issues like hallucinations or toxic output. Most existing interpretability research focuses on simple classification tasks. However, language generation involves a vast output space, making it difficult to trace how specific context words—such as a distant subject—influence the final choice of a verb. This paper introduces a novel method to track information flow from input tokens to final output probabilities, providing explanations that align with human linguistic logic.
Methodology
The core of the proposed approach is viewing the Transformer as a residual stream—an information highway where modules like Self-Attention and Multi-Layer Perceptrons (MLPs) write updates at each layer.
The authors introduce a two-step framework:
- Logit Decomposition: The final logit (the raw score before the softmax function) is mathematically decomposed into a sum of contributions from every MLP and Attention block across the network.
- ALTI-Logit: Standard attribution methods often overlook how word representations "mix" in deeper layers. By using ALTI (Aggregation of Layer-wise Token Interactions), the authors track this mixing, allowing them to attribute a logit update in a late layer back to the original input words, even after heavy processing.
Additionally, the method employs Contrastive Explanations to explain why a model chose a specific target word over a "foil" (e.g., choosing "has" instead of "have").
Experimental Setup
The method was validated across several linguistic benchmarks:
- BLiMP (Benchmark of Linguistic Minimal Pairs): Evaluates grammatical correctness in pairs like "The boy eats" vs. "The boy eat."
- SVA (Subject-Verb Agreement): Tests the model's ability to link verbs to subjects across distracting context.
- IOI (Indirect Object Identification): Requires identifying the correct recipient in complex sentences (e.g., "Alice gave a gift to Bob").
- NMT Evaluation: German-English translation tasks using the Europarl v7 corpus to assess source-target alignment.
Results and Discussion
The proposed ALTI-Logit method significantly outperforms traditional baselines in identifying the linguistic evidence used for predictions.
Key Insights
- Superior Alignment: As shown in the results, ALTI-Logit consistently achieves higher Mean Reciprocal Rank (MRR) scores than methods like Gradient Norm or Input Erasure. This indicates that its explanations are more grounded in actual linguistic structure.
- Layer-wise "Aha!" Moments: Models do not solve linguistic puzzles linearly. For instance, in GPT-2 Small, the final decision for Indirect Object Identification is primarily made in layers 10 and 11.
- MLPs as Functional Units: MLPs are shown to contain specific neurons that act as "grammar switches," promoting features like singular or plural agreement based on detected context.
- Human-like Logic in Translation: In machine translation, the method extracts alignments that closely mirror human translation logic, achieving an Alignment Error Rate (AER) of 26.0—nearly half that of standard attention weights (48.6).
Conclusion
This research provides a powerful tool for debugging Transformer models by "unmixing" the complex interactions within the residual stream. While currently focused on English and well-defined linguistic structures, the ability to trace predictions back to specific input tokens opens new avenues for "steering" models. Future work may involve manually adjusting internal "grammar switches" to prevent errors and improve the reliability of language generation.
Summary updated