Abstract: Deep neural networks (DNNs) are vulnerable to adversarial examples, perturbations to correctly classified examples which can cause the model to misclassify. In the image domain, these perturbations are often virtually indistinguishable to human perception, causing humans and state-of-the-art models to disagree. However, in the natural language domain, small perturbations are clearly perceptible, and the replacement of a single word can drastically alter the semantics of the document. Given these challenges, we use a black-box population-based optimization algorithm to generate semantically and syntactically similar adversarial examples that fool well-trained sentiment analysis and textual entailment models with success rates of 97% and 70%, respectively. We additionally demonstrate that 92.3% of the successful sentiment analysis adversarial examples are classified to their original label by 20 human annotators, and that the examples are perceptibly quite similar. Finally, we discuss an attempt to use adversarial training as a defense, but fail to yield improvement, demonstrating the strength and diversity of our adversarial examples. We hope our findings encourage researchers to pursue improving the robustness of DNNs in the natural language domain.
Introduction
Adversarial examples have long been a subject of study in computer vision, where subtle pixel-level changes can lead a model to misclassify an image while remaining invisible to the human eye. Translating this concept to Natural Language Processing (NLP) presents unique challenges. Unlike the continuous space of image pixels, language is discrete; one cannot "slightly" modify a word without potentially changing the entire meaning or grammatical structure of a sentence. Furthermore, humans are highly sensitive to linguistic errors, making it difficult to craft perturbations that fool a machine without also confusing a human reader.
This paper introduces a black-box population-based optimization algorithm designed to generate adversarial text that is both semantically and syntactically similar to the original input. By focusing on word-level replacements that preserve context and meaning, the authors demonstrate the inherent fragility of state-of-the-art NLP models.
Methodology
The proposed attack utilizes a Genetic Algorithm (GA) to evolve a population of adversarial sentences. Because it is a black-box attack, it requires no access to the model's internal gradients, relying solely on the output confidence scores.
The Perturb Subroutine
The core of the optimization is the Perturb Subroutine, which ensures that modifications remain natural and semantically consistent:
- Word Selection: The algorithm identifies words to replace based on their influence on the model's prediction.
- Synonym Generation via Counter-fitting: To find suitable replacements, the authors use counter-fitted word embeddings. Unlike standard embeddings that cluster words by general relatedness (e.g., "good" and "bad"), counter-fitting ensures that true synonyms are close together while antonyms are pushed apart.
- Contextual Filtering: To maintain grammatical correctness, a large-scale Language Model (trained on Google’s 1 Billion Words dataset) filters out replacements that result in unnatural phrasing.
Experimental Results
The attack was evaluated against models trained on the IMDB (sentiment analysis) and SNLI (textual entailment) datasets. The results highlight a significant gap between model performance and model robustness.
As shown in the table above, the genetic attack achieved a staggering 97% success rate against the sentiment analysis model, requiring changes to only 14.7% of the text. While the success rate on the SNLI dataset was lower (70%), it remains substantial given the shorter average length of sentences in that dataset, which provides fewer opportunities for perturbation.
Qualitative Impact
The power of the attack lies in its subtlety. In many cases, replacing a single word is sufficient to flip a model's prediction entirely, even when the semantic meaning remains unchanged for a human observer.
In the example above, the model correctly identifies the relationship between the premise and the original hypothesis as "Entailment." However, by simply swapping the word "runner" for "racer," the model's prediction flips to "Contradiction," despite the two sentences being functionally identical in this context.
Human Validation and Defense
To ensure the adversarial examples were truly "adversarial" (fooling the machine but not the human), the authors conducted a study with 20 human annotators. They found that 92.3% of the successful sentiment analysis adversarial examples were still correctly classified by humans according to their original label.
Finally, the researchers attempted to use adversarial training—incorporating these generated examples into the training set—to improve model robustness. Surprisingly, this defense failed to yield significant improvements. This suggests that current DNN architectures in NLP may be fundamentally limited in their ability to learn the underlying semantics of language, instead relying on brittle statistical patterns that are easily exploited.
Summary updated