A Geometry-Inspired Attack for Generating Natural Language Adversarial Examples

Zhao Meng, Roger Wattenhofer · DOI

TL;DR

This paper introduces a novel "geometry-inspired" attack to generate adversarial examples for natural language processing (NLP) models. By iteratively approximating the model's decision boundary, their method effectively fools models with minimal word changes, and human evaluations show these adversarial examples are hard to detect.

What Problem Does This Paper Address?

Deep Neural Networks (DNNs) have revolutionized NLP, but they are also susceptible to adversarial attacks. Unlike image adversarial attacks where small pixel changes can drastically alter predictions, generating adversarial examples in NLP is challenging due to the discrete nature of language (words and sentences) and variable input lengths. Existing methods often struggle with perceptibility (making the adversarial examples look unnatural) or don't fully leverage the underlying geometric properties of the DNN's decision boundary, which has proven effective in image domains. This paper aims to bridge this gap by proposing a geometry-guided attack that generates more natural and effective adversarial examples for NLP models.

Methods

The core of the proposed attack is a white-box method that iteratively approximates the DNN's decision boundary. It operates in two main steps:

  1. Word Selection: Words in the original text are ranked by their "saliency score." This score quantifies how much the true class probability decreases when a word is replaced by an out-of-vocabulary embedding (initialized to zeros). Words with higher saliency scores are considered more important for the model's prediction and are prioritized for replacement.
  2. Synonym Replacement Strategy: For the selected word, the attack finds its synonyms using WordNet. Then, it leverages geometric information from the DNN's internal representations. Specifically, it uses the DeepFool algorithm to find the closest point on the feed-forward layer's decision boundary. The attack then projects the difference vector between the original text's embedding and the synonym's embedding onto the direction towards this decision boundary. The synonym that results in the largest projection (indicating it moves the text vector closest to the boundary) is chosen for replacement. This process is repeated until the model's prediction changes.

Datasets

The authors evaluated their attack on two standard English text classification datasets:

  • IMDB: A large dataset for binary sentiment classification (movie reviews).
  • AG's News: A dataset for topic classification (news articles).

Key Insights and Ideas

  • Geometry Matters in NLP: The paper demonstrates that applying geometric principles, successful in image adversarial attacks, can also be effective for NLP. Understanding the "shape" of the decision boundary is crucial.
  • Saliency + Geometry = Effective Attacks: Combining word saliency (identifying important words) with geometric approximation (finding the best replacement to cross the boundary) leads to high success rates with minimal changes.
  • Human Perception is Key: The attack prioritizes generating examples that are hard for humans to detect, which is a significant improvement over some previous methods that might create unnatural-sounding text.
  • Adversarial Training Works: The research confirms that adversarial training can indeed improve the robustness of NLP models against this type of attack, although it might come at a cost to accuracy on clean examples.

Key Results

  • High Success Rates: The proposed attack achieved high success rates on both IMDB (up to 99.09% for RNNs) and AG's News (up to 87.08% for RNNs) datasets.
  • Low Word Replacement Rates: The attack was effective while replacing a small number of words, with rates as low as 2.97% for RNNs on IMDB.
  • Human Evaluation: Adversarial examples generated by the attack were perceived as very similar to original examples, with only a small drop in human prediction accuracy and low scores for "modification possibility."
  • Robustness Improvement: Adversarial training significantly reduced the success rate of the attack, indicating improved model robustness.

Limitations and Future Work

  • Model Architecture: The current attack assumes a specific model architecture (text encoder + feed-forward layer) and works with context-independent word embeddings.
  • Contextualized Embeddings: The authors explicitly mention extending the attack to models using contextualized word embeddings like ELMo and BERT as a key future direction.
  • Multi-class vs. Binary: The paper notes that fooling multi-class classifiers (like AG's News) is harder than binary classifiers (like IMDB), and longer sequences in IMDB might make attacks easier. Further exploration into these factors could be beneficial.

Summary updated

BibTeX
@inproceedings{meng2020geometry,
  author = {Zhao Meng and Roger Wattenhofer},
  title = {{A Geometry-Inspired Attack for Generating Natural Language Adversarial Examples}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.coling-main.585},
}
Figure