Grad-ECLIP: Gradient-based Visual and Textual Explanations for CLIP
Chenyang Zhao, Kun Wang, Janet H. Hsiao, Antoni B. Chan
TL;DR
Grad-ECLIP introduces a white-box, gradient-based approach to explain CLIP by producing heat maps that reflect how image regions and words influence image-text matching. By deriving channel weights from gradients and employing a loosened spatial weight to counteract sparse attention, Grad-ECLIP yields high-quality, result-specific visual and textual explanations applicable to ViT and CNN backbones, as well as other vision-language models. The authors demonstrate superior faithfulness, localization, and robustness across datasets and domains, and show how these explanations reveal CLIP’s concept decomposition, attribution tendencies, and tendency to rely on concrete words. Additionally, Grad-ECLIP enables a fine-grained CLIP fine-tuning framework that uses region-phrase mappings to strengthen region-wise alignment without sacrificing global performance. Overall, Grad-ECLIP provides a practical, generalizable tool for interpreting and improving vision-language models, with implications for debugging, prompt design, and downstream dense prediction tasks.
Abstract
Significant progress has been achieved on the improvement and downstream usages of the Contrastive Language-Image Pre-training (CLIP) vision-language model, while less attention is paid to the interpretation of CLIP. We propose a Gradient-based visual and textual Explanation method for CLIP (Grad-ECLIP), which interprets the matching result of CLIP for specific input image-text pair. By decomposing the architecture of the encoder and discovering the relationship between the matching similarity and intermediate spatial features, Grad-ECLIP produces effective heat maps that show the influence of image regions or words on the CLIP results. Different from the previous Transformer interpretation methods that focus on the utilization of self-attention maps, which are typically extremely sparse in CLIP, we produce high-quality visual explanations by applying channel and spatial weights on token features. Qualitative and quantitative evaluations verify the effectiveness and superiority of Grad-ECLIP compared with the state-of-the-art methods. Furthermore, a series of analysis are conducted based on our visual and textual explanation results, from which we explore the working mechanism of image-text matching, the strengths and limitations in attribution identification of CLIP, and the relationship between the concreteness/abstractness of a word and its usage in CLIP. Finally, based on the ability of explanation map that indicates text-specific saliency region of input image, we also propose an application with Grad-ECLIP, which is adopted to boost the fine-grained alignment in the CLIP fine-tuning. The code of Grad-ECLIP is available here: https://github.com/Cyang-Zhao/Grad-Eclip.
