Visual Prompts for Adversarial RobustnessVisual Prompting for Adversarial Robustness
The authors propose C-AVP, which uses class-wise visual prompts to harden a fixed pretrained model at test time; on CIFAR-10/ResNet18 it achieves 57.57% standard accuracy and 34.75% PGD-10 robust accuracy (Table 1).
The defender hardens a fixed, standard-trained pretrained model (ResNet18 on CIFAR-10) at test time without modifying model parameters; the attack is a PGD adversarial attack with l∞ norm ε=8/255 (PGD-10 is used when training the prompts, and PGD-10/20/50/100 for evaluation). The paper does not state whether the attacker knows about the defense.
- Robustification methods such as adversarial training are computationally expensive and hard to apply to fixed pretrained models; existing test-time defenses in turn increase inference time. The authors ask: can visual prompting (VP) improve the adversarial robustness of a fixed model at low cost at test time?
- The authors propose C-AVP: learn one visual prompt per class, and use three joint regularization terms to respectively constrain the prompt selection rule, suppress the backdoor effect of mismatched prompts, and widen the confidence gap between matched and mismatched prompts; once the prompts are learned offline, they are plug-and-play at test time.
- On CIFAR-10/ResNet18, C-AVP achieves 57.57% standard accuracy and 34.75% PGD-10 robust accuracy, higher than U-AVP's 27.75%/16.9% (Table 1); its inference overhead is 1.4×, lower than the three test-time defense baselines, but its robust accuracy is lower than [44]'s 50.6% (Table 3).
- The authors acknowledge a performance gap between C-AVP and test-time defense baselines (Section 5). Experiments are conducted on only one setting, CIFAR-10/ResNet18, and only PGD is evaluated as the attack; the paper does not report adaptive attack evaluations or the number of repetitions.
- Evaluated models
- ResNet18
- Benchmarks
- CIFAR-10
- Metrics
- standard accuracyrobust accuracy (vs PGD)inference time (IT)
The researchers propose class-level adversarial visual prompts (C-AVP), which generate class-level visual prompts at test time for a fixed pretrained model to improve adversarial robustness. General visual prompts struggle to defend against sample-specific adversarial perturbations, whereas C-AVP leverages the advantages of ensemble prompts and optimizes the relationships among class-level prompts. Experiments show that C-AVP improves standard accuracy by 2.1X and robust accuracy by 2X over conventional visual prompts, and speeds up inference by 42X compared with classic test-time defenses.
Paper analysis
What problem does this paper attempt to solve?
Whether visual prompts (VP) can be used at test time to harden a fixed pretrained model at low cost against adversarial attacks.
Core question: Can visual prompts (VP) be designed as an effective test-time adversarial defense to harden a fixed pretrained model?
- Setting and motivation: Robust training methods such as adversarial training (AT) are computationally expensive and hard to apply to already-fixed pretrained models; the authors state that existing test-time defenses (input purification, model modification) increase inference time and harm test-time efficiency (Section 1).
- Shortcomings of existing methods: The authors state that VP had previously been used only to improve generalization, and whether it can be used for adversarial defense is unclear (abstract); the paper's experiments show that a directly adapted VP (U-AVP) drops standard accuracy by more than 50% while improving robust accuracy by only about 18% (Fig. 1).
- Core observation: The authors argue that data-agnostic universal prompt learning has limited capability and is insufficient against sample-specific adversarial perturbations; class-wise prompts in turn bring two challenges: prompt selection errors and the "backdoor effect" (Sections 3, 4).
- Paper's proposal: Proposes C-AVP (Class-wise Adversarial Visual Prompting), which generates one visual prompt per class and jointly optimizes the relationships among them, trained offline and plug-and-play at test time (abstract, Section 4).
- Threat model:
- Defense target: a fixed, standard-trained pretrained classifier (ResNet18 on CIFAR-10 in the experiments), without modifying model parameters.
- Attack: PGD adversarial attack with l∞ norm ε=8/255, evaluated with PGD-10/20/50/100 (Section 5).
- The paper does not state the attacker's level of knowledge of the defense (white-box/black-box not specified).
What related research exists?
Related work falls into two groups: visual prompting/model reprogramming and adversarial defenses; baselines are U-AVP, C-AVP-v0, and three test-time defenses.
Visual Prompts and Model Reprogramming
- Bahng et al. [21]—propose visual prompts (VP), adapting a pretrained model by modifying the pixel space; this paper's VP problem setting follows that work.
- Model/adversarial reprogramming [22–24, 31–33]—add a universal perturbation pattern to test samples to reprogram a fixed model to cross-domain tasks; Tsai et al. [24] do black-box transfer, Zhang et al. [25] do fairness reprogramming.
- Salman et al. [26] (unadversarial examples)—use "prompt"-style template perturbations on the original image to improve out-of-distribution generalization. The paper notes that the problem of using VP for adversarial defense has not yet been explored.
Adversarial Defenses
- Adversarial training (AT) [1] and its follow-ups [2–13]—robust training via min-max optimization, the most commonly used defense line; the authors state that such methods are computationally expensive.
- Test-time defenses [14–20, 43–45]—Croce et al. [14] propose a benchmark for evaluating test-time defenses; input purification [15, 43], anti-adversarial perturbation [17], small modifications to a fixed model [44, 45]; the authors state that these methods increase inference time, among which [17] is most related to this paper.
- Adversarial detection [19, 34–38]—detecting adversarial examples; the paper lists these only as background.
Baselines and Benchmarks
- Baseline methods: U-AVP (a direct extension of VP to adversarial defense), C-AVP-v0 (a direct per-class prompt decomposition version), and three test-time defenses [43], [15], [44] selected from the Croce et al. [14] benchmark (Table 3).
- Dataset: CIFAR-10; victim model: pretrained ResNet18.
Positioning of this paper: the authors state that this paper is the first work to study VP for adversarial defense (AVP), and propose C-AVP, which partitions by class and is jointly optimized, trading robustness for lower inference overhead than classical test-time defenses (Sections 1, 6).
How does the paper address this problem?
C-AVP: one visual prompt per class, using three joint regularization terms to address prompt selection errors and the backdoor effect, trained offline and plug-and-play at test time.
Overall approach: extend VP from "a single universal prompt" to "one prompt per class," and explicitly optimize the coupling between prompts; the method is named C-AVP (Class-wise Adversarial Visual Prompting).
Problem Setting and U-AVP
- Standard form of VP: learn a perturbation δ that minimizes the prediction loss of the pretrained model θ on x+δ, with constraint C requiring x+δ ∈ [0,1], solvable with PGD (Equation (1)).
- The authors apply the adversarial training loss to VP to obtain U-AVP: minimize both the clean loss and the adversarial loss over δ, with λ balancing the two; solved by alternating inner maximization (generating adversarial examples) and outer minimization (updating δ).
- The authors state that U-AVP performs poorly: the ability of data-independent universal prompts to learn is limited (Fig. 1).
Two Challenges of Class-wise Prompts
- (C1) Test-time prompt selection: it is unclear which class's prompt a test sample should use; the intuitive rule is to select the prompt that maximizes the model's top-1 confidence (Equation (3)), but the authors state that this rule produces many selection errors due to (C2).
- (C2) Backdoor effect of mismatched prompts: when the prompt for class i is added to a sample not of class i, it steers the prediction toward class i like a backdoor trigger (the authors cite BadNets [46] as an analogy), because backdoor triggers are likewise input-independent.
Joint Optimization Objective of C-AVP
- The base term
C−AVP,0is the objective of C-AVP-v0: split the training set by class, learn one prompt per class, and the classes are decomposable. C−AVP,1(Equation (4)): a CW-type loss requiring the correct class's prompt to have confidence at least τ higher than other prompts on its data, incorporating selection rule (3) into training; this term is not decomposable by class, forcing joint optimization of prompts.C−AVP,2(Equation (5)): penalizes the targeted prediction confidence when prompt δ(i) is added to data not of class i, suppressing the backdoor effect.C−AVP,3(Equation (6)): requires the confidence of the matched prompt to be higher than that of mismatched prompts.- Total objective: min{δ(i)∈ C} ℓC−AVP,0 + γ ∑q=13 ℓC−AVP,q, i.e., three class-wise prompt penalty terms added to the C-AVP-v0 objective, with γ controlling their weight.
Training and Evaluation Settings
- Key parameters: λ=1 (U-AVP), τ=0.1, γ=3 (C-AVP), prompt width 8; during training, adversarial examples are generated with PGD-10 (ε=8/255), with cosine learning rate starting from 0.1 (Section 5).
- Evaluation: standard accuracy (clean samples with prompts) and robust accuracy against PGD attacks (adversarial samples with prompts); prompts are trained offline and directly added to the input at test time.
What experiments did the paper conduct?
On CIFAR-10/ResNet18, C-AVP achieves 57.57% standard accuracy and 34.75% PGD-10 robust accuracy, outperforming U-AVP, with 1.4× inference overhead.
Experimental Setup
- Model under test: a standard-trained pretrained ResNet18 on CIFAR-10, standard test accuracy 94.92% (Section 5).
- Dataset: CIFAR-10 (the paper does not state the sample size used).
- Baselines: the pretrained model itself, Vanilla VP (Eq. (1)), U-AVP, C-AVP-v0; test-time defense baselines [43], [15], [44] (selected from Croce et al. [14], Table 3).
- Metrics: standard accuracy (SA), robust accuracy (RA) against PGD (ε=8/255, 10/20/50/100 steps), inference time multiplier (IT).
- Training setup: PGD-10 generates adversarial examples, cosine learning rate starting at 0.1; λ=1, τ=0.1, γ=3, prompt width 8.
- Number of repetitions: not reported in the paper.
Main Results
According to Table 1 (CIFAR-10, ResNet18, ε=8/255):
Swipe horizontally to read the table
Method Std acc (%) PGD-10 PGD-20 PGD-50 PGD-100 Pre-trained 94.92 0 0 0 0 Vanilla VP 94.48 0 0 0 0 U-AVP 27.75 16.9 16.81 16.81 16.7 C-AVP-v0 19.69 13.91 13.63 13.6 13.58 C-AVP (ours) 57.57 34.75 34.62 34.51 33.63 - The authors state that C-AVP outperforms U-AVP and C-AVP-v0 on both standard accuracy and robust accuracy; the abstract summarizes this as a 2.1× standard accuracy gain and a 2× robust accuracy gain.
- The authors note that, compared with the pretrained model and Vanilla VP, the VP variants that gain robustness trade a drop in standard accuracy for robustness.
Ablation of the Prompt Regularization Terms
- According to Table 2 (CIFAR-10, ResNet18): S1 (all three weights 8) Std 19.69%/PGD-10 13.91%; S3 (
C−AVP,2reduced to 4) 40.01%/25.40%; S5 (C−AVP,1,C−AVP,2set to 4) 57.03%/32.39%; S7 (all three set to 4) 57.57%/34.75%. - The authors state that
C−AVP,2contributes the most (see S3), because it targets the backdoor effect, the main source of prompt selection errors;C−AVP,1is second, because it pairs with selection rule (3). - The authors state that the combination of
C−AVP,1+C−AVP,2is a computationally lighter alternative.
Analysis of Inter-class Prediction Errors
- Fig. 4 compares the classification confusion matrices of C-AVP-v0 and C-AVP: rows are the true class of the test samples, columns are the selected prompts ('P') covering the 10 classes.
- The authors state that C-AVP has a higher main diagonal and fewer prompt selection errors; the converted text does not show the specific values in the matrices.
Comparison with Test-time Defenses
- According to Table 3 (same fixed ResNet18, PGD-10): [43] IT 518×, SA 85.9%, RA 0.4%; [15] IT 176×, SA 91.1%, RA 40.3%; [44] IT 59×, SA 56.1%, RA 50.6%; C-AVP IT 1.4×, SA 57.6%, RA 34.8%.
- The authors state that C-AVP belongs to the input purification (IP) category but requires no additional test-time operations (IA/AN/R are all not required), and has the smallest inference overhead; the abstract summarizes this as a 42× inference speedup.
- The authors acknowledge that a performance gap exists between C-AVP and these test-time defense baselines (RA is lower than [15] and [44]).
Other Ablations and Analyses
- Fig. 1: compared with Vanilla VP, U-AVP's standard accuracy drops by more than 50% (0-step PGD), while robust accuracy improves by only about 18%.
- Fig. 3: visualizes one image from each CIFAR-10 class and its corresponding C-AVP prompt.
- Fig. 2: a schematic comparison of C-AVP with U-AVP and with a pipeline without prompts (two-class example).
What are some points that can be further explored?
The authors acknowledge a performance gap with test-time defense baselines; experiments cover only CIFAR-10/ResNet18 and PGD attacks.
Limitations and Future Directions Noted by the Authors
- The authors acknowledge a performance gap between C-AVP and test-time defense baselines, and hope this paper paves the way for studying the pros and cons of visual prompts in adversarial robustness (Section 5, "Comparisons with other test-time defenses").
- The paper has no dedicated Limitations or Future Work section, and apart from the previous point does not explicitly raise other limitations or future directions.
Experimental Coverage
- The model tested is one pretrained ResNet18 on CIFAR-10, i.e., 1 model and 1 dataset (Section 5).
- Attack evaluation includes only PGD (ε=8/255, 10/20/50/100 steps); the paper does not report other attacks such as AutoAttack or adaptive attack evaluations.
- The test-time defenses compared are three methods [43], [15], [44] selected from the Croce et al. [14] benchmark (Table 3).
- The paper does not report repetitions, variance, or statistical significance tests.
- The paper does not state the attacker's knowledge of the defense (white-box/black-box settings are not specified).
Summarize the main content of the paper
C-AVP hardens a fixed model at test time using class-wise, jointly optimized visual prompts, trading a drop in standard accuracy for robustness and low inference overhead.
A test-time adversarial defense paper that investigates whether visual prompts (VP) can harden a fixed pretrained model.
- Problem: Adversarial training is computationally expensive and hard to apply to already-fixed models; existing test-time defenses increase inference time; the authors state that VP had previously been used only to improve generalization, and whether it can be used for adversarial defense has not been explored.
- Method: Proposes C-AVP—learn one visual prompt per class, and use three joint regularization terms to respectively internalize the prompt selection rule, suppress the backdoor effect of mismatched prompts, and widen the confidence gap between matched and mismatched prompts; prompts are trained offline and directly added to the input at test time.
- Result 1: On CIFAR-10/ResNet18, C-AVP achieves 57.57% standard accuracy and 34.75% PGD-10 robust accuracy, outperforming U-AVP's 27.75%/16.9% and C-AVP-v0's 19.69%/13.91% (Table 1).
- Result 2: The unhardened pretrained model and Vanilla VP have 0 robust accuracy under PGD (Table 1).
- Result 3: Compared with three test-time defense baselines, C-AVP has 1.4× inference overhead (baselines 59×–518×), but its 34.8% robust accuracy is lower than [44]'s 50.6% and [15]'s 40.3% (Table 3).
- Ablation: The authors state that
C−AVP,2(suppressing the backdoor effect) contributes the most, followed byC−AVP,1(Table 2). - Authors' conclusion: The authors state that this is the first work to study VP for adversarial defense; C-AVP trades robustness for lower inference overhead than classical test-time defenses, but there is a performance gap with the baselines.
Related papers
Show 3 more papers
- Self-Progressing Robust TrainingDefensesarXiv