Abstract
Deep learning models for Natural Language Processing (NLP) are highly susceptible to adversarial attacks, where subtle word substitutions can drastically alter model predictions. While Adversarial Data Augmentation (ADA) is a common defense, it often suffers from distribution distortion, high computational overhead, and overfitting to dataset biases. We introduce WETAR (Weighting Examples Towards Adversarial Robustness), a novel defense mechanism that leverages meta-learning to reweight clean training examples. By optimizing weights against a small, robust validation set, WETAR achieves state-of-the-art defense performance without the need for extensive adversarial training on the full dataset.
Introduction
The fragility of NLP models is well-documented; for instance, the "TextFooler" attack can flip a sentiment prediction by replacing "brilliant" with "intelligent." Existing defenses like ADA attempt to mitigate this by incorporating synthetic adversarial examples into the training set. However, this often leads to a trade-off where accuracy on clean (non-adversarial) text decreases. Furthermore, generating adversarial examples for massive datasets is computationally expensive. WETAR addresses these challenges by asking: can we achieve robustness simply by adjusting the importance of existing clean examples during training?
Methodology
WETAR utilizes a bilevel optimization approach to learn the optimal weights for training data. The process involves a "Robust Guide"—a small validation set (approximately 10% of the training data) containing both clean and adversarial examples.
Bilevel Optimization
During training, the model evaluates a batch of clean data and determines how increasing the weight of specific examples impacts performance on the robust validation set. Using gradient-based meta-learning, the system calculates weights that minimize loss on the validation set, effectively teaching the model to prioritize examples that contribute most to robustness.
Static vs. Dynamic Variants
Two versions of the algorithm were evaluated:
- WETAR-S (Static): Uses a fixed validation set generated before training.
- WETAR-D (Dynamic): Generates new adversarial examples for the validation set on the fly, forcing the model to adapt to an evolving attacker.
Experimental Evaluation
The effectiveness of WETAR was tested on three standard benchmarks: SST-2 (Stanford Sentiment Treebank), AGNEWS, and MR (Movie Reviews). These datasets cover binary sentiment analysis and multi-class topic classification.
Results and Analysis
WETAR consistently outperformed baseline defenses, including FreeLB and ADA. As illustrated in the performance comparison below, both WETAR-S and WETAR-D provide substantial gains in accuracy under attack across all tested datasets. Notably, the combination of WETAR with ADA (WETAR+ADA) further enhances performance, suggesting that reweighting clean data and augmenting with adversarial data provide complementary benefits.
Robustness and Clean Accuracy
A key advantage of WETAR is its ability to preserve, or even slightly improve, clean accuracy. Unlike traditional defenses that often trade off performance on normal text for robustness, WETAR maintains high clean accuracy. For example, on the SST-2 dataset, WETAR-D achieved a clean accuracy of 93.4%, compared to the undefended base model's 93.2%.
Sensitivity analysis demonstrates that while clean accuracy remains remarkably stable across different ratios of adversarial samples in the validation set, the accuracy under attack is optimized when the validation set contains a balanced mix of clean and adversarial examples (typically around 20%).
Efficiency and Transferability
WETAR is approximately three times slower than standard training due to the meta-learning step but remains significantly more efficient than full-scale ADA. Furthermore, models trained with WETAR demonstrate strong transferability; robustness gained against one attack type (e.g., TextFooler) persists when facing different algorithms like BERT-Attack or TextBugger.
Conclusion and Future Work
WETAR demonstrates that adversarial robustness can be achieved through strategic reweighting of clean data, avoiding the pitfalls of distribution distortion associated with synthetic data augmentation. Future research will explore the sensitivity of WETAR to validation set diversity and its potential integration with certified defense mechanisms to provide formal robustness guarantees.
Summary updated