DSRM: Boost Textual Adversarial Training with Distribution Shift Risk Minimization

Songyang Gao, Shihan Dou, Yan Liu, Xiao Wang, Qi Zhang, Zhongyu Wei, Jin Ma, Ying Shan

Introduction

Deep learning models for Natural Language Processing (NLP), particularly Transformer-based architectures like BERT, have demonstrated remarkable performance across various tasks. However, these models remain notoriously fragile when faced with adversarial attacks—small, often imperceptible perturbations to input text that can trigger incorrect predictions. Adversarial Training (AT) has emerged as the primary defense mechanism, involving the generation of adversarial samples during the training phase. Despite its effectiveness, standard AT suffers from significant computational overhead and often produces ungrammatical "garbage" samples that degrade the model's understanding of natural language.

Distribution Shift Risk Minimization (DSRM)

The proposed Distribution Shift Risk Minimization (DSRM) framework re-imagines adversarial robustness by shifting the focus from individual sample perturbations to the overall data distribution. Rather than solving the computationally expensive "inner maximization" problem to find specific perturbations $\delta$ for every input $x$, DSRM treats adversarial attacks as a form of distribution shift.

Conceptual comparison between standard Adversarial Training (AT) and the proposed Distribution Shift approach.

Mathematically, DSRM leverages the insight that the distance (specifically the Wasserstein distance) between the clean data distribution and the adversarial distribution is bounded by the attack intensity $\epsilon$. The core algorithm employs a distributional perturbation strategy, searching for a "worst-case" distribution that re-weights training samples to emphasize vulnerable examples. To maintain efficiency, the framework utilizes a first-order Taylor expansion to approximate the inner maximization and solves it via its dual problem within a meta-learning loop. This allows the model to achieve robustness using only clean text, without ever generating explicit adversarial samples.

Experimental Evaluation

The authors evaluated DSRM across four standard NLP classification benchmarks: SST-2 (sentiment), IMDB (large-scale sentiment), AG NEWS (topic classification), and QNLI (natural language inference). Using BERT-base as the backbone, the model's robustness was tested against three prominent attack methods: TextFooler, BERT-Attack, and TextBugger.

Results and Discussion

DSRM demonstrates a significant leap in both robustness and training efficiency compared to existing state-of-the-art methods.

Accuracy Under Attack (AuA) performance across different perturbation thresholds and gradient ascent steps.

Superior Robustness

On the IMDB dataset, DSRM achieved an Accuracy under Attack (AuA) of 56.3% against TextFooler. This significantly outperforms standard Projected Gradient Descent (PGD) training (26.0%) and the previous state-of-the-art, FreeLB++ (45.3%). Notably, DSRM maintains high "clean" accuracy, avoiding the significant performance degradation often seen in other AT methods.

Computational Efficiency

By eliminating the need for multi-step gradient calculations to generate adversarial samples, DSRM achieves a massive speedup. It is approximately twice as fast as vanilla PGD and reduces training time by roughly 70% compared to FreeLB++. This efficiency makes adversarial robustness more accessible for large-scale NLP applications.

Conclusion

DSRM provides a novel and efficient path toward robust NLP models. By reframing adversarial defense as a distribution shift problem, it bypasses the quality and cost issues associated with sample generation. While a minor "robustness tax" exists on simpler datasets, the substantial gains in speed and defense against sophisticated attacks like TextFooler position DSRM as a powerful tool for modern NLP pipelines.

Summary updated

BibTeX
@inproceedings{gao2023dsrm,
  author = {Songyang Gao and Shihan Dou and Yan Liu and Xiao Wang and Qi Zhang and Zhongyu Wei and Jin Ma and Ying Shan},
  title = {{DSRM: Boost Textual Adversarial Training with Distribution Shift Risk Minimization}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.680},
}
Figure