Skip to content

RITA: Enhancing the adversarial robustness of vision-language models through test-time prompt adaptationRobustifying Vision-Language Models via Test-Time Prompt Adaptation

arXiv· arXiv:2607.09450· ICML 2026· Xingyu Zhu, Huanshen Wu, Shuo Wang, Beier Zhu, Jiannan Ge, Jiaheng Zhang, Long ChenNational University of Singapore; University of Science and Technology of China; The Hong Kong University of Science and TechnologyIndexed by this site · 25 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose a test-time prompt adaptation framework, RITA, which uses optimal transport to align augmented view distributions with text prototypes, improving CLIP's adversarial robustness on 8 fine-grained datasets.

Threat modelDefender's perspective: the victim system is pretrained CLIP (ViT-B/32, ViT-B/16, RN50 and other backbones); the attack is white-box PGD (L∞ constraint, ϵ=1.0 or 4.0, 7 steps), with adversarial examples generated on the original CLIP model; the appendix additionally tests CW, DI, FGSM, AutoAttack, and adaptive attacks with perception-enhancement strategies.

Questions
VLMs such as CLIP show substantial performance degradation under adversarial perturbations; the authors argue that existing test-time adaptation methods rely on sample-level confidence and cannot distinguish high-confidence adversarial mispredictions from genuine semantic consistency.
Methods
Proposes RITA: models multiple augmented views of an adversarial image and multiple text prototypes per class as discrete distributions, performs distribution-level alignment using entropy-regularized optimal transport, and uses a dynamic cache to accumulate low-entropy views to refine the alignment online.
Experiments and results
On 8 fine-grained datasets under PGD ϵ=1.0, RITA's average robust accuracy is 49.7% (ViT-B/32) and 52.7% (ViT-B/16), which the authors state is higher than R-TPT; higher averages are also reported under CW, DI, FGSM, AutoAttack, and adaptive attack.
Limitations and future work
In the conclusion, the authors state that extension to generative tasks such as image captioning is left for future exploration; the Impact Statement says the method cannot eliminate all safety risks. The experiments cover only image classification, and adversarial examples are generated on the original CLIP.
Experimental setupCLIP-ViT-B/32、CLIP-ViT-B/16 et al. · Caltech101、Pets et al. · clean accuracy (Acc.)、robust accuracy (Rob.) et al.
Evaluated models
CLIP-ViT-B/32CLIP-ViT-B/16RN50TeCoAPMGFAREOpenCLIPEVA-CLIP
Benchmarks
Caltech101PetsCarsFlower102AircraftDTDEuroSATUCF101ImageNetImageNetV2ImageNet-SketchImageNet-AImageNet-RSUN397Food101
Metrics
clean accuracy (Acc.)robust accuracy (Rob.)running time (s/image)KL divergence
AI summaryResearchers propose RITA, a test-time prompt adaptation framework that can significantly improve the adversarial robustness of vision-language models such as CLIP without reducing clean-sample accuracy. The method shifts from sample-level estimation to distribution-level alignment, uses optimal transport to align augmented visual feature distributions with text prototypes, and performs online correction by accumulating reliable cues from the test stream through a dynamic cache. Its basis is that adversarial distortion is structurally fragile: when the overall representation is corrupted, semantic integrity in the distribution of augmented views is often still preserved.

