TL;DR
GiLOT (Generative Language model Interpretation via Optimal Transport) is a novel feature attribution method designed specifically for the autoregressive nature of Large Language Models (LLMs). By using Optimal Transport to measure how masking an input token shifts the entire probability distribution of generated sequences—while accounting for semantic similarities between tokens—it provides significantly more faithful explanations than traditional methods like LIME or Integrated Gradients.
What Problem Does This Paper Address?
As LLMs become ubiquitous, understanding why they generate specific text is critical for trust, safety, and alignment. However, traditional "feature attribution" methods, which rank the importance of input tokens, were built for discriminative models like BERT that output a single label.
LLMs present two unique challenges that break these traditional methods:
- Semantic Nuance: LLMs output a probability distribution over a massive vocabulary. Standard metrics like KL Divergence treat a shift from "England" to "Britain" (synonyms) the same as a shift from "England" to "China" (distinct concepts). A faithful explainer needs to understand semantic distance.
- Autoregressive Complexity: A single input token doesn't just affect the next word; its influence ripples through the entire generated sequence.
Existing tools often fail to capture these dynamics, leading to "unfaithful" explanations that do not accurately reflect the model's internal logic.
Methods
The authors propose GiLOT, which treats feature attribution as a distributional shift problem. The workflow consists of three main stages:
- Token Masking: To measure the importance of an input token, the authors mask it and observe the change in the model's output.
- Marginalization via Beam Search: Because calculating every possible generated sequence is computationally impossible, GiLOT uses Beam Search to identify the top-$b$ most likely sequences. It then marginalizes these to estimate the probability distribution of tokens at each position in the output.
- Optimal Transport (OT): Instead of simple probability subtraction, GiLOT uses OT to calculate the "cost" of transforming the original output distribution into the masked one.
- Semantic Cost Matrix: The cost of "moving" probability from one token to another is defined by the cosine similarity of their embeddings.
- Efficiency Gains: To make OT feasible for real-time use, they employ the Sinkhorn-Knopp algorithm (a fast, iterative solver) and Dynamic Vocabulary Compression, focusing only on the top-100 tokens that typically carry 95% of the probability mass.
Datasets
The researchers evaluated GiLOT across several popular model families and benchmarks:
- Models: Llama-2 (7B, 13B), Llama-2-chat, CodeLlama, Alpaca-LoRA, and Vicuna.
- Evaluation Data: 100 prompts from the Alpaca dataset and ShareGPT.
- Use Case Analysis: The SST-2 (Stanford Sentiment Treebank) dataset was used to test how the model handles In-Context Learning (ICL).
Key Insights and Ideas
- Synonyms Matter: The move to Optimal Transport is a major conceptual shift. By embedding semantic distance into the attribution calculation, GiLOT avoids "over-penalizing" the model when it switches between semantically similar words, leading to a more "human-aligned" explanation.
- The "Attribution-guided Query Weight" (AQW): The authors introduced a metric to quantify how much a model relies on the query versus the in-context examples. They found that models with higher AQW (those that focus more on the specific query) are generally more accurate and less sensitive to the order of examples in the prompt.
- Bias Detection: GiLOT proved effective at unmasking implicit biases. For example, when generating a story about a "homemaker," the model placed high importance on the token "male" when forced to write about a man, but didn't care as much about the token "female" for a woman—suggesting the model views "female homemaker" as a default state and "male" as a significant deviation.
Key Results
GiLOT was tested against baselines like LIME, Integrated Gradients (IG), and Bidirectional Transformer Attribution (BTA) using three faithfulness metrics: MoRF (Most Relevant First), LeRF (Least Relevant First), and ABPC (Area Between Perturbation Curves).
- Superior Faithfulness: GiLOT consistently achieved the highest scores across almost all models and metrics. For instance, on Llama2-7b, GiLOT's ABPC (0.85) significantly outperformed LIME (-0.55) and IG (0.61).
- Robustness to Scale: The performance gains were even more pronounced in larger models (13B) and those fine-tuned with RLHF, suggesting GiLOT is well-suited for the current generation of production LLMs.
- Ablation Success: Comparing GiLOT (OT) against a version using KL Divergence showed that the Optimal Transport approach is fundamentally more effective at capturing true feature importance.
Limitations and Future Work
- Computational Overhead: While the authors optimized the OT solver, the method still requires running the model multiple times (once for each input token being tested). For extremely long contexts (e.g., 128k tokens), this remains a bottleneck.
- Beam Search Constraints: The accuracy of the distribution estimation depends on the diversity of the beam search. If a model generates highly diverse, low-probability outputs, the approximation might lose precision.
- Future Directions: The authors suggest exploring gradient-based or attention-based methods to approximate these attributions in a single pass, potentially bringing GiLOT's accuracy to real-time applications.
Summary updated