Adversarial Text Generation by Search and Learning

Guoyi Li, Bingkang Shi, Zongzhen Liu, Dehan Kong, Yulei Wu, Xiaodan Zhang, Longtao Huang, Honglei Lyu

Presented at EMNLP 2023, this research introduces ATGSL (Adversarial Text Generation by Search and Learning), a framework designed to rigorously test the robustness of Natural Language Processing (NLP) models. By integrating heuristic search techniques with deep learning, the authors generate adversarial examples that are highly effective at deceiving models while maintaining human-level fluency and semantic integrity.

The Challenge of Adversarial Text

Deep Neural Networks (DNNs) are susceptible to adversarial attacks—minor, intentional perturbations that trigger incorrect predictions. In the context of NLP, this typically involves substituting words or characters. However, generating effective adversarial text faces two primary hurdles:

  1. The Quality-Success Trade-off: Many heuristic methods achieve high success rates but result in "word salad"—text that is ungrammatical or loses its original meaning.
  2. Efficiency: Identifying the optimal combination of word swaps in long sequences is computationally expensive, often requiring an impractical number of queries to the target model.

Existing approaches generally fall into two categories: Search-based methods, which are effective but slow, and Learning-based methods, which are fast but often lack semantic consistency. ATGSL bridges this gap by using search to "teach" a generative model.

The ATGSL Framework

The authors propose three algorithms within the ATGSL framework:

  • ATGSL-SA (Search): Utilizes Simulated Annealing (SA) to explore word substitutions from synonym (WordNet) and sememe (HowNet) databases. SA allows the algorithm to avoid local optima by occasionally accepting less-than-ideal changes to find a better global solution.
  • ATGSL-BM (Learning): This core innovation treats successful attacks from the SA phase as "pseudo-references" to fine-tune a BERT-Masked Language Model (MLM). This generative model learns the patterns of successful attacks while smoothing out the linguistic noise inherent in raw heuristic searches.
  • ATGSL-FUSION (Hybrid): Combines both approaches. It uses the generative model (BM) to provide high-quality starting points or intermediate solutions, which the search algorithm (SA) then refines, preventing the search from becoming trapped in mediocre solutions.

Experimental Results

The framework was evaluated on five standard benchmarks: IMDB, MR, and AG’s News for classification, and MNLI and SNLI for natural language inference. The target models included CNN, LSTM, BERT, and RoBERTa.

Attack Success Rate (ASR)

ATGSL-FUSION demonstrated superior performance, achieving near-perfect success rates across all tested models and datasets. As shown in the table below, it consistently outperformed established baselines like PWWS, PSO, and BESA.

Attack Success Rates (ASR) of ATGSL variants compared to baseline methods across multiple datasets and models.

Text Quality and Semantic Similarity

A critical advantage of ATGSL is its ability to maintain text quality. By training on successful search results, the generative model learns to prioritize substitutions that fit the linguistic context. Quantitative metrics confirm that ATGSL-FUSION achieves lower modification rates and higher semantic similarity scores than traditional rule-based attacks.

Comparison of text quality metrics (%M: Modification rate, %I: Increase in perplexity, %S: Semantic similarity) for various attack methods.

Key Insights and Conclusion

The primary innovation of ATGSL is the concept of Search as a Teacher. Using a computationally intensive search to generate training data for a fast generative model allows the latter to mimic the search's effectiveness without the high query overhead during actual deployment.

While the initial training phase is resource-heavy and performance on very long texts (like IMDB) requires significant data, the resulting attacks are highly transferable and produce text that is significantly more fluent than previous state-of-the-art methods. Future work will focus on scaling the framework to larger pre-trained models and exploring self-supervised learning to reduce reliance on the initial search phase.

Summary updated

BibTeX
@inproceedings{li2023adversarial,
  author = {Guoyi Li and Bingkang Shi and Zongzhen Liu and Dehan Kong and Yulei Wu and Xiaodan Zhang and Longtao Huang and Honglei Lyu},
  title = {{Adversarial Text Generation by Search and Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.1053},
}
Figure