Abstract
Vision transformers rely on a patch token based self attention mechanism, in contrast to convolutional networks. We investigate fundamental differences between these two families of models, by designing a block sparsity based adversarial token attack. We probe and analyze transformer as well as convolutional models with token attacks of varying patch sizes. We infer that transformer models are more sensitive to token attacks than convolutional models, with ResNets outperforming Transformer models by up to $\sim30\%$ in robust accuracy for single token attacks.
Introduction
While Convolutional Neural Networks (CNNs) have long dominated computer vision, Vision Transformers (ViTs) have emerged as powerful alternatives due to their performance on large-scale datasets. However, the robustness of these architectures to adversarial perturbations remains a critical area of study. Traditional adversarial attacks often focus on pixel-level noise, such as $\ell_\infty$ or $\ell_2$ constraints. This research investigates a novel "token-level" attack that exploits the fundamental patch-based processing mechanism inherent to the Transformer architecture.
Methodology: Adversarial Token Attacks
The core contribution of this work is the Adversarial Token Attack, which utilizes block sparsity constraints to target specific image patches, or "tokens." Unlike standard sparse attacks that distribute noise across the entire image, this method concentrates the perturbation budget into contiguous blocks. The attack follows a three-step process:
- Saliency Mapping: The algorithm identifies the most influential patches by calculating the norm of loss gradients for all pixels within non-overlapping blocks.
- Patch Selection: The "Top-K" most salient patches are selected for perturbation.
- Optimization: Gradient ascent is performed on these specific $K$ patches to maximize model loss.
By constraining the attack to specific blocks, the researchers simulate a threat model that aligns with the internal logic of Vision Transformers.
Experimental Setup
The study evaluated several pre-trained models, including ViT variants, ResNets, and MLP-Mixers. Testing was performed on a subset of 300 images randomly selected from the ImageNet validation set. The models were sourced from the timm (PyTorch Image Models) repository.
Analysis of Architectural Vulnerabilities
The experiments revealed several key insights into the fundamental differences between CNNs and ViTs:
- Token Size Sensitivity: ViTs exhibit a degree of robustness to perturbations smaller than their internal token size (typically $16 \times 16$). However, when the attack patch size matches the architecture's token size, performance collapses.
- ResNet Resilience: Despite not being designed with tokens in mind, ResNets demonstrate superior robustness to block-style attacks. Their convolutional nature appears to provide a natural defense against concentrated local perturbations compared to the global attention mechanism of Transformers.
- The 1% Threshold: The researchers found they could effectively "break" Vision Transformers by perturbing as little as 1% of the total pixels, provided those pixels were concentrated within the most salient tokens.
Key Results
The performance gap between architectures under token-level pressure is significant:
- Robustness Gap: In single-token attacks ($K=1$), ResNets outperformed ViTs by approximately 30% in robust accuracy.
- ViT Fragility: For high-resolution models like ViT-384, robust accuracy plummeted to near 0% when only two $16 \times 16$ patches were targeted.
- Model Comparison: ResNet-101 emerged as the most robust model across the board, maintaining significantly higher accuracy than any Transformer or MLP-Mixer model tested.
Conclusion
This work highlights a specific vulnerability in Vision Transformers arising from their tokenized input processing. While ViTs may appear robust to scattered noise, they are significantly more susceptible to concentrated patch-based attacks than traditional CNNs. As the field moves toward Transformer-based vision systems, it is essential to move away from "one-size-fits-all" robustness metrics and develop defenses that account for the underlying geometry of the architecture.
Summary updated