Skip to content

Not Just Counterattack, but Precise Targeting: Direction-Aware Test-Time Counterattacks for Robust Vision-Language ModelsNot Just Fighting Back, But Aiming Right: Direction-Aware Test-Time Counterattacks for Robust Vision-Language Models

Chunchun Chen, Li Gu, Weidong Zhang, Zhaokai Sun, Yuxing Zhang, Xiaofeng Cao, Yuanqiang Zhou, Rui Fan, Xin Sun, Tiantian He, Wei Ye
Tongji University; Shanghai Jiao Tong University; City University of Macau; A*STAR
arXiv: Adversarial Attacks, Backdoors & PoisoningarXiv:2612.01026Originally published Indexed by this site · 18 hr agoDefenses

Quick read

Defenses

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

The authors propose the DART direction-aware objective for CLIP test-time counterattack; on 16 datasets under PGD-10, DOC+DART achieves an average robust accuracy of 59.61%.

Threat modelThe victim system is a frozen-parameter CLIP zero-shot classifier. The attacker constructs bounded adversarial perturbations using true labels, mainly using 10-step PGD, ϵadv=1/255, and also tests CW, AutoAttack, and ϵadv=4/255; the defender has no true labels and does not update model parameters, and only optimizes the counterattack perturbation in input space at test time.

Questions
CLIP zero-shot classification is susceptible to adversarial perturbations. Existing test-time counterattacks mainly push representations away from the adversarial state, but do not specify the correct class to move toward or the classes to avoid; the authors believe this may cause representations to enter incorrect semantic regions.
Methods
DART is integrated as a plug-and-play objective into TTC, DOC, and MAC: it constructs semantic anchors from multi-view visual features and fine-grained text prototypes for attraction, then aggregates confidence-weighted text repulsion by class, optimizing a bounded input perturbation on frozen CLIP.
Experiments and results
The experiments cover 16 datasets, four ImageNet-OOD datasets, and multiple attacks. The authors report that under PGD-10, DART improves the robust accuracy of the three frameworks on each dataset; DOC+DART averages 59.61% on the 16 datasets, and SCC is 51.68%.
Limitations and future work
The main experiments use only CLIP ViT-B/32, with attacks PGD, CW, and AutoAttack; the paper does not report the number of repeated experiments, statistical significance tests, or adaptive attack evaluations. The conclusion section does not specifically discuss limitations or future directions.
Experimental setupCLIP ViT-B/32 · CIFAR10、CIFAR100 et al. · Clean accuracy (Acc.)、Adversarial accuracy (Rob.) et al.
AI summaryThe paper proposes a direction-aware test-time counterattack (TTC) objective that improves the zero-shot adversarial robustness of vision-language models such as CLIP. Addressing the lack of a target direction in existing TTC, its attraction term builds stable semantic anchors from transformation-consistent visual and fine-grained text features, and its repulsion term uses weighted class text prototypes to push representations away from non-target classes. Across multiple datasets and multiple attack settings, this plug-and-play module consistently improves the adversarial robustness of existing TTC methods.

The paper proposes a direction-aware test-time counterattack (TTC) objective that improves the zero-shot adversarial robustness of vision-language models such as CLIP. Addressing the lack of a target direction in existing TTC, its attraction term builds stable semantic anchors from transformation-consistent visual and fine-grained text features, and its repulsion term uses weighted class text prototypes to push representations away from non-target classes. Across multiple datasets and multiple attack settings, this plug-and-play module consistently improves the adversarial robustness of existing TTC methods.

Related events and news

