Attention Mechanisms Don't Learn Additive Models: Rethinking Feature Importance for Transformers

Tobias Leemann, Alina Fastowski, Felix Pfeiffer, Gjergji Kasneci
5/22/2024
cs.LGcs.AIcs.CL

Official code: tleemann/slalom_explanations (7 stars, Apache-2.0, last commit 2025-02-05).

Abstract

We address the critical challenge of applying feature attribution methods to the transformer architecture, which dominates current applications in natural language processing and beyond. Traditional attribution methods to explainable AI (XAI) explicitly or implicitly rely on linear or additive surrogate models to quantify the impact of input features on a model's output. In this work, we formally prove an alarming incompatibility: transformers are structurally incapable of representing linear or additive surrogate models used for feature attribution, undermining the grounding of these conventional explanation methodologies. To address this discrepancy, we introduce the Softmax-Linked Additive Log Odds Model (SLALOM), a novel surrogate model specifically designed to align with the transformer framework. SLALOM demonstrates the capacity to deliver a range of insightful explanations with both synthetic and real-world datasets. We highlight SLALOM's unique efficiency-quality curve by showing that SLALOM can produce explanations with substantially higher fidelity than competing surrogate models or provide explanations of comparable quality at a fraction of their computational costs. We release code for SLALOM as an open-source project online at https://github.com/tleemann/slalom_explanations.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

SLALOM explanations for transformer models (TMLR 2024)

71Shell, PythonSep 24, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{leemann2024attention,
  title  = {Attention Mechanisms Don't Learn Additive Models: Rethinking Feature Importance for Transformers},
  author = {Tobias Leemann and Alina Fastowski and Felix Pfeiffer and Gjergji Kasneci},
  year   = {2024},
  eprint = {2405.13536},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2405.13536v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2405.13536.svg)](https://codeofpaper.com/paper/2405.13536)

Discussion