Text-Guided Attention is All You Need for Zero-Shot Robustness in Vision-Language Models

Due to the impressive zero-shot capabilities, pre-trained vision-language models (e.g. CLIP), have attracted widespread attention and adoption across various domains. Nonetheless, CLIP has been observed to be susceptible to adversarial examples. Through experimental analysis, we have observed a phenomenon wherein adversarial perturbations induce shifts in text-guided attention. Building upon this observation, we propose a simple yet effective strategy: Text-Guided Attention for Zero-Shot Robustness (TGA-ZSR). This framework incorporates two components: the Attention Refinement module and the Attention-based Model Constraint module. Our goal is to maintain the generalization of the CLIP model and enhance its adversarial robustness: The Attention Refinement module aligns the text-guided attention obtained from the target model via adversarial examples with the text-guided attention acquired from the original model via clean examples. This alignment enhances the model's robustness. Additionally, the Attention-based Model Constraint module acquires text-guided attention from both the target and original models using clean examples. Its objective is to maintain model performance on clean samples while enhancing overall robustness. The experiments validate that our method yields a 9.58% enhancement in zero-shot robust accuracy over the current state-of-the-art techniques across 16 datasets. Our code is available at https://github.com/zhyblue424/TGA-ZSR.

Paper

References (68)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer mEBo5/10 · confidence 4/52024-07-01

Summary

The paper focuses on enhancing the robustness of CLIP models against adversarial perturbations. The approach utilizes saliency maps generated by the inner products between image and text embeddings. Two regularization terms are introduced: the first aims to align the saliency maps of the original and its adversarial examples, while the second seeks to match the saliency maps of the original example between the pre-trained CLIP model and the target model. Experimental results indicate that fine-tuning CLIP with these two regularization terms improves its robustness to attacks.

Strengths

1. The paper is well-written and organized, with clear descriptions of the motivation and methods. 2. To the best of my knowledge, enhancing CLIP robustness by aligning the saliency maps produced through inner products between image and text embeddings, termed "Text-Guided Attention" in the paper, is a novel approach. 3. It is good to see the detailed ablation analysis.

Weaknesses

1. The abstract claims that the goal is to enhance both the generalization and robustness of the CLIP model; however, the experimental results do not fully support this assertion. Specifically, regarding generalization, Table 2 shows a significant decrease in clean accuracy compared to the original pre-trained CLIP model. I kindly ask the authors to use the terms "generalizability" and "adversarial robustness" more carefully within the paper. Typically, the generalizability of CLIP models refers to their zero-shot classification performance across different datasets. It may be argued that the proposed method improves the adversarial robustness of CLIP models while maintaining relatively good generalizability compared to previous adversarial training methods. However, the authors must acknowledge the decrease in generalizability compared to original CLIP model as clearly evidenced by the results in Table 2. 2. Since the training uses adversarial examples produced by PGD, it is not surprising that the proposed method results in a model with good robustness to PGD attacks, as shown in Table 1. However, when the evaluation comes to AutoAttack, the advantage of the TGA-ZSR over the previously best method is marginal as shown in Table 3. Could the authors provide explanations for this point, and could they demonstrate the robustness of the resulting models to more attacks?

Questions

See weaknesses.

Rating

5

Confidence

4

Soundness

2

Presentation

4

Contribution

2

Limitations

The primary limitation of the paper is that the experimental results presented do not sufficiently support its claims. I recommend that the authors either revise the claims to align more closely with the data presented or extend the experimental section to provide additional evidence supporting their assertions.

Reviewer BFe66/10 · confidence 5/52024-07-06

Summary

This work studies the robustness to adversarial samples for CLIP. Inspired by an observation that adversarial perturbations induce shifts in text-guided attention, the work proposes a simple yet effective approach to improve the zero-shot robostness, i.e., align the text-guided attention of clean samples and adversarial samples. The state-of-the-art performance across 16 datasets demonstrate the effectiveness of the proposed method.

Strengths

This work focuses on an interesting topic, which involves the robustness of VLMs. To improve the zero-shot robustness of CLIP, the work proposes a text-guided attention-based method, which is simple but intuitive and effective. Extensive experiments on 16 datasets demonstrate the effectiveness of the proposed method. Additionally, the paper is well written and the experiments are solid.

Weaknesses

I would like to see more comparison with other types of attention, e.g., vision-only self-attention. Does the proposed method works because of the attention mechanism or the text guidance?

Questions

1. How do you utilize the class token in the ViT backbone of CLIP? 2. In Tables 13 and 14, why the losses L1 and L2 have very different performance?

Rating

6

Confidence

5

Soundness

3

Presentation

4

Contribution

3

Limitations

The paper has discussed the limitations and potential impacts of the work.

Authorsrebuttal2024-08-11

