R-TPT: Improving Adversarial Robustness of Vision-Language Models through Test-Time Prompt Tuning

Lijun Sheng, Jian Liang, Zilei Wang, Ran He
4/15/2025
cs.LGcs.CRcs.CV

Official code: TomSheng21/R-TPT (22 stars, last commit 2025-08-28).

Abstract

Vision-language models (VLMs), such as CLIP, have gained significant popularity as foundation models, with numerous fine-tuning methods developed to enhance performance on downstream tasks. However, due to their inherent vulnerability and the common practice of selecting from a limited set of open-source models, VLMs suffer from a higher risk of adversarial attacks than traditional vision models. Existing defense techniques typically rely on adversarial fine-tuning during training, which requires labeled data and lacks of flexibility for downstream tasks. To address these limitations, we propose robust test-time prompt tuning (R-TPT), which mitigates the impact of adversarial attacks during the inference stage. We first reformulate the classic marginal entropy objective by eliminating the term that introduces conflicts under adversarial conditions, retaining only the pointwise entropy minimization. Furthermore, we introduce a plug-and-play reliability-based weighted ensembling strategy, which aggregates useful information from reliable augmented views to strengthen the defense. R-TPT enhances defense against adversarial attacks without requiring labeled training data while offering high flexibility for inference tasks. Extensive experiments on widely used benchmarks with various attacks demonstrate the effectiveness of R-TPT. The code is available in https://github.com/TomSheng21/R-TPT.

View on arXivView PDF

Code Implementations(1)

TomSheng21/R-TPTOfficial100%

CVPR 2025 - R-TPT: Improving Adversarial Robustness of Vision-Language Models through Test-Time Prompt Tuning

222PythonApr 11, 20251 years ago

Similar Papers

Cite this paper

@article{sheng2025rtpt,
  title  = {R-TPT: Improving Adversarial Robustness of Vision-Language Models through Test-Time Prompt Tuning},
  author = {Lijun Sheng and Jian Liang and Zilei Wang and Ran He},
  year   = {2025},
  eprint = {2504.11195},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.11195v2},
  journal = {CVPR 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.11195.svg)](https://codeofpaper.com/paper/2504.11195)

Discussion