Abstract
Adversarial attacks in Natural Language Processing (NLP) frequently rely on word-level perturbations that result in ungrammatical or semantically nonsensical text. While effective at reducing model accuracy, these "artificial" adversaries do not reflect real-world human language. We present NaturalAdversaries, a framework that utilizes generative models to produce adversarial examples that are both effective and naturalistic. Our findings indicate that while naturalistic attacks may be less potent against specific target models, they exhibit superior transferability and significantly enhance model robustness when used for fine-tuning.
Introduction
Modern NLP models, particularly those based on the Transformer architecture, are notoriously brittle. They often rely on "shortcuts"—statistical artifacts or specific keywords—rather than a deep semantic understanding of the input. Adversarial attacks are designed to expose these vulnerabilities. However, traditional methods like TextFooler or HotFlip often produce text that feels like a "glitch in the matrix," lacking the grammatical and semantic coherence of human writing. This "naturalness gap" limits the utility of such attacks for identifying real-world social biases or logical failures. NaturalAdversaries addresses this by generating attacks that are indistinguishable from human-written text.
Methodology
The NaturalAdversaries framework operates in a two-stage process to bridge the gap between effectiveness and naturalness:
- The Probing Stage: The system identifies influential tokens that a classifier uses to make its prediction. This can be done in a white-box setting using Integrated Gradients (NA-IG) or a black-box setting using LIME (NA-LIME).
- The Generative Stage: A generative model (GPT-2) is conditioned on these influential tokens and a target "flipped" label. The goal is to produce a new, natural-sounding sentence that retains the key concepts but changes the classification outcome.
Datasets and Evaluation
The framework was evaluated on two primary tasks: Hate Speech Detection (using the DynaHate dataset) and Natural Language Inference (using the ANLI dataset). To measure real-world utility, models were tested on out-of-distribution benchmarks including HateCheck and SNLI-Hard.
Results and Key Insights
Naturalness and Human Perception
Human evaluators found NaturalAdversaries to be significantly more natural than baseline artificial attacks. On the ANLI dataset, the NA-IG method achieved a naturalness score of 89%, a substantial improvement over the 57% achieved by the TextFooler (TF) baseline.
Transferability and Robustness
While artificial attacks are often more effective at breaking the specific model they were designed for, they tend to "overfit" to that model's specific quirks. NaturalAdversaries, by following natural language patterns, demonstrate better transferability to unseen models.
More importantly, fine-tuning models on these naturalistic examples provides a superior robustness boost. For instance, fine-tuning a RoBERTa model on just 150 NaturalAdversaries improved its F1 score on the HateCheck suite by 1.68 points, outperforming traditional attack methods which often fail to improve out-of-distribution performance.
Discussion and Limitations
Despite its success, the NaturalAdversaries framework faces several challenges. The method still relies heavily on lexical attribution; it may miss model failures rooted in complex sentence structure or composition. Furthermore, the quality of generated adversaries is sensitive to decoding strategies, and the computational cost of training a generative attacker is higher than simple word-swapping algorithms. Future research will focus on more sophisticated explainability methods to capture structural vulnerabilities beyond individual keywords.
Summary updated