Multi-granularity Textual Adversarial Attack with Behavior Cloning

Yangyi Chen, Jin Su, Wei Wei

Abstract

Deep learning models for Natural Language Processing (NLP) are vulnerable to adversarial attacks, yet existing methods often suffer from granularity blindness and excessive query requirements. This paper introduces MAYA, a framework that crafts adversarial examples by modifying text at multiple levels—words, phrases, and full sentences—simultaneously. By employing Behavior Cloning, the researchers trained an agent to predict the most effective modifications, reducing the number of queries to victim models by orders of magnitude while maintaining high success rates and linguistic fluency.

Introduction

Adversarial attacks in NLP typically involve small, intentional perturbations designed to flip a model's prediction. However, current methodologies face two primary challenges:

  1. Granularity Blindness: Most attacks focus exclusively on a single level, such as word-level swaps or sentence-level paraphrasing, ignoring the holistic structural potential of the text.
  2. The Query Bottleneck: Finding a successful perturbation often requires thousands of queries to the victim model, which is impractical for real-world applications involving rate-limited or paid APIs.

MAYA addresses these issues by creating a multi-granular attack strategy that is optimized for query efficiency.

Methodology

The framework consists of two primary components: the MAYA algorithm (the "expert") and the MAYA$_{\pi}$ agent (the "student").

MAYA utilizes constituency parsing to decompose sentences into structural components (e.g., NP, VP). It generates adversarial candidates from two perspectives:

  • Constituent Level: Paraphrase models rewrite specific phrases or entire sentences while maintaining the surrounding context.
  • Word Level: Masked language modeling (MLM) suggests synonyms for individual words.

To ensure human-like quality, strict constraints are applied: semantic meaning must be preserved (measured via Sentence-BERT), and grammatical error rates must not increase.

The MAYA framework architecture, illustrating the flow from original sentence to adversarial generation and the behavior cloning process.

Efficiency via Behavior Cloning

To solve the query bottleneck, the authors treat the attack process as an imitation learning problem. They train the MAYA$_{\pi}$ agent using the DAGGER (Dataset Aggregation) algorithm. The agent learns to predict which modifications are most likely to deceive the victim model. Once trained, the agent makes internal decisions, querying the victim model only for the highest-probability candidates, which drastically reduces total query counts.

Experimental Results

The approach was evaluated against standard benchmarks (SST-2, MNLI, AG’s News) and popular architectures (BiLSTM, BERT, and RoBERTa).

Query Efficiency and Success Rates

The results demonstrate a significant leap in efficiency. For instance, on the SST-2 dataset attacking a BERT model, traditional PSO (Particle Swarm Optimization) attacks required over 5,000 queries. In contrast, the MAYA$_{\pi}$ agent achieved comparable success with only 18 queries.

Attack Success Rate vs. Maximum Query Number on SST-2 BERT, showing MAYA variants outperforming baselines at low query counts.

Key Insights

  • Holistic Search: Combining word-level and phrase-level modifications allows MAYA to find vulnerabilities that single-level attacks miss, leading to higher success rates with fewer total modifications.
  • Fluency and Naturalness: By using grammatical paraphrase models rather than isolated word swaps, MAYA produces adversarial text with lower perplexity and higher linguistic quality than baseline methods.
  • Transferability: Adversarial samples generated by an agent trained on a local proxy model remain highly effective against different architectures, suggesting they exploit fundamental processing flaws in Transformer models.

Conclusion and Future Work

MAYA demonstrates that multi-granular attacks combined with imitation learning can bypass the query bottleneck of traditional adversarial methods. While the current implementation assumes some knowledge of the victim's architecture, the high transferability of the attacks suggests broad applicability. Future research will explore using these multi-granular samples in adversarial training to bolster model robustness and adapting the framework for targeted attacks.

Summary updated

BibTeX
@inproceedings{chen2021multi,
  author = {Yangyi Chen and Jin Su and Wei Wei},
  title = {{Multi-granularity Textual Adversarial Attack with Behavior Cloning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=VCZV3eyGuu},
}
Figure