Introduction
The rapid adoption of Pre-trained Language Models (PrLMs) like BERT and RoBERTa has been accompanied by growing concerns regarding their security. Recent literature suggests these models are highly susceptible to adversarial attacks—minor, often character- or word-level perturbations that can cause a model to output incorrect predictions with high confidence. With reported attack success rates (ASR) frequently exceeding 90%, the prevailing narrative has been that PrLMs are fundamentally fragile.
However, researchers from Shanghai Jiao Tong University challenge this assumption. They argue that many "successful" adversarial samples are essentially "non-natural"—containing typos, grammatical errors, and nonsensical phrasing that a human would immediately identify as anomalous. By failing to account for the "naturalness" of an input, current evaluation metrics may be overstating the vulnerability of PrLMs. This paper introduces a framework to distinguish between natural and non-natural samples, providing a more realistic assessment of model robustness and a novel defense mechanism.
The Naturalness Constraint
The core of the authors' argument is that adversarial machine learning should ideally produce "imperceptible" changes. In NLP, this translates to maintaining the linguistic naturalness of the text. If an attack produces a "linguistic train wreck," it violates the premise of a stealthy adversarial example.
To address this, the researchers developed a PrLM-based Anomaly Detector. This BERT-based binary classifier is trained to distinguish between natural text and artificial/adversarial text. The training occurs in two stages:
- Synthetic Noise Training: The detector is first exposed to simple synthetic noise.
- Adversarial Fine-tuning: The detector is fine-tuned on actual adversarial samples generated by popular attack algorithms like TextFooler and DeepWordBug.
By introducing an Anomaly Score (the probability output by this detector), the authors can enforce a "naturalness constraint." When existing attacks are re-evaluated with the requirement that they must maintain an Anomaly Score below 0.5, their effectiveness is significantly diminished.
A Framework for Defense and Purification
Beyond evaluation, the anomaly detector serves as the foundation for a robust defense framework. When a model receives an input, the system follows a multi-step process:
- Detection: The anomaly detector calculates the naturalness of the input.
- Conditional Processing: If the text is deemed "natural," it is processed normally.
- Purification: If the text is flagged as an anomaly, the system applies $k$ random transformations to "purify" the input. These transformations include back-translation, synonym swaps, or using a language model to fill in masked words. The final prediction is based on these purified versions.
This approach allows the model to defend against adversarial noise while preserving its performance on legitimate, clean data.
Experimental Results
The researchers evaluated their framework across four major benchmarks: SST2, MR, IMDB, and MNLI. The results suggest that the perceived fragility of PrLMs is, in many ways, a "myth" created by non-natural samples.
Impact on Attack Success Rates
When the naturalness constraint was applied, the success of popular attacks plummeted. For example, on the MR (Movie Review) dataset:
- DeepWordBug: Success rate dropped from 82.2% to 8.5%.
- TextFooler: Success rate dropped from 80.5% to 35.2%.
These findings indicate that PrLMs have already captured a significant amount of robust semantic information; they are primarily "fooled" by samples that fall outside the distribution of natural language.
Defense Performance
The proposed defense framework outperformed existing state-of-the-art methods such as DISP and SAFER. On the IMDB dataset under a TextFooler attack, the system maintained an accuracy of 90.3%, whereas a model with no defense saw its accuracy collapse to 12.4%. Notably, the framework often improved accuracy on "clean" data (e.g., increasing MR accuracy from 86.4% to 87.0%), as the detector prevents unnecessary and potentially damaging transformations on natural text.
Beyond Defense: Data Augmentation
The utility of the anomaly detector extends to training. The authors demonstrated that the detector can be used for informed Data Augmentation. By selecting augmented samples that the detector identifies as "diverse" or borderline anomalous, researchers can train models that generalize better to the inherent noise of real-world data without sacrificing core performance.
Limitations and Future Work
While the paper provides a robust defense against black-box and grey-box attacks, the authors acknowledge several areas for future work:
- White-box Attacks: Attacks with full access to the model's gradients remain a significant challenge.
- Inference Overhead: The purification process requires multiple transformations and predictions, increasing the computational cost during inference.
- The Arms Race: As detection methods improve, attackers may develop more sophisticated techniques to bypass naturalness filters.
In conclusion, by shifting the focus from "can the model be broken?" to "can the model be broken by natural-looking text?", this research provides a more grounded perspective on NLP robustness. It suggests that PrLMs are more resilient than previously thought and offers a practical path forward for building models that can withstand real-world adversarial pressure.
Summary updated