Researchers propose RITA, a test-time prompt adaptation framework that can significantly improve the adversarial robustness of vision-language models such as CLIP without reducing clean-sample accuracy. The method shifts from sample-level estimation to distribution-level alignment, uses optimal transport to align augmented visual feature distributions with text prototypes, and performs online correction by accumulating reliable cues from the test stream through a dynamic cache. Its basis is that adversarial distortion is structurally fragile: when the overall representation is corrupted, semantic integrity in the distribution of augmented views is often still preserved.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Addresses CLIP's poor robustness under adversarial perturbations and the fact that existing test-time adaptation looks only at sample-level confidence.

    Core problem: pretrained VLMs (such as CLIP) suffer large performance drops under adversarial perturbations, and existing test-time adaptation methods struggle to remain robust under attack.

    • Problem setting: the authors state that VLMs such as CLIP have strong zero-shot generalization but are highly vulnerable to adversarial noise imperceptible to humans, posing security risks in real applications.
    • Shortcomings of existing methods: the authors argue that adversarial training methods are computationally expensive and require task-labeled data; test-time prompt tuning methods such as TPT and R-TPT mainly rely on sample-level confidence (e.g., entropy) to filter augmented views, treating augmentations as isolated data points and failing to distinguish high-confidence adversarial mispredictions from genuine semantic consistency.
    • Core observation: the authors observe that adversarial distortion is "structurally fragile"—the overall representation is corrupted, but geometric transformations such as random cropping and flipping change the pixel-space correspondences, causing perturbations optimized for the original image to partially mismatch, so semantic integrity is still preserved in the distribution of augmented views (Figure 1(a)(b)).
    • Proposed approach: proposes RITA (Robust test-tIme prompT Adaptation), shifting from sample-level estimation to distribution-level alignment: aligning the distribution of augmented views with text prototypes using optimal transport, and introducing a dynamic cache to accumulate reliable cues from the test stream for online refinement.
    • Threat model:
      • Victim system: pretrained CLIP (ViT-B/32, ViT-B/16, RN50 backbones) and adversarially fine-tuned variants TeCoA, PMG, FARE.
      • Attacker knowledge and capability: white-box attack, generating adversarial examples on the original CLIP model with PGD (L∞ constraint); the appendix additionally tests CW, DI, FGSM, AutoAttack, and adaptive attacks with perceptual enhancement strategies.
      • Attack objective: maximize the cross-entropy loss so that image-text matching is incorrect.
      • Defense setting: at test time only prompt parameters are updated, the CLIP backbone is frozen, and no labeled data is used.
  2. What related research exists?

    Related work is divided into three groups: VLM adversarial attack and defense, test-time prompt tuning, and applications of optimal transport in vision-language.

    VLM adversarial attacks and defenses

    • Attack side: from unimodal perturbations (Carlini & Wagner, 2017a; Xie et al., 2019) to multimodal strategies such as Co-Attack (Zhang et al., 2022a), which disrupts cross-modal alignment.
    • Defense side: adversarial contrastive fine-tuning (Mao et al., 2023; Schlarmann et al., 2024; Wang et al., 2024); the authors note that such methods require expensive retraining and labeled data, limiting practicality.
    • Inference-time defenses: diffusion purification (Feng et al., 2023; 2025) and optimization-based methods (Wang et al., 2021; Zhang et al., 2022b).

    Test-time prompt tuning (TPT-type)

    • TPT (Shu et al., 2022): adapts text prompts at inference time via entropy minimization without updating model parameters.
    • TAPT (Wang et al., 2025) and R-TPT (Sheng et al., 2025): adapt prompts using unlabeled data via contrastive learning or entropy minimization. The authors note that these paradigms treat visual inputs as isolated points and do not exploit the distributional geometry of adversarial examples.

    Optimal transport (OT) in vision-language

    • OT (Cuturi, 2013) with the Sinkhorn solver has been used in generative modeling, structural alignment, and domain adaptation.
    • PLOT (Chen et al., 2023) uses OT to match image features with multiple prompts; ALIGN (Wang et al., 2023) introduces hierarchical/token-level transport; AWT (Zhu et al., 2024c) models image-text distance as an OT problem. The authors note that these methods target representation enhancement in clean settings, rely on undistorted visual manifolds, and do not consider structural perturbations caused by adversarial attacks.

    Baselines and benchmarks: the compared methods are TPT, R-TPT, C-TPT (Yoon et al., 2024), MTA (Zanella & Ayed, 2024), zero-shot CLIP, and an Ensemble baseline that averages predictions over augmented views; the benchmarks are 8 fine-grained classification datasets, ImageNet, and its 4 OOD variants.

    The authors position this paper as: repurposing OT from representation enhancement in clean settings to adversarial defense, reconstructing at inference time the distribution-level correspondences disrupted by attacks, without parameter updates.

  3. How does the paper address this problem?

    RITA models augmented views and text prototypes as discrete distributions, aligns them with optimal transport, and then refines online with a dynamic cache.

    Overall approach: RITA no longer relies on a single-point image embedding; instead, it represents an adversarial test image as a discrete distribution over N augmented views, represents each class's text as a discrete distribution over M prompt prototypes, measures distribution-level alignment with entropy-regularized optimal transport, and uses a dynamic cache to accumulate reliable semantics from the test stream.

    Problem setting and formalization

    • Following the TPT setting: the test image undergoes N random augmentations, and the CLIP image encoder extracts features; on the text side, each class's prompt contains learnable context vectors, and predictions are computed by softmax over cosine similarity.
    • An adversarial example is defined as maximizing the cross-entropy loss under a white-box L∞ norm constraint ϵadv, approximated with iterative PGD.

    Distributional feature modeling and OT alignment

    • For an adversarial image, N augmented views form a visual distribution Pt, and for each class M prompts (learnable context vectors) form a text distribution Qk; both use uniform weights.
    • The alignment between Pt and Qk is measured by the entropy-regularized OT distance: dOT(P,Q;C)=minT∈Π(a,b) ⟨ T,C⟩ − λ h(T), with a cosine-distance cost matrix; the prediction is the class with the smallest OT distance. The authors state that a smaller OT distance indicates better distribution-level alignment, which can mitigate the effect of adversarial outliers.

    Dynamic distribution alignment (cache mechanism)

    • Cache update: for each augmented view, compute its average affinity with each class's text distribution; views with entropy below the threshold γ=0.8 are stored in a per-class cache together with their pseudo-labels, and when the cache is full, the sample with the highest entropy is replaced.
    • Cross-modal alignment: the cache stores visual features; an orthogonal transformation is learned by solving an Orthogonal Procrustes problem to align the cached features to that class's text space.
    • Final inference: ŷ=argmink dOT(Pt,Qk;Ct,k)+α  dcOT(Pt,Q̃k;C̃t,k), i.e., a weighted sum of global prompt alignment and local cache consensus, where α controls the cache contribution.

    Theoretical analysis and implementation parameters

    • Theorem 3.1: the authors decompose the 2-Wasserstein distance into a centroid alignment term (equivalent to the mean alignment of TPT-type methods) and a Bures metric term for covariance structure mismatch; this expression is exact for Gaussian distributions and is a lower bound for general distributions (proof in Appendix A). On this basis, the authors argue that optimizing only the centroid term leaves the structural variance unconstrained, giving attackers room to distort the distribution geometry.
    • Key parameters: number of prompts M=4 (template "a photo of a"), N=64 augmented views per image (including the original image), AdamW optimization, TTA steps fixed at 1, learning rate 0.005, entropy threshold γ=0.8; class descriptions on the text side are generated by an LLM; augmentations are random crop, resize, and horizontal flip (Appendix B states AugMix is actually used). The full pipeline is given in Algorithm 1 of Appendix E.
  4. What experiments did the paper conduct?

    On 8 fine-grained datasets and the ImageNet series, RITA achieves higher average robust accuracy than the baselines under attacks such as PGD, CW, DI, and AA.

    Experimental setup

    • Models tested: CLIP-ViT-B/32, CLIP-ViT-B/16 (main experiments); the appendix additionally tests CLIP-RN50 (Table 7), OpenCLIP and EVA-CLIP (Table 9), and adversarially fine-tuned models TeCoA, PMG, FARE (Table 2).
    • Datasets: 8 fine-grained classification datasets (Caltech101, Pets, Cars, Flower102, Aircraft, DTD, EuroSAT, UCF101); ImageNet and ImageNetV2, ImageNet-Sketch, ImageNet-A, ImageNet-R; Table 9 adds SUN397 and Food101. The paper does not report the sample size of each dataset.
    • Attacks: PGD (L∞, ϵ=1.0 in main experiments, ϵ=4.0 in appendix, 7 steps), with adversarial examples generated on the original CLIP model; the appendix additionally tests CW, DI, FGSM, AutoAttack, and adaptive attack (all ϵ=1.0, ViT-B/16).
    • Baselines: CLIP zero-shot, Ensemble (average of predictions over augmented views), TPT, C-TPT, MTA, R-TPT.
    • Metrics: clean accuracy (Acc.) and adversarial robust accuracy (Rob.); single-image inference time is also reported.
    • Protocol: instance-level test-time adaptation, with each test sample adapted and predicted independently; the paper does not report the number of repetitions or variance.

    Main results

    According to Table 1 (PGD ϵ=1.0, average over 8 fine-grained datasets, %):

    Swipe horizontally to read the table

    MethodViT-B/32 Acc.ViT-B/32 Rob.ViT-B/16 Acc.ViT-B/16 Rob.
    CLIP53.64.753.21.8
    Ensemble57.848.361.151.6
    TPT57.637.861.739.3
    C-TPT57.834.661.935.8
    MTA58.638.861.940.9
    R-TPT57.147.961.150.5
    RITA58.649.762.052.7
    • The authors state that RITA improves average robustness over CLIP by 45.0% (ViT-B/32) and 50.9% (ViT-B/16), and over R-TPT by 1.8% and 2.2%, while maintaining the highest average clean accuracy.
    • Exceptions: on ViT-B/32, Ensemble's robust accuracy of 48.3% is higher than R-TPT's 47.9%; on individual datasets RITA is not best in all cases (e.g., on ViT-B/32 Cars, R-TPT's 44.6% is higher than RITA's 42.9%; on ViT-B/16 UCF101, TPT's clean accuracy of 67.9% is higher than RITA's 65.5%).
    • ImageNet series (Table 5, ϵ=1.0): on ViT-B/16, RITA's Rob. on ImageNet is 55.1% (CLIP: 0.6%), and the average OOD Rob. is 46.2%; however, on ImageNet-A, RITA's Acc./Rob. (55.8/35.0) is lower than R-TPT's (57.2/34.7, with higher Acc. and close Rob.), and on ImageNet-R and ImageNet-Sketch, Ensemble or R-TPT has higher clean accuracy.

    Different attack types

    • Table 3 (ViT-B/16, ϵ=1.0): under CW attack, RITA's average Rob. is 54.0% (R-TPT 51.2%); under DI attack, 46.2% (R-TPT 44.2%).
    • Table 8 (ViT-B/16, ϵ=1.0): under AutoAttack, RITA's average Rob. is 55.4% (R-TPT 52.6%); under FGSM, 50.5% (R-TPT 48.2%); under adaptive attack with perception-enhancement strategies, 53.4% (R-TPT 50.6%). The authors state that the defense capability is not specific to a particular attack.
    • Exceptions: under DI attack, RITA is higher than R-TPT on datasets such as Pets (69.4%), but on Cars RITA's 39.9% is close to R-TPT's 39.1% (aside from Ensemble's 39.1%), and on Caltech101 RITA's 84.7% is slightly lower than R-TPT's 84.9%.

    Combination with adversarially fine-tuned models

    • Table 2 (ϵ=1.0): RITA applied on top of TeCoA, PMG, and FARE improves average Rob. from 23.8%→31.7%, 26.1%→32.6%, and 23.3%→41.0%, respectively.
    • The authors state that FARE+RITA reaches 81.9% Rob. on Caltech101, a 19.0% improvement over the FARE baseline.
    • Exceptions: in some cells RITA is not best, e.g., on TeCoA Cars, R-TPT's Rob. of 17.8% is higher than RITA's 15.7%; on FARE Cars, R-TPT's 33.0% is higher than RITA's 31.2%.

    Other ablations and analyses

    • Cache ablation (Table 10, ViT-B/32, ϵ=1.0): with only dcOT, fine-grained Acc./Rob. is 39.7%/27.1%; with only dOT, 57.0%/49.4%; with both combined, 57.9%/55.0%.
    • Hyperparameter sensitivity (Figure 3, DTD, ViT-B/16): performance improves steadily as learnable prompts increase from 4 to 32; adversarial accuracy is highest at 96 augmented views and decreases slightly at 128.
    • Cache weight α (Figure 4, DTD and ImageNet): increasing α from 0 to 0.1 gives a clear gain, after which it rises slowly and stabilizes.
    • Perturbation budget and TTA steps (Figures 5, 6): accuracy decreases as ϵ increases from 1 to 4; performance is highest at 2 TTA steps and decreases slightly at 4, so the authors choose 1 TTA step to balance efficiency.
    • Inference time (Table 4, ViT-B/16, ϵ=1.0): RITA 1.76s/image, R-TPT 1.70s, MTA fastest at 1.20s; the authors state that RITA's robust accuracy is 11.8% higher than MTA's.
    • Semantic alignment analysis (Figures 7, 8, DTD and Caltech101): the KDE curves of the KL divergence between the class-conditional distribution of the augmented views used by the cache and the ideal one-hot are shifted left relative to the original adversarial views and more concentrated in the low-value region; the authors state that this indicates the cache mechanism corrects adversarial semantic bias.
    • Other backbones: on RN50 (Table 7, ϵ=1.0), RITA's average Rob. is 46.4% (R-TPT 43.0%); on OpenCLIP, average Rob. rises from 2.4% to 54.4%, and on EVA-CLIP from 1.6% to 54.8% (Table 9, 10 datasets).
  5. What are some points that can be further explored?

    The authors note that extension to generative tasks is left for future work; the experiments cover only image classification and attacks generated on the original CLIP.

    Limitations and future directions noted by the authors

    • Conclusion & Limitations: RITA currently targets image classification, and extension to generative tasks such as image captioning is left for future exploration.
    • Impact Statement: the authors state that the method cannot eliminate all safety risks, that adversarial attacks may continue to evolve, and that future work should further study robust inference-time defenses and evaluate potential failure modes and misuse risks.

    Scope of experimental coverage

    • The models tested are CLIP (ViT-B/32, ViT-B/16, RN50), OpenCLIP, EVA-CLIP, and adversarially fine-tuned models TeCoA, PMG, FARE, 8 in total (Tables 1, 2, 7, 9).
    • The task type is image classification: 8 fine-grained datasets, ImageNet and 4 OOD variants, with Table 9 adding SUN397 and Food101; generative tasks are not covered (the authors state this in the conclusion).
    • Attacks covered are PGD (ϵ=1.0, 4.0), CW, DI, FGSM, AutoAttack, and adaptive attack with perception-enhancement strategies, all with L∞ constraint and ϵ=1.0 (Tables 3, 8); adversarial examples in the main experiments are generated on the original CLIP model (Appendix B).
    • The compared methods in the defense evaluation are TPT, C-TPT, MTA, R-TPT, Ensemble, and zero-shot CLIP (Table 1).
    • The paper does not report the sample size of each dataset, the number of experimental repetitions, or variance, nor does it report the specific LLM used to generate class descriptions (Section 4.1 only says "an Large Language Model").
  6. Summarize the main content of the paper

    RITA uses optimal transport for distribution-level test-time prompt adaptation, improving CLIP's adversarial robustness under multiple attacks.

    A defense paper on VLM adversarial robustness that proposes a test-time prompt adaptation framework, RITA.

    • Problem: the authors state that VLMs such as CLIP suffer large performance drops under adversarial perturbations, while existing test-time methods such as TPT and R-TPT rely on sample-level confidence and cannot distinguish high-confidence adversarial mispredictions from genuine semantic consistency.
    • Method: models N=64 augmented views of an adversarial image and M=4 text prototypes per class as discrete distributions, and performs distribution-level alignment using entropy-regularized optimal transport; then uses an entropy threshold of 0.8 to select reliable views into a dynamic cache, aligns them to the text space via Orthogonal Procrustes, and incorporates them into joint transport cost inference; Theorem 3.1 gives a decomposition into centroid alignment plus a covariance structure penalty.
    • Main results: under PGD ϵ=1.0, RITA achieves average robust accuracy of 49.7% (ViT-B/32) and 52.7% (ViT-B/16) on 8 fine-grained datasets, higher than R-TPT's 47.9% and 50.5% (Table 1); on ImageNet, ViT-B/16 robust accuracy is 55.1% (Table 5).
    • Attack generalization: average 54.0% under CW, 46.2% under DI, 55.4% under AutoAttack, and 53.4% under adaptive attack, all higher than R-TPT (Tables 3, 8).
    • Compatibility: when stacked on FARE, average robust accuracy rises from 23.3% to 41.0% (Table 2); inference takes 1.76s/image, close to R-TPT's 1.70s (Table 4).
    • Authors' conclusion: the authors consider distribution-level alignment an effective paradigm for robust VLM inference; they also note that extension to generative tasks is left for future work and that the method cannot eliminate all security risks.

Related papers

Show 3 more papers
Read originalICML 2026