Vision models that look robust on paper still fail on changes a person would call trivial. Examples include an object on an unusual background, a strange texture or material, or a small rotation. Pretrained backbones like CLIP and DINOv2 are no exception. Standard defenses do not transfer to these changes, and the ones that do are expensive. Adversarial training, which retrains the model on worst-case inputs, hardens a model against small pixel noise but not against these semantic changes. Methods that do train against semantic changes retrain the whole network inside an expensive attack loop. One such method needed three days on 64 GPUs for ImageNet. Retraining the backbone also costs clean accuracy.
We propose to keep the backbone frozen and train only a handful of extra input tokens. These are learnable vectors appended to the image patches of a Vision Transformer. The tokens are trained against a cached bank of diffusion-generated semantic edits of each training image. At every step, the model scores several cached edits of the same image and trains on the one it currently handles worst. This keeps the "find the hardest example" behavior of adversarial training. Because it never backpropagates through the image generator, the per-step cost is a few forward passes. The scientific question is whether a frozen backbone lets us escape the robustness-accuracy trade-off for semantic shifts, as it apparently does for pixel noise. If the escape fails, we want to know which classes pay for it.
Core Claim
Robustness Tokens tunes 10 appended tokens on a frozen ViT in about 200 steps. On DINOv2-Giant it restores white-box accuracy from 0.3% to 63.1% while clean accuracy moves only from 85.6% to 85.2%. That result was obtained only for additive pixel noise.
The theory of the trade-off predicts that semantic shifts are harder. Robustness May Be at Odds with Accuracy argues that robustness costs accuracy because it forces the model to drop features that are predictive on clean data. Pixel-noise features are expendable. The background and texture cues that ImageNet-D manipulates are the same cues that clean ImageNet accuracy partly relies on.
Our claim has two parts. First, input tokens trained on a frozen backbone with worst-of-K selection from a cached semantic edit bank should recover a large share of the ImageNet-D and composite-transformation gap at a tiny fraction of the cost of GAT. The comparison point is Towards Compositional Adversarial Robustness. Second, any clean-accuracy cost will not be uniform. It should concentrate on classes whose clean accuracy depends on context. This is measurable through a semantic version of the error decomposition in TRADES. If the cost is near zero everywhere, the frozen-backbone escape extends to semantic threats. If it concentrates as predicted, we have a per-class account of where the trade-off is unavoidable.
Research Program
Edit bank. For each training image $x$, we precompute a small set $S(x)$ of label-preserving semantic edits. These are prompt-driven substitutions of background, texture, and material produced with Stable Diffusion, in the spirit of LANCE. We add cheap differentiable parametric edits: rotation, hue, saturation, brightness, and contrast, as in GAT.
Bank edits are not optimized against any model, so a single bank serves every backbone and every tuning run. Its one-time cost is reported and included in all compute comparisons. Nuisance vocabularies are split by category. Every Broden texture, material, and background family that ImageNet-D uses is held out from the bank. Without this split, evaluating on ImageNet-D would amount to testing on the training distribution.
Diffusion edits can overshoot and destroy the object. SD-NAE reports this in 6–8% of runs. We therefore filter edits by agreement between two frozen zero-shot models that are not the ones being defended. A small sample of the filtered edits is checked by humans.
Training objective. Let $f_t$ be the frozen backbone with the linear head and the appended tokens $t$. Let $h_t$ be its pooled feature, and let $h_0$ be the feature without tokens. Let $S_K(x)$ be $K$ edits sampled from the bank, plus one online parametric edit. The tokens and head minimize
$$\mathbb{E}_{(x,y)}\Big[\mathcal{L}(f_t(x),y) + \lambda \max_{x'\in S_K(x)} \mathrm{KL}\big(f_t(x)\,\|\,f_t(x')\big) + \mu\,\|h_t(x)-h_0(x)\|^2\Big],$$
where $\mathcal{L}$ is cross-entropy.
The second term is the TRADES consistency term. The ball of small pixel perturbations is replaced by the cached semantic neighborhood, and the max is computed by scoring the $K$ candidates. The third term is the clean-feature anchor from Robustness Tokens. The weights $\lambda$ and $\mu$ trace out the trade-off curve.
Diagnostic decomposition. Following TRADES, we split semantic robust error into two parts. Natural error is the error on clean images. Semantic boundary error is the fraction of correctly classified clean images that some held-out edit flips. We report both per class. This tests the second claim: we check whether the clean-accuracy change correlates with each class's reliance on context. Reliance is measured by the undefended model's accuracy drop when the background alone is swapped.
Threat model. Token values are treated as known to the attacker, since the Robustness Tokens paper itself flags secrecy as a weakness. Every attack is rerun white-box against the defended model.
Baselines
The do-nothing reference is the frozen backbone with a linear probe, trained on clean ImageNet with the same data and step budget. Understanding Robustness of Parameter-Efficient Tuning found linear probing more robust than VPT, LoRA, and adapters under attack. It is therefore a stronger floor than it looks. Any gain must be measured against it, not against a weaker tuned model.
The pixel-trained Robustness Tokens baseline uses the published recipe on the same backbones, then evaluates on semantic benchmarks. Its reported numbers are 85.2% clean and 63.1% white-box accuracy on DINOv2-Giant. It shows whether pixel-level token robustness already transfers. Beating it means higher ImageNet-D and composite-attack accuracy at equal or better clean accuracy.
The strongest existing semantic defense is GAT, run from its published ImageNet setting. On ImageNet it reports about 11.8% accuracy under full composite attacks, against 2.8% for an ℓ∞-robust model and 0% for an undefended one. That run cost 3 days on 64 V100s. Because GAT retrains a ResNet, we compare in two regimes. In the first, the composite-attack accuracy of our method and GAT is compared at their native costs, with GPU-hours reported. In the second, the backbone is fixed and the tokens are trained against GAT's own composite attacks, which isolates what the bank adds.
For out-of-distribution robustness, the comparison is DAD. It distills from CLIP using offline adversarial augmentations at twice the training budget. It reports 65.1% on ImageNet-Rendition and 46.1% on ImageNet-Sketch with a ViT-B student. We compare on a matched ViT-B/16 backbone.
As a zero-training reference, we run the test-time defenses ATAC and ERICT on CLIP. Their extra inference cost is reported.
The key ablation keeps everything identical but replaces the worst-of-K max with a uniformly random draw from the same bank. This is plain semantic augmentation of the tokens. A second ablation runs worst-of-K through LoRA instead of tokens, which tests whether the input-token location matters. All tuned variants share the same bank, step count, and hyperparameter search budget of eight configurations each. They are selected on a held-out validation split of edits from nuisance families that appear in neither the training bank nor the evaluation sets.
Why not just…?
Why not just linear-probe a strong frozen foundation model? Linear probing is cheap and costs nothing on clean data, but it inherits the backbone's semantic blind spots. ImageNet-D reports that CLIP ViT-L/14 loses about 46% accuracy on its images, and that ViT-L/16 falls from 68.6% to 9.2%. A probe cannot change the features that fail. Our do-nothing baseline measures exactly how much of this gap the tokens close.
Why not just train the tokens on random semantic augmentations? This is the real threat. If the random-draw ablation matches worst-of-K, then the adversarial part of the proposal is unnecessary, and the contribution reduces to "diverse diffusion augmentation for tokens." Two findings argue that selection matters. GAT found worst-case ordering of transformations much stronger than random sequences, and AGAT beat augmentation baselines on MNIST-RTS (52.95% vs. about 29%). However, both results come from full retraining, not frozen backbones. The ablation settles this directly. It is scored mainly on white-box, SD-NAE-style attacks against the defended model, where worst-case training should matter most. If random draws match there too, we will report that as the finding.
Why not just fine-tune the full backbone with ℓ∞ adversarial training or GAT? ℓ∞ training does not buy semantic robustness: GAT reports that an ℓ∞-robust ImageNet model reaches only 2.8% under composite semantic attacks. On the effectiveness of adversarial training against common corruptions shows it misses global changes such as contrast and lighting. GAT closes part of this gap, but at a cost DAD places at about 11× standard training for ordinary adversarial training, far more for GAT on ImageNet. Full retraining also reintroduces the clean-accuracy penalty that TRADES formalizes. Our comparison reports both accuracy and GPU-hours, so a reader can see whether full retraining wins by enough to justify its cost.
Why not just defend at test time with ATAC or ERICT? Neither method needs training, and ERICT raises CLIP ViT-B/32 worst-group accuracy on Waterbirds from 39.33% to 71.44%. But ERICT targets fixed spurious backgrounds, not an optimizing attacker. ATAC's authors note that it struggles when augmentations alter semantic properties such as color. Both also add cost to every query. Our experiments test them on the same adaptive semantic attacks. If they match our method, the case for training rests only on inference cost.
Proposed Experiments
We use DINOv2 (up to Giant, matching the Robustness Tokens paper) and CLIP ViT-L/14. Evaluation covers five settings: clean ImageNet; ImageNet-D with its 4,835 images across 113 categories, where ViT-L/16 scores 9.2% and ResNet-101 scores 12.6%; GAT's composite semantic attacks on ImageNet; ImageNet-Rendition and ImageNet-Sketch, compared against DAD; and adaptive SD-NAE token-embedding attacks. The SD-NAE attacks are generated against each defended model. Since the paper reports about 1 minute and 22GB of GPU memory per sample, we attack a fixed 1,000-image subset. We run the TRADES-style pixel attack on the defended models as well, to check that semantic training does not destroy pixel robustness.
Three results would be decisive. The first is whether tokens with worst-of-K selection beat both the linear probe and the pixel-trained tokens on ImageNet-D with held-out nuisance families, while staying within one point of clean accuracy. The second is whether worst-of-K beats random draws under adaptive SD-NAE attacks by a margin larger than the spread across three random seeds. The third is whether the per-class clean-accuracy change correlates negatively with the class's reliance on context, as the non-robust-features account predicts, or is flat, which would mean the frozen-backbone escape extends to semantic threats.
Total cost is reported as GPU-hours, including bank generation. It is set against the 3 days on 64 V100s that GAT needed. Failure on the first check, success only with random draws, or clean accuracy collapsing on context-heavy classes are each informative outcomes, and each will be reported as such.
References
- Robustness Tokens: Towards Adversarial Robustness of Transformers
- Robustness May Be at Odds with Accuracy
- ImageNet-D: Benchmarking Neural Network Robustness on Diffusion Synthetic Object
- Towards Compositional Adversarial Robustness: Generalizing Adversarial Training to Composite Semantic Perturbations
- Theoretically Principled Trade-off between Robustness and Accuracy
- LANCE: Stress-testing Visual Models by Generating Language-guided Counterfactual Images
- SD-NAE: Generating Natural Adversarial Examples with Stable Diffusion
- Understanding Robustness of Parameter-Efficient Tuning for Image Classification
- Distilling Out-of-Distribution Robustness from Vision-Language Foundation Models
- ATAC: Augmentation-Based Test-Time Adversarial Correction for CLIP
- ERICT: Enhancing Robustness by Identifying Concept Tokens in Zero-Shot Vision Language Models
- Attribute-Guided Adversarial Training for Robustness to Natural Perturbations
- On the effectiveness of adversarial training against common corruptions