Skip to main content
QUICK REVIEW

[Paper Review] LeGrad: An Explainability Method for Vision Transformers via Feature Formation Sensitivity

Walid Bousselham, Angie Boggust|arXiv (Cornell University)|Apr 4, 2024
Explainable Artificial Intelligence (XAI)Computer Science6 citations
TL;DR

LeGrad introduces a layerwise gradient-based explainability method for Vision Transformers, aggregating gradient signals w.r.t. attention maps across layers to produce robust, open-vocabulary and perturbation-friendly localization maps. It outperforms SOTA methods on segmentation, open-vocabulary detection, and robustness benchmarks across ViT backbones.

ABSTRACT

Vision Transformers (ViTs), with their ability to model long-range dependencies through self-attention mechanisms, have become a standard architecture in computer vision. However, the interpretability of these models remains a challenge. To address this, we propose LeGrad, an explainability method specifically designed for ViTs. LeGrad computes the gradient with respect to the attention maps of ViT layers, considering the gradient itself as the explainability signal. We aggregate the signal over all layers, combining the activations of the last as well as intermediate tokens to produce the merged explainability map. This makes LeGrad a conceptually simple and an easy-to-implement tool for enhancing the transparency of ViTs. We evaluate LeGrad in challenging segmentation, perturbation, and open-vocabulary settings, showcasing its versatility compared to other SotA explainability methods demonstrating its superior spatial fidelity and robustness to perturbations. A demo and the code is available at https://github.com/WalBouss/LeGrad.

Motivation & Objective

  • Address the interpretability gap in Vision Transformers (ViTs) by designing a gradient-based explainability method tied to ViT attention maps.
  • Leverage layerwise gradients to capture feature formation across multiple ViT layers and aggregate them into a single explainability map.
  • Demonstrate LeGrad’s effectiveness across segmentation, open-vocabulary detection, and perturbation evaluations on diverse ViT backbones.
  • Show that LeGrad scales to very large ViTs and adapts to different feature aggregation strategies.
  • Provide a hyperparameter-free, model-agnostic tool that does not require localization annotations for training or fine-tuning.

Proposed method

  • Compute the gradient of the target class activation with respect to ViT attention maps for each layer.
  • Apply ReLU to clip negative contributions before aggregation.
  • Average layerwise explainability signals across all layers and reshape to a 2D heatmap.
  • Adapt the method to attentional poolers by using the pooler’s attention map in place of the self-attention map.
  • Evaluate on segmentation (ImageNet-Seg), open-vocabulary detection (OpenImagesV7), and perturbation tests (ImageNet-val).
  • Demonstrate compatibility with various ViT backbones (ViT-B/16 to ViT-BigG/14) and aggregation schemes.
Figure 1 : LeGrad explainability maps: For a given vision-language model and a textual prompt, LeGrad generates a heatmap indicating the part of the image that is most sensitive to that prompt. LeGrad performs equally well across a large range of model sizes, ranging from ViT-B/16(150M params.) to V
Figure 1 : LeGrad explainability maps: For a given vision-language model and a textual prompt, LeGrad generates a heatmap indicating the part of the image that is most sensitive to that prompt. LeGrad performs equally well across a large range of model sizes, ranging from ViT-B/16(150M params.) to V

Experimental results

Research questions

  • RQ1Can LeGrad faithfully attribute model decisions to image regions by computing gradients w.r.t. ViT attention maps?
  • RQ2Does pooling layerwise signals across layers improve explainability for ViTs compared to layer-specific maps?
  • RQ3How does LeGrad perform on segmentation, open-vocabulary localization, and perturbation-based evaluations across different ViT backbones?
  • RQ4Is LeGrad scalable to very large ViTs and adaptable to different feature aggregation methods?
  • RQ5Does LeGrad maintain performance without localization annotations during training?

Key findings

  • LeGrad achieves higher mIoU (58.66) and pixel accuracy (77.52) than other methods on ImageNet-Seg with CLIP ViT-B/16.
  • In OpenImagesV7 open-vocabulary segmentation, LeGrad outperforms all SOTA methods with substantial gains across model sizes.
  • LeGrad’s perturbation-based evaluation shows strong performance across negative and positive perturbations, often surpassing gradient- and attention-based baselines.
  • LeGrad scales to ViT-BigG/14 (2.5B params) and remains effective across different pooling strategies.
  • On SigLIP-B/16, LeGrad achieves notable p-mIoU improvements in open-vocabulary localization.
  • Qualitative analyses show LeGrad’s explanations focus on relevant objects while suppressing noisy background artifacts.
Figure 2 : Overview of LeGrad: Given a text prompt or a classifier $\mathcal{C}$ , for each layer $l$ , an activation $s^{l}$ is computed and used to compute the explainability of that layer. The layerwise explainability maps are then merged to produce LeGrad’s output.
Figure 2 : Overview of LeGrad: Given a text prompt or a classifier $\mathcal{C}$ , for each layer $l$ , an activation $s^{l}$ is computed and used to compute the explainability of that layer. The layerwise explainability maps are then merged to produce LeGrad’s output.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.