NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Efficient Shapley Values Calculation for Transformer Explainability

Tianli Sun, Haonan Chen, Yuping Qiu, Cairong Zhao

Abstract

Class activation mapping (CAM) methods have achieved great model explainability performance for CNNs. However, these methods do not perform so well for Transformers, whose architectures are fundamentally different from CNNs. Instead, gradient-weighted attention visualization methods, with effective consideration for the self-attention and skip-connection, achieve very promising explainability for Transformers. These methods compute gradients by back-propagation to achieve class-specific and accurate explainability. In this work, to further increase the accuracy and efficiency in Transformer explainability, we propose a novel method which is both class-specific and gradient-free. The token importance is calculated using Shapley value method, which has a solid base on game theory but is conventionally very computational expensive to use in practice. To calculate the Shapley value accurately and efficiently for each token, we decouple the self-attention from the information flow in Transformers and freeze other unrelated values. In this way, we construct a linear version of Transformer so that the Shapley values can be calculated conveniently. Using Shapley values for explainability, our method not only improves the explainability further but also becomes class-specific without using gradients, surpassing other gradient-based methods in both accuracy and efficiency. Furthermore, we show that explainability methods for CNNs and Transformers can be bridged under the 1st-order Taylor expansion of our method, resulting in (1) a significant explainability improvement for a modified GradCAM method in Transformers and (2) new insights into understanding the existing gradient-based attention visualization methods. Extensive experiments show that our method is superior compared to state-of-the-arts methods. Our code will be made available.
BibTeX
@inproceedings{sun2023efficient,
  author = {Tianli Sun and Haonan Chen and Yuping Qiu and Cairong Zhao},
  title = {{Efficient Shapley Values Calculation for Transformer Explainability}},
  booktitle = {ACPR},
  year = {2023},
  doi = {10.1007/978-3-031-47634-1\_5},
}

Loading related content...

Figure