1 events · 0 news mentions

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Adding semantic attraction and class repulsion to direction-free test-time counterattack improves CLIP zero-shot adversarial robustness.

    The core problem is: test-time counterattacks only make CLIP representations escape the adversarial region, without specifying the recovery direction, and may fall into incorrect class regions.

    • Problem scenario: CLIP can recognize zero-shot without task training, but is still susceptible to adversarial perturbations. The authors hope to improve robustness at test time while preserving pretrained representations and zero-shot capability.
    • Shortcomings of existing methods: The authors state that prompt tuning does not directly recover damaged visual features; feature corrections such as AOM and DBD lack explicit per-class repulsion; displacement objectives such as TTC do not specify a semantic target. Although SCC includes attraction and repulsion, its hardest negative class selection only excludes the estimated pseudo-label, and when the pseudo-label is wrong it may repel the true class.
    • Core observation: In Figure 1, on STL10, CLIP clean accuracy is 96.40%, after PGD-10 it is 11.00%, TTC recovers to 76.70%, and TTC+DART is 87.00%. The Figure 2 caption states that features recovered by TTC, DOC, and MAC remain scattered, and after adding DART the distribution is more compact and aligned with the clean boundary.
    • Proposed method: The authors propose Direction-AwaRe Test-time counterattack (DART), which attracts representations with stable semantic anchors and applies class-support-weighted text repulsion; it replaces the counterattack objective of TTC, DOC, and MAC, with the rest of the pipeline unchanged.
    • Threat model:
      • Attack goal: Optimize bounded perturbations on clean images with true labels to make CLIP misclassify.
      • Attack settings: Mainly 10-step PGD, ϵadv=1/255; CW, AutoAttack, and ϵadv=4/255 are also tested.
      • Defender knowledge and capability: No true labels at test time, no model parameter updates, only optimizing the input-space counterattack perturbation through the frozen visual encoder.
      • Victim system: CLIP ViT-B/32 zero-shot classifier using handcrafted class prompts.
  2. What related research exists?

    Related work is divided into training-time defenses, three types of test-time defenses, and the counterattack framework that this paper directly integrates.

    Training-time robustness

    • TeCoA, FARE, PMG-AFT: respectively align adversarial features with real text embeddings, use frozen clean image embeddings as unlabeled targets, and apply pretrained-model regularization. The authors summarize that such methods require training data and may harm generalization.
    • LAAT, APT, GLADIATOR: respectively introduce language-driven anchors, perform adversarial training on text prompts, and stabilize the modality gap and gradient norms through bimodal fine-tuning.
    • Comp-TGA, AGFT, UCAT, LEAF: respectively combine class-guided and reverse non-class-guided attention, use soft alignment and distribution consistency to preserve cross-modal relations, align Dirichlet distributions, and fine-tune the text encoder against text perturbations.

    Test-time prompt tuning and feature correction

    • R-TPT, TAPT: R-TPT optimizes text prompts with pointwise entropy minimization and performs reliability-weighted view ensembling; TAPT adapts visual and text prompts through multi-view entropy minimization and prediction distribution alignment.
    • AOM, ATAC, DBD, T-VSS: AOM takes a one-step linear move toward anchors obtained from Gaussian-noise views; ATAC and DBD estimate the recovery direction from feature shifts caused by augmentation; T-VSS learns corrections in a sample-specific subspace. The paper points out that AOM and DBD lack explicit per-class repulsion.

    Input-space test-time counterattack

    • TTC, DOC, MAC: TTC maximizes embedding displacement to escape a false stable state; DOC adds orthogonal gradient exploration and momentum; MAC combines multi-view counterattack with corruption-aware intensity weighting.
    • SCC: combines soft prototype attraction, hardest negative class repulsion, and multi-view consistency. The paper explicitly criticizes that its hardest negative class selection only excludes the estimated pseudo-label, and when the pseudo-label is wrong it may repel the true class.

    Comparison baselines and benchmarks

    • Baseline methods: zero-shot CLIP; fine-tuning group CLIP-FT, TeCoA, PMG-AFT, FARE; parameter-free test-time defenses RN, Anti-adv, HD; counterattack methods SCC, TTC, DOC, MAC.
    • Evaluation data: 16 recognition datasets and four OOD variants ImageNetV2, ImageNet-Sketch, ImageNet-A, ImageNet-R; the main table uses PGD-10, and CW and AutoAttack are also tested.

    The authors position DART as a unified direction-aware objective for input-space counterattack: without changing prompts or pretrained parameters, it adds semantic anchor attraction and per-class text repulsion to iterative input correction.

  3. How does the paper address this problem?

    DART uses visual–text semantic anchor attraction and low-confidence class repulsion, replacing the original pure-displacement counterattack objective.

    The overall idea is to integrate DART as a plug-and-play objective into TTC, DOC, and MAC: first estimate the recovery direction from multi-views of the adversarial input and fine-grained class descriptions, then optimize the input within the perturbation budget, with CLIP parameters always frozen.

    Problem Setup and Counterattack Formalization

    • Zero-shot classification: With frozen image encoder fθ and text encoder gϕ, compute cosine similarity between normalized image features and text features of each class, and take the class with the highest probability after softmax.
    • Original counterattack: TTC maximizes the Euclidean distance between embeddings before and after counterattack within the ϵcat budget. Since normalized features lie on the unit hypersphere, this distance is determined by the angle; the authors point out that the displacement itself gives neither a reliable semantic target nor the class regions to avoid.
    • Available information: At test time there are no clean features or true labels, so anchors can only be constructed from augmented views of the adversarial input and class text features.

    Semantic Anchor-Guided Attraction

    • Multi-view reliability: Each input constructs N views, including the original input and N−1 AugMix views. View reliability is computed from its consistency with features of other views, then weighted by softmax with temperature τv=0.07; higher consistency gives larger weight.
    • Visual anchor: Normalized visual features of each view are aggregated by reliability weight, then normalized. The authors state that this can limit the influence of inconsistent views and reduce dependence on a single transformation.
    • Text anchor: M fine-grained descriptions are generated offline for each class, encoded by the frozen text encoder, averaged, and normalized into text prototypes. Each view's class prediction is aggregated into qk by visual reliability weight, then all class prototypes are weighted by qk, avoiding reliance on a single class prediction.
    • Anchor fusion: zanc=sg[norm((1−β)zvis+β ztxt)], where β=0.5 and sg denotes stop-gradient. This anchor is computed before counterattack optimization and kept fixed; the visual part provides instance content, and the text part provides class semantics.

    Class-Conditional Text Repulsion

    • Weight design: Class weights are proportional to 1−qk and normalized, that is, classes with lower aggregated confidence receive larger weights.
    • Repulsion effect: During optimization, the counterattacked representation is pushed away from the fine-grained text prototypes of these weakly supported classes, but not toward any specified class. The repulsion temperature is τu=0.07.
    • Difference from SCC: Here confidence weighting over all classes is used, rather than selecting the hardest negative class only around the estimated pseudo-label; this is the paper's explanation of the design, not an additional experimental conclusion.

    Direction-Aware Optimization and Integration

    • Core objective: δcat=argmaxδ′:|δ′|p≤ϵcat|zcat−zadv|2−λ1|zcat−zanc|2+λ2Rtxt. The three terms respectively move away from the adversarial state, toward the semantic anchor, and away from weakly supported classes; defaults are λ1=3, λ2=0.5.
    • Optimization: The paper illustrates the maximization process with projected sign gradient ascent; actual updates retain each framework's original design, such as DOC's orthogonal exploration and momentum; only the counterattack objective is replaced, and initialization, gating, multi-view processing, etc. remain unchanged.
    • Inference: TTC and DOC use single-view scores, and MAC averages scores over counterattack views, finally taking the class with the highest score.

    Key Implementation Parameters

    • General settings: Backbone is CLIP ViT-B/32, using CLIP handcrafted prompts; N=64, M=50 descriptions per class, descriptions taken from [37], with missing parts supplemented by GPT-6.1 Sol; τv=τt=τu=0.07.
    • TTC settings: Counterattack budget 4/255, two iterations, step size 1/255, threshold 0.2, weight coefficient 2.
    • DOC and MAC settings: DOC budget 4/255, three iterations, step size 1/255, effective threshold 0.19, sigmoid gate temperature 70; MAC budget 8/255, four iterations, step size 2/255, threshold 0.5, tau temp=0.01, eight views.
  4. What experiments did the paper conduct?

    On 20 datasets, DART improves the robust accuracy of three counterattack frameworks, and attack strength, attack type and ablations are tested.

    Experimental Setup

    • Models under test: All results are based on CLIP ViT-B/32; CLIP-FT, TeCoA, PMG-AFT, and FARE are fine-tuning controls, and test-time methods all operate on this backbone. The paper does not report results for other CLIP backbones.
    • Datasets and scale: 16 recognition datasets plus four ImageNet-OOD, 20 in total. Appendix Table 6 lists evaluation scales, for example ImageNet validation set 50,000 images, CIFAR10 test set 10,000 images, DTD test set 1,880 images, PCAM test set 32,768 images.
    • Baselines: zero-shot CLIP; CLIP-FT, TeCoA, PMG-AFT, FARE; RN, Anti-adv, HD; SCC, TTC, DOC, MAC. DART replaces the counterattack objective of the latter three respectively.
    • Metrics and attacks: Acc. is classification accuracy on clean images, Rob. is classification accuracy on adversarial images. The main experiments use 10-step PGD, ϵadv=1/255; CW and AutoAttack under the same budget, and PGD and CW with ϵadv=4/255, are also tested.
    • Implementation and decision rule: predictions are determined by the class with the highest model similarity, without LLM judging. Batch size 128, run on NVIDIA RTX 3090 GPU; the paper does not report the number of repetitions or statistical significance tests.

    Main Results

    According to Table 2, the condition is 16 datasets, PGD-10, ϵadv=1/255; values are average accuracy across datasets, and the Imp. column is not included in the average.

    MethodAverage Rob. (%)Average Acc. (%)
    CLIP2.7061.51
    TeCoA26.5440.25
    PMG-AFT28.7642.30
    FARE20.0051.02
    SCC51.6860.21
    TTC / TTC+DART39.17 / 56.0959.75 / 60.71
    DOC / DOC+DART44.27 / 59.6159.61 / 60.72
    MAC / MAC+DART47.84 / 58.1357.62 / 57.45
    • Per-dataset results: The authors report that DART improves the Rob. of TTC, DOC, and MAC on all 16 datasets; the average absolute gains given in the main text are 16.92%, 15.34%, and 10.29% respectively.
    • Distribution of best frameworks: The authors state that the best Rob. on each dataset comes from some +DART framework; DOC+DART has the highest average Rob., and SCC is the baseline without DART with the highest average performance.
    • Clean accuracy exceptions: Not all methods maintain or improve average Acc.; MAC+DART is lower than original MAC. Per-dataset Imp. also has both positive and negative values, for example Caltech101 is +0.94 percentage points, ImageNet is −4.30 percentage points.

    OOD and Different Attacks

    • ImageNet-OOD: According to Table 3, DOC+DART has average Rob. 52.69% and Acc. 45.42% on the four datasets, and SCC has 38.85% and 43.48% respectively; TTC+DART has average Rob. 47.41%, and MAC+DART 39.18%. The authors state that after adding DART to the three frameworks, both Rob. and Acc. improve on all four OOD datasets.
    • Stronger attack budget: According to Table 4, at ϵadv=4/255, TTC+DART has average PGD Rob. 56.26% and CW Rob. 56.69% on the 16 datasets, while original TTC has 20.63% and 20.61% respectively; its average clean accuracy is 60.51%.
    • Full strong-budget results: In Appendix Table 8, DOC+DART has average PGD Rob. 61.14% and CW 54.12%; MAC+DART has 39.38% and 38.49% respectively. Appendix S.5 states that the three frameworks improve on every dataset under both attacks, with average gains of about 8–36%.
    • CW and AutoAttack: According to Table 5, at ϵadv=1/255, TTC+DART has average Rob. 55.10% under CW and 55.87% under AutoAttack, while original TTC has 38.17% and 45.67% respectively; the corresponding average Acc. is 60.91% and 54.10%, and original TTC is 59.75% and 46.21%.

    Ablation, Visualization, and Runtime Cost

    • Attraction and repulsion ablation: According to Table 9, the full objective of TTC+DART has average Rob. 56.09%, removing attraction with λ1=0 gives 27.60%, and removing repulsion with λ2=0 gives 53.49%; DOC+DART corresponds to 59.61%, 32.34%, 58.27%, and MAC+DART corresponds to 58.13%, 45.48%, 48.84%. The authors state that the full objective has the highest Rob. on all datasets and frameworks.
    • Visual and text anchors: Figure 5 compares visual-only, text-only, and combined anchors; the authors state that combined anchors perform best on each dataset, visual-only is usually second, and text-only is lowest. The converted text does not retain reliably corresponding per-bar values, so specific values are not listed.
    • Qualitative examples: Appendix Figure 8 gives predictions and confidences for four images; the authors state that DART variants correct some TTC and DOC errors and increase confidence in already correct predictions. These are individual case displays, not independent quantitative evaluations.
    • Runtime: According to Table 7, anchor construction on 20 datasets is 49.694±0.461 ms/image; TTC and TTC+DART are 3.710±0.023 and 3.765±0.053 ms/image, DOC is 4.130±0.043 and 4.174±0.069, MAC is 44.660±0.593 and 45.226±1.098. The authors state that adding DART increases the framework's own timing by about 1–1.5%, and anchor time is listed separately.

    Other Ablations and Analysis

    • λ1, λ2: Figure 6 jointly scans on DTD, Aircraft, and OxfordPets; the authors state that without attraction, increasing λ2 continuously decreases robustness, and λ1=3, λ2=0.5 as a shared setting is competitive.
    • β: Figure 7 scans β on the above three datasets; the authors state that Rob. increases from β=0 to 0.5 and decreases with further increase, with peaks all at β=0.5.
    • Figure 4: A radar chart shows the full objective of the three frameworks and two variants with terms removed; its trends are given by Table 9 with full values that can be checked.
    • Figure 1: In the STL10 example, PGD-10 changes the cat image prediction from Ragdoll to Siamese, TTC does not correct it, and TTC+DART restores Ragdoll; this is a single-image example.
  5. What are some points that can be further explored?

    The paper does not specifically list limitations; the available evidence is concentrated on a single CLIP backbone, established attacks, and offline class descriptions.

    Limitations and future directions noted by the authors

    • The paper does not specifically discuss limitations: Section 7, Conclusion, of the main text summarizes the method and experiments and does not explicitly list limitations or future work; Appendices S.1–S.6 also mainly supplement data, implementation, runtime, visualization and full results.
    • A design premise rather than a limitation statement: Section 4 points out that the pure-displacement objective does not provide a reliable semantic target or class regions to avoid; this is the motivation for proposing DART and is not the authors' statement of DART's own limitations.

    Scope of experimental coverage

    • Model coverage: The main results, OOD, attack variations and ablations all use CLIP ViT-B/32 (Section 6.1); the paper does not report results on other backbones.
    • Data coverage: 20 datasets in total, including 16 recognition datasets and four ImageNet-OOD; the evaluation splits, number of classes, number of samples and manual prompts are given in Appendix Table 6.
    • Attack coverage: Includes 10-step PGD, 10-step CW and AutoAttack; PGD and CW cover the corresponding settings of ϵadv=1/255 or 4/255, and AutoAttack uses ϵadv=1/255 in Table 5. The paper does not report adaptive attacks designed against DART.
    • Text and view sources: 50 descriptions per class, taken from [37], with gaps supplemented by GPT-6.1 Sol; the visual side uses the original input plus AugMix views, with the general setting N=64 (Section 6.1).
    • How evidence is reported: Classification results are reported as accuracy, and runtime is reported as the mean and standard deviation over the 20 datasets (Table 7); the paper does not report the number of repetitions, confidence intervals, statistical significance tests or human evaluation for the classification experiments.
  6. Summarize the main content of the paper

    DART changes test-time counterattack from merely moving away from the adversarial state to a semantically directed recovery, and is evaluated on 20 datasets.

    DART is a test-time input-space defense objective for CLIP zero-shot classification, used to address the problem that existing counterattacks only enlarge feature displacement without specifying the direction of the recovery class.

    • Method highlights: Visual anchors are constructed from the consistency of AugMix multi-views, and text anchors from fine-grained descriptions of each class and multi-view class confidences; the fused anchor is responsible for attraction, and classes with lower aggregated confidence receive larger text repulsion weights.
    • Integration: Only the counterattack objective of TTC, DOC, and MAC is replaced, retaining their respective optimization, gating, and multi-view pipelines; CLIP parameters are frozen, and true labels are not used at test time.
    • Main results on 16 datasets: Under PGD-10, ϵadv=1/255, the average Rob. of TTC, DOC, and MAC after adding DART is 56.09%, 59.61%, and 58.13%, respectively, and the original methods are 39.17%, 44.27%, and 47.84%; SCC is 51.68% (Table 2).
    • OOD results: On the four ImageNet-OOD datasets, DOC+DART has average Rob. 52.69%, and SCC is 38.85%; TTC+DART and MAC+DART are 47.41% and 39.18% respectively (Table 3).
    • Attack variations: At ϵadv=4/255, TTC+DART has average PGD and CW Rob. 56.26% and 56.69%; under AutoAttack at ϵadv=1/255 it is 55.87%, and original TTC is 45.67% (Table 4, Table 5).
    • Cost and ablation: MAC+DART has average clean accuracy 57.45%, lower than original MAC's 57.62%; removing attraction or repulsion both reduces the average Rob. of the three frameworks (Table 2, Table 9).

    Based on this, the authors believe that explicit direction guidance can serve as a plug-and-play objective for various test-time counterattacks, improving adversarial robustness while maintaining competitive clean accuracy. The experimental conclusions are based on CLIP ViT-B/32 and the attacks listed in the paper; the paper does not specifically discuss the limitations or future directions of DART.

Research lineage

4 foundations · 0 follow-ups in library
Explore in knowledge graph →

Hover or focus a connected paper to inspect the citation context.

Related papers

Show 3 more papers
Read originalarxiv.org