Introduction
Understanding the decision-making process of Transformer models remains a critical challenge in AI interpretability. While early methods relied on raw attention weights, they often failed to capture the true importance of input tokens. Subsequent "Attention Flow" methods modeled Transformers as graph networks to track information movement but suffered from a significant mathematical flaw: the non-uniqueness of maximum flow solutions. This ambiguity leads to inconsistent feature attribution scores depending on the specific solver used.
In this work, researchers introduce Generalized Attention Flow (GAF). By reformulating the feature attribution problem as a regularized maximum flow optimization, GAF provides unique, mathematically grounded, and "fair" importance scores that consistently outperform existing state-of-the-art methods in identifying the true drivers of model predictions.
Methodology: From Tensors to Unique Flows
The GAF framework operates by transforming the internal states of a Transformer into a flow network. The process involves three primary components:
1. The Information Tensor
Instead of relying solely on attention weights, GAF utilizes a "Generalized Information Tensor" ($A$) to define edge capacities in the graph. The authors evaluated three variants:
- AF (Attention Flow): Uses mean attention weights across heads.
- GF (Grad Flow): Uses the gradients of attention weights to capture sensitivity.
- AGF (Attention Grad Flow): Combines weights and gradients (element-wise product), capturing both the magnitude and the direction of information influence.
2. Log-Barrier Regularization
To solve the non-uniqueness problem inherent in standard maximum flow, GAF introduces a log-barrier regularization term to the optimization objective. This addition transforms the problem into a strictly convex optimization, ensuring that the solver converges to a single, unique optimal solution ($f^*$).
3. Axiomatic Fairness
A key theoretical contribution is the proof that this regularized flow satisfies the four fundamental axioms of Shapley values: efficiency, symmetry, nullity, and linearity. This provides a rigorous "fairness" guarantee for the resulting attribution scores, aligning the flow values with established cooperative game theory principles.
Experimental Evaluation
The researchers benchmarked GAF against standard NLP sequence classification tasks, including sentiment analysis (SST2, IMDB, Amazon, Yelp) and news classification (AG News), using pre-trained BERT-base models. Performance was measured using Faithfulness metrics such as AOPC (Area Over the Perturbation Curve) and LOdds (Log-odds), which evaluate how model confidence shifts when tokens are masked.
Results and Discussion
The experiments revealed that AGF is the most effective variant, significantly outperforming established methods like Integrated Gradients (IG), KernelSHAP, and Transformer-specific baselines like AttCAT and TransAtt.
The Power of the Graph Analogy
By modeling the Transformer as a layered graph, GAF captures complex pairwise interactions between features across all layers. Information "flows" from input tokens through intermediate layers to a "super-sink" representing the final prediction.
Key findings include:
- Uniqueness and Stability: Forcing a unique solution makes explanations reproducible and reliable, fixing the "guessing" behavior of previous flow methods.
- Gradient Integration: Gradients are essential for capturing the actual impact of attention shifts on the final output, providing a necessary "direction" to the flow.
- Robustness: GAF effectively identifies both the most and least important tokens across diverse datasets, though performance slightly dips in noisy text environments (e.g., Yelp) due to the sensitivity of gradient-based tensors.
Conclusion and Future Work
Generalized Attention Flow addresses the critical "non-uniqueness" bug in flow-based interpretability. While the computational cost of solving regularized optimization problems is higher than simple gradient passes, the gains in faithfulness and theoretical consistency are substantial. Future research will focus on optimizing the parallelization of these flow computations and exploring more sophisticated definitions for the Information Tensor.
Summary updated