Causality for Inherently Explainable Transformers: CAT-XPLAIN

Subash Khanal, Benjamin Brodie, Xin Xing, Ai-Ling Lin, Nathan JacobsarXiv 2022 · DOI

Abstract

Vision Transformers (ViTs) have become a standard in computer vision, yet their decision-making processes often remain opaque. Traditional "post-hoc" explanation methods frequently suffer from a lack of faithfulness, where the explanation does not truly reflect the model's internal logic. We present CAT-XPLAIN, featuring the expViT architecture. By introducing a dedicated selection token and training with a joint causal loss function, expViT learns to identify causally significant image patches inherently. Our evaluations on MNIST, Fashion-MNIST, and CIFAR-10 show that expViT outperforms state-of-the-art post-hoc explainers in both faithfulness and computational efficiency.

Introduction

In high-stakes applications like medical imaging or autonomous driving, understanding why an AI model makes a specific prediction is as important as the prediction itself. Currently, the field relies heavily on post-hoc explanations—tools like Grad-CAM or separate explainer models that attempt to interpret a pre-trained black-box model.

However, these tools face a significant "faithfulness" challenge: the explainer may have different internal biases than the original model, leading to justifications that are human-readable but technically inaccurate regarding the model's actual mechanics. CAT-XPLAIN addresses this by making the Vision Transformer inherently explainable, ensuring the decision and the explanation stem from the same internal process.

Methods: The expViT Architecture

The authors introduce expViT, a modification of the standard Vision Transformer designed for causal feature selection. The architecture is built on three pillars:

  1. The sel Token: While standard ViTs use a cls (class) token to aggregate information, expViT adds a second learnable token called sel (selection). This token attends to all image patches to determine which regions are most "causally significant."
  2. Continuous Subset Sampling: The sel token's output is processed by a selection head to produce a probability distribution over input patches. Using the Gumbel-Softmax trick, the model performs differentiable sampling to select the top-$k$ most important patches during training.
  3. Joint Causal Loss: The model is trained using a multi-task loss function that balances classification accuracy with a selection loss ($L_{sel}$). This causal loss encourages the model to identify patches that, if removed, would most significantly impact the prediction, thereby identifying the true drivers of the output.
Architecture of expViT featuring the selection (sel) token and subset sampler.

Key Results and Evaluation

The model was evaluated against state-of-the-art post-hoc causal explainers using metrics such as Post-hoc Accuracy (PA)—measuring how well selected patches represent the full image's logic—and Average Causal Effect (ACE).

  • Superior Faithfulness: On the MNIST dataset, when restricted to just 5% of image patches (frac=0.05), expViT achieved a PA of 0.936, compared to 0.744 for the post-hoc method.
  • Stronger Causal Signal: Across MNIST, FMNIST, and CIFAR-10, expViT consistently yielded higher ACE scores, proving that its selected patches have a more direct causal link to the final classification.
  • Efficiency: Unlike post-hoc methods that require additional passes or separate model training, expViT generates explanations in a single forward pass.
Visualizations of selected patches for MNIST and FMNIST at varying selection fractions.

Discussion and Limitations

CAT-XPLAIN demonstrates that Transformers are naturally suited for causal explanation due to their self-attention mechanisms. By eliminating the "explainer gap," the model ensures explanations are perfectly aligned with its logic.

However, a fundamental accuracy-explainability trade-off exists; models forced to rely on very few patches may see a slight dip in overall classification accuracy. Future work will focus on scaling this approach to multi-class problems and more complex datasets like ImageNet, as well as refining patch resolution for more granular explanations.

Summary updated

BibTeX
@misc{khanal2022causality,
  author = {Subash Khanal and Benjamin Brodie and Xin Xing and Ai-Ling Lin and Nathan Jacobs},
  title = {{Causality for Inherently Explainable Transformers: CAT-XPLAIN}},
  year = {2022},
  eprint = {2206.14841},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2206.14841},
}
Figure