Grad-ECLIP: Gradient-based Visual and Textual Explanations for CLIP

Chenyang Zhao, Kun Wang, Janet H. Hsiao, Antoni B. Chan · DOI

Introduction

The Contrastive Language-Image Pre-training (CLIP) model has emerged as a cornerstone of modern vision-language tasks. However, its internal decision-making remains largely a "black box." Existing Explainable AI (XAI) techniques often fail to provide meaningful insights into CLIP. Gradient-based methods like Grad-CAM, designed for CNNs, produce noisy results on Vision Transformers (ViTs), while attention-based methods suffer from the inherent sparsity of CLIP's softmax attention maps, which often highlight isolated pixels rather than complete objects. Furthermore, CLIP's global matching objective limits its ability to align specific words with local image regions.

The Grad-ECLIP Framework

To address these challenges, we introduce Grad-ECLIP, a top-down, gradient-based explanation method that generates high-fidelity heatmaps for both image and text encoders.

Overview of the Grad-ECLIP architecture for visual and textual explanations.

As shown in the architecture above, Grad-ECLIP computes two primary weights for intermediate Transformer features:

  1. Channel Importance: Derived from the gradients of the image-text matching score with respect to the class token's output.
  2. Spatial Importance: Instead of relying on sparse raw attention, Grad-ECLIP employs a "loosened" 0-1 normalized similarity map. This prevents the heatmap from collapsing and ensures it captures the full spatial extent of relevant objects.

Uncovering Model Biases and Capabilities

Grad-ECLIP allows for a diagnostic look into CLIP's learned representations:

  • Concreteness Bias: Textual heatmaps reveal that CLIP prioritizes concrete nouns (e.g., "dog") over abstract terms. Analysis shows this is an inherent learning bias rather than a simple reflection of training data frequency.
  • Physical Blind Spots: Diagnostics on the CLEVR dataset show that while CLIP excels at color recognition, it struggles to ground physical attributes like shape and material, as well as spatial relationships (e.g., "left of").
  • Concept Addibility: The model demonstrates a dynamic ability to combine concepts; for instance, adding the modifier "young" to "horse" successfully shifts the visual focus to a foal.

Experimental Results and Applications

Grad-ECLIP significantly outperforms existing baselines in both faithfulness and localization accuracy.

Qualitative comparison of Grad-ECLIP against various XAI baselines for the prompt "a dog is playing with frisbee".

In faithfulness tests (Deletion/Insertion metrics), Grad-ECLIP identifies the features most critical to the model's output more accurately than Grad-CAM or Rollout. On the ImageNet-Segmentation task, it achieved an 88.99% Point Game accuracy, vastly exceeding Grad-CAM's 18.45% and CLIPSurgery's 57.59%.

Beyond interpretation, Grad-ECLIP serves as a powerful tool for self-supervised fine-tuning. By using generated heatmaps as pseudo-labels for noun phrases, the authors implemented a "local loss" that teaches CLIP fine-grained alignment without external object detectors. This approach improved zero-shot region classification on MS COCO by +14.4% and boosted Average Precision in open-vocabulary detection tasks by up to 11.1 points.

Conclusion

Grad-ECLIP provides a robust mechanism for interpreting and improving foundational vision-language models. By moving beyond sparse attention maps to gradient-informed "loosened" similarity, it offers a clearer view of CLIP's internal logic and a scalable path toward fine-grained multimodal understanding. Future work will focus on extending this method to models with complex cross-attention architectures.

Summary updated

BibTeX
@misc{zhao2025grad,
  author = {Chenyang Zhao and Kun Wang and Janet H. Hsiao and Antoni B. Chan},
  title = {{Grad-ECLIP: Gradient-based Visual and Textual Explanations for CLIP}},
  year = {2025},
  eprint = {2502.18816},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.18816},
}
Figure