Thank you for taking the time to review our response and for recognizing the insights and interest in our work. We are pleased to hear that our previous response addressed your concerns. Regarding your new question, we believe that the significant improvement in robustness with text guidance can be attributed to two key aspects: (1) **Selective Focus on Relevant Features**: Text-guided attention allows the model to selectively focus on the most relevant parts of the image based on the text input. For instance, if the text describes "a photo of an apple," the attention mechanism guides the model to focus on the apple in the image, while ignoring irrelevant details. This selective focus enables the model to extract the most pertinent information, thus enhancing robustness by minimizing distractions from non-essential features. To illustrate the advantage of text-guided attention over vision-only attention, we calculated the mean Intersection over Union (mIoU) of the attention maps generated by both methods on the validation set of the ImageNet-S-50 dataset [d], which includes ground truth masks for semantic segmentation tasks. The results below demonstrate that the mIoU of text-guided attention is significantly higher than that of vision-only attention, indicating the superior effectiveness of our approach. Table 8: mIoU Comparison of Text-Guided and Vision-Only Attention on ImageNet-S-50 Dataset. | Method | mIoU | |----------| -------| | Text-guided | **0.485** | | Vision-only | 0.400 | (2) **Consistency Across Modalities**: By integrating text-guided attention, the model maintains consistency between the visual and textual modalities. The attention mechanism aligns visual features with corresponding textual descriptions, reinforcing the semantic connections between the two. This alignment reduces the risk of the model making inconsistent or erroneous predictions based on a single modality, thereby enhancing overall robustness. To further support this point, we conducted an experiment measuring the difference (L2 distance) in attention maps before and after an adversarial attack using both the text-guided attention-based model and the vision-only model on the TinyImageNet validation set. The results below show that the text-guided attention model maintains better consistency after the attack compared to the vision-only model. Table 9: L2 Distance Comparison Before and After Attack on TinyImageNet. | Method | L2 distance| |----------| -------| | Text-guided | **29.886** | | Vision-only | 52.918 | Based on these findings, we believe that the introduction of text guidance significantly enhances the robustness of the model. We hope this response addresses your concerns. [d] Shanghua Gao, Zhong-Yu Li, Ming-Hsuan Yang, Ming-Ming Cheng, Junwei Han, and Philip Torr. Large-scale unsupervised semantic segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.

Reviewer BFe62024-08-12

Thanks for the authors' response. I would like to confirm with you the details of your experiment settings. Specifically, I wonder how do you calculate the attention map when using text-guided attention and vision-only attention in this experiment (and how in Fig. 1).

Authorsrebuttal2024-08-12

Thanks for your question. We will incorporate these discussions into the final version. We compute the **text-guided attention** $A(x)$ by simply multiplying the text embedding $g(t)$ with the vision embedding $f_{g}(x)$. Specifically, this is expressed as $A(x)=f_{g}(x) \cdot g(t)^ \mathsf{T} $, where $f_{g}(x)$ represents the global image features before the pooling operation of the class token $f(x)$ (as described in Equation 5 and in Lines 162-166 of the paper). Text-guided attention incorporates textual context, potentially offering more precise and context-aware localization of relevant image features. For comparison, the **vision-only attention** is obtained using the widely adopted visualization technique in deep learning, Grad-CAM [49]. The Grad-CAM heatmap $L_{\text{Grad-CAM}}^c $ for class $c$ is defined as $L_{\text{Grad-CAM}}^c = \text{ReLU} \left( \sum_k \alpha_k^c A^k \right)$, where $\alpha_k^c = \frac{1}{Z} \sum_i \sum_j \frac{\partial y^c}{\partial A_{ij}^k}$. Here, $y^c$ denotes the class score, $i,j$ are the spatial dimensions within the activation map of the $k$-th convolutional layer $A^k$, and $Z$ represents the total number of spatial locations $i \times j$ in the feature map. The Grad-CAM method highlights regions of the image that are most relevant to the class prediction by calculating the gradients of the class score with respect to the activation map. Figure 1 demonstrates the results of our text-guided attention. We first convert a grayscale attention map into a color map using the ‘cv2.applyColorMap’ function. This colorized attention map is then overlaid onto the original image through a weighted sum: $ image \times 0.4 + attention × 0.6$ (these weights can be adjusted to achieve the desired visual emphasis), as similarly demonstrated in references [e] and [f]. The resulting image, shown in Figure 1, effectively highlights the areas of focus for the model, providing a clear visualization of its attention. [49] Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and456 Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. In457 Proceedings of the IEEE international conference on computer vision, pages 618–626, 2017. [e] Song, Y., Jang, S., Katabi, D., & Son, J. (2023). Unsupervised Object Localization with Representer Point Selection. 2023 IEEE/CVF International Conference on Computer Vision (ICCV), 6511-6521. [f] Li, Y., Wang, H., Duan, Y., & Li, X. (2023). CLIP Surgery for Better Explainability with Enhancement in Open-Vocabulary Tasks. ArXiv, abs/2304.05653.

Reviewer BFe62024-08-12

Thanks for the authors' response and their valuable insights. My concerns have been addressed. I wil increase my rating to Weak Accept.

Reviewer qndz5/10 · confidence 3/52024-07-10

Summary

This paper proposes an approach to improve the adversarial robustness of vision-language models while maintaining performance on clean images. The key idea is to aligns the attention maps of adversarial examples with clean examples. Extensive experiments demonstrate the effectiveness of the proposed method in zero-shot adversarial robustness across multiple datasets while maintaining high clean accuracy.

Strengths

1. The proposed method is simple, straightforward and effective. It leverages text-guided attention to significantly enhance zero-shot adversarial robustness while maintaining clean accuracy across diverse datasets. 2. The experiments are comprehensive. The results on 16 datasets demonstrate consistent improvements over baseline methods.

Weaknesses

1. The method is only demonstrated on CLIP, raising questions about its applicability to other vision-language models or architectures. 2. The method introduces additional hyperparameters without a clear strategy for tuning them across different datasets or tasks. 3. No error bars or statistical significance tests reported for the experimental results.

Questions

1. How sensitive is the method to the choice of hyperparameters? Is there a principled way to select these across different datasets or tasks? 2. Are there any scenarios or types of adversarial attacks where this method performs poorly? What are the limitations of this approach?

Rating

5

Confidence

3

Soundness

3

Presentation

2

Contribution

2

Limitations

The authors did not explicitly address the limitations such as the types of adversarial attacks where this method performs poorly.

Reviewer qndz2024-08-12

I thank the authors for their responses. All my concerns have been addressed. I will increase my rating from 4 to 5.

Reviewer w4iU6/10 · confidence 2/52024-07-11

Summary

The paper proposes a framework, Text-Guided Attention for Zero-Shot Robustness (TGA-ZSR), to enhance the robustness of vision-language models (VLMs) against adversarial attacks. The proposed method incorporates two modules: the Attention Refinement module and the Attention-based Model Constraint module. The Attention Refinement module aligns the text-guided attention of adversarial examples with clean examples, while the Attention-based Model Constraint module maintains the model’s performance on clean samples.

Strengths

1. The use of text-guided attention allows to enhance zero-shot robustness. 2. Extensive evaluation of the approach was conducted across diverse datasets. 3. The proposed method outperforms current state-of-the-art techniques in both zero-shot robust accuracy. 4. The paper provides a thorough analysis of the impact of adversarial attacks on text-guided attention, offering insights into the model's decision-making process. 5. The method improves robustness without significantly sacrificing performance on clean data, achieving a favorable trade-off.

Weaknesses

1. The incorporation of text-guided attention mechanisms and multiple modules may increase the complexity of implementation and computational overhead. 2. Although the authors claim zero-shot robustness in Vision-Language Models, the experiments and methods only target the CLIP model. 3. Missing limitation in Section 5.

Questions

1. What is the additional computational overhead introduced by the Attention Refinement and Attention-based Model Constraint modules? How does this impact training and inference times compared to baseline methods? 2. How well does the proposed method generalize to other types of vision-language tasks beyond image classification, such as image captioning or visual question answering? 3. Why is the proposed method fine-tuned on Tiny-ImageNet rather than ImageNet? Both TeCoA [1] and FARE [2] are trained on ImageNet. [1] Mao, C., Geng, S., Yang, J., Wang, X., & Vondrick, C. (2022). Understanding zero-shot adversarial robustness for large-scale models. [2] Schlarmann, C., Singh, N. D., Croce, F., & Hein, M. (2024). Robust clip: Unsupervised adversarial fine-tuning of vision embeddings for robust large vision-language models.

Rating

6

Confidence

2

Soundness

3

Presentation

3

Contribution

3

Limitations

N/A

Reviewer mEBo2024-08-08

The author have addressed my concern, and I will change my score from 4 to 5.

Authorsrebuttal2024-08-09

Thank you for taking the time to read our response and increasing your score! We are glad to hear that the response addressed your concerns.

Reviewer BFe62024-08-11

Thanks for the authors' response. My concerns have been addressed. Additionally, I have one more question about the proposed model: Why introducing the text guidance can significantly improve the robustness? I think this work is insightful and the proposed model is interesting, and thus I would like to see more analysis or more insights. If the authors can address this, I am willing to increasing my rating.

Authorsrebuttal2024-08-11

Thank you for taking the time to review our response and for your support. We are glad to hear that the response addressed your concerns.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC