Generating Natural Language Adversarial Examples through Probability Weighted Word Saliency

Shuhuai Ren, Yihe Deng, Kun He, Wanxiang Che

Introduction

Deep Neural Networks (DNNs) have demonstrated remarkable performance in various domains but remain notoriously fragile to adversarial examples—inputs specifically crafted to deceive models. While this phenomenon is well-documented in computer vision, generating adversarial text is significantly more challenging due to the discrete nature of language. Unlike images, where pixels can be adjusted by infinitesimal amounts, text requires swapping entire words. Such modifications often result in "adversarial" text that is ungrammatical or semantically incoherent. This paper introduces Probability Weighted Word Saliency (PWWS), a black-box attack method designed to generate effective yet stealthy adversarial examples by intelligently substituting a small fraction of words.

Methodology

PWWS is a greedy algorithm for word substitution that operates without access to a model's internal gradients, requiring only the output probabilities. The core innovation lies in a scoring function that prioritizes word replacements based on two factors:

  1. Word Substitution Strategy: For each word, the algorithm identifies synonyms using WordNet. For Named Entities, it swaps them with common entities of the same type. It calculates the potential impact ($\Delta P$)—the largest drop in the model's confidence for the correct label—offered by any single synonym.
  2. Word Saliency: This measures the "importance" of a word by replacing it with an "unknown" token and observing the resulting drop in classification probability.
  3. The PWWS Score: The final score is the product of Word Saliency and the Probability Change ($\Delta P$).

By weighting the potential attack effect by the word's original importance, PWWS prioritizes the most influential words, allowing it to flip predictions with minimal changes.

Table 1: Examples of original vs. adversarial text generated by PWWS. Note how small changes like "funny" to "laughable" can flip model sentiment.

Experimental Setup

The authors evaluated PWWS on three benchmark datasets:

  • IMDB: Binary sentiment analysis of movie reviews.
  • AG’s News: Four-class news categorization.
  • Yahoo! Answers: Ten-topic classification.

The attack was tested against several architectures, including word-based CNNs, character-based CNNs, and LSTMs.

Key Results and Discussion

PWWS consistently outperformed existing attack methods across all datasets and models. As shown in the results table below, the attack significantly reduces model accuracy while maintaining a very low word substitution rate.

Table 2: Performance of various models under different attack methods. PWWS consistently achieves the lowest accuracy across all benchmarks.

Efficiency and Stealth

On the IMDB dataset, PWWS reduced a word-based CNN's accuracy from 86.55% to just 5.50%. For the Bi-LSTM model, it required changing only 3.38% of the words to successfully break the model. This high efficiency ensures that adversarial examples remain nearly imperceptible to human readers. In human evaluation studies, participants found it difficult to distinguish between original and adversarial texts, often rating them as highly similar in meaning.

Transferability and Defense

Adversarial examples generated for one model (e.g., a CNN) frequently fooled others (e.g., an LSTM), indicating shared underlying vulnerabilities. Furthermore, the authors demonstrated that "adversarial training"—incorporating these perturbed examples into the training set—significantly enhances model robustness against future attacks.

Conclusion

While PWWS is highly effective, it faces challenges in multi-class settings where the search space for label flipping is larger. Additionally, while WordNet provides synonyms, some substitutions may subtly shift the tone or meaning. Future research should focus on improving search efficiency and ensuring even greater semantic consistency. Despite these limitations, PWWS represents a significant step forward in understanding and exposing the vulnerabilities of modern NLP models.

Summary updated

BibTeX
@inproceedings{ren2019generating,
  author = {Shuhuai Ren and Yihe Deng and Kun He and Wanxiang Che},
  title = {{Generating Natural Language Adversarial Examples through Probability Weighted Word Saliency}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/p19-1103},
}
Figure