Transferable Adversarial Attacks on Vision Transformers with Token Gradient Regularization

Jianping Zhang, Yizhan Huang, Weibin Wu, Michael R. Lyu

Introduction

Adversarial attacks involve adding human-imperceptible perturbations to images to deceive machine learning models. A significant challenge in this field is transferability: generating an attack on a known "source" model that remains effective against an unknown "black-box" target model. While Vision Transformers (ViTs) have become a dominant architecture, attacks generated on them often overfit to the source model's specific features, failing to transfer effectively to other architectures.

Researchers have introduced Token Gradient Regularization (TGR) to address this bottleneck. By identifying and "muting" extreme gradients within the internal tokens of a ViT during attack generation, TGR achieves an average performance boost of 8.8% over previous state-of-the-art methods.

The Challenge: Gradient Volatility

The authors discovered that gradients in ViTs are highly volatile in intermediate layers, particularly in shallower blocks. This high variance causes attack generation to get trapped in "poor local optima," focusing on model-specific noise rather than universal features. This overfitting is the primary reason for low transfer success rates across different model architectures.

Methodology: Token Gradient Regularization (TGR)

The core innovation of TGR is its internal regularization approach. Unlike methods that only smooth gradients at the input level, TGR operates within the transformer blocks during back-propagation.

Figure 1: The TGR framework applied within a Transformer block, showing the elimination of extreme gradients in the QKV, Attention, and MLP components.
  1. Token-wise Regularization: ViTs process images as sequences of patches (tokens). TGR analyzes the back-propagated gradients for each token within the QKV (Query, Key, Value), Attention, and MLP components.
  2. Extreme Token Elimination: The algorithm identifies "extreme tokens"—those with the highest or lowest gradient magnitudes—and zeros them out. These outliers are treated as model-specific noise that hinders transferability.
  3. Scaling and Integration: A scaling factor is applied to the remaining gradients to stabilize updates. TGR is "plug-and-play" and can be combined with other techniques like PatchOut to further enhance performance.

Experimental Results

The study evaluated TGR using the ImageNet validation set across various source models (ViT-B/16, PiT-B, CaiT-S/24, and Visformer-S) and a wide array of target architectures, including both ViTs and CNNs.

Figure 2: Comparison of attack success rates (%) against various ViT target models. TGR consistently outperforms existing methods like MIM, VMI, SGM, and PNA.

Key Findings

  • Superior Transferability: TGR outperformed the previous state-of-the-art (PNA) by an average of 8.8% across ViT targets.
  • Cross-Architecture Success: Attacks generated on ViTs using TGR were significantly more effective at fooling CNNs, improving success rates by 6.2% on average. This suggests TGR uncovers fundamental perceptual weaknesses common across architectures.
  • Breaking Defenses: TGR showed substantial gains against models hardened with adversarial training (e.g., Inc-v3_ens3), sometimes doubling the success rates of baseline methods.
  • Component Importance: Ablation studies revealed that regularizing the Attention component provides the most significant boost, indicating that the self-attention mechanism is a primary source of model-specific vulnerability.

Discussion and Future Work

While TGR is highly effective, it introduces a hyperparameter $k$ (the number of extreme tokens to eliminate). Although $k=1$ generally performs best, optimal results may require architecture-specific tuning. Additionally, while the current focus is on image classification, the authors suggest that extending TGR to tasks like object detection and semantic segmentation is a promising future direction. The computational overhead of ranking gradients in every internal block is a minor trade-off for the significant gains in attack transferability.

Summary updated

BibTeX
@inproceedings{zhang2023transferable,
  author = {Jianping Zhang and Yizhan Huang and Weibin Wu and Michael R. Lyu},
  title = {{Transferable Adversarial Attacks on Vision Transformers with Token Gradient Regularization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure