Papers › XAI for Transformers: Better Explanations through Conservative Propagation

XAI for Transformers: Better Explanations through Conservative Propagation

15 Feb 2022arXiv:2202.07304archive 2025-07-28

Ameen Ali, Thomas Schnake, Oliver Eberle, Grégoire Montavon, Klaus-Robert Müller, Lior Wolf

Transformers have become an important workhorse of machine learning, with numerous applications. This necessitates the development of reliable methods for increasing their transparency. Multiple interpretability methods, often based on gradient information, have been proposed. We show that the gradient in a Transformer reflects the function only locally, and thus fails to reliably identify the contribution of input features to the prediction. We identify Attention Heads and LayerNorm as main reasons for such unreliable explanations and propose a more stable way for propagation through these layers. Our proposal, which can be seen as a proper extension of the well-established LRP method to Transformers, is shown both theoretically and empirically to overcome the deficiency of a simple gradient-based approach, and achieves state-of-the-art explanation performance on a broad range of Transformer models and datasets.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2202.07304")

Code

Syntology Ran 2 of 12 code samples harvested from 1 repository linked to this paper; 10 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran with no contract checked.

By repository: official repository: 12 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ameenali/xai_transformers officialmentioned in paperpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

12 samples harvested; 2 ran; 1 honoured the contract we drafted; 10 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran
10unverified

Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from ameenali/xai_transformers. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

avg_heads ameenali/xai_transformers/IMDB/run_imdb.py official repository ran MIT (permissive) · 27481013d8c59da1 · report
softmax ameenali/xai_transformers/attribution.py official repository ran · honoured contract fingerprinted MIT (permissive) · 91fe7a23c1c052b7 · report
LayerNorm ameenali/xai_transformers/utils.py official repository unverified MIT (permissive) · 8aae8fd9930a694c · report
apply_self_attention_rules ameenali/xai_transformers/IMDB/run_imdb.py official repository unverified MIT (permissive) · 62d56a2c8e317a8d · report
compute_flows ameenali/xai_transformers/attribution.py official repository unverified MIT (permissive) · e6f03715bb008a76 · report
create_data_loader ameenali/xai_transformers/IMDB/imdb.py official repository unverified MIT (permissive) · e68f6ccbc2173bdb · report
get_adjmat ameenali/xai_transformers/attribution.py official repository unverified MIT (permissive) · 38d43b4feccaaa24 · report
get_sst_dataset ameenali/xai_transformers/SST/sst.py official repository unverified MIT (permissive) · 7448a1b293e85dc5 · report
load_imdb ameenali/xai_transformers/IMDB/imdb.py official repository unverified MIT (permissive) · 3f92118756cbc8b1 · report
make_p_layer ameenali/xai_transformers/xai_transformer.py official repository unverified MIT (permissive) · c8b195f1d000eaf9 · report
rename_params ameenali/xai_transformers/IMDB/run_imdb.py official repository unverified MIT (permissive) · 0918e3d36dec3d64 · report
to_sentiment ameenali/xai_transformers/IMDB/imdb.py official repository unverified MIT (permissive) · 3ff61564e786e665 · report

Tasks

Explainable Artificial Intelligence (XAI)Question Answering

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Question Answering NewsQA xAI/grok-3-1212 EM 70.57 #8 of 18 Archive leaderboard report
Question Answering NewsQA xAI/grok-3-1212 F1 88.24 #8 of 18 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections