T3: Tree-Autoencoder Constrained Adversarial Text Generation for Targeted Attack

Boxin Wang, Hengzhi Pei, Boyuan Pan, Qian Chen, Shuohang Wang, Bo Li

Introduction

Adversarial attacks—inputs specifically designed to deceive machine learning models—have long been a focus in computer vision research. In that domain, minor pixel adjustments can easily misguide a classifier. However, applying similar techniques to Natural Language Processing (NLP) presents a significant challenge: text is discrete. Unlike image data, one cannot simply "nudge" a word by a small fraction to alter its meaning or the model's perception.

Existing NLP attacks often rely on heuristic word substitutions or computationally expensive genetic algorithms, which frequently result in ungrammatical or nonsensical outputs. Furthermore, most are untargeted, merely aiming to make the model incorrect. T3 (Tree-Autoencoder Regularized Adversarial Text Generation) introduces a novel framework for targeted attacks, forcing models to produce specific incorrect answers (e.g., changing a sentiment from negative to positive) while maintaining grammatical integrity.

The T3 Framework

The T3 framework pipeline for generating adversarial text.

The core innovation of T3 is the use of a tree-based autoencoder to map discrete sentences into a continuous, high-dimensional latent space. This allows researchers to utilize gradient-based optimization—similar to the powerful Carlini & Wagner attacks used in vision—to find the minimal perturbation required for a successful attack.

Core Components

  1. Tree-Encoder: Utilizing a Tree-LSTM, this component converts a sentence into a continuous embedding by following its dependency parse tree. This ensures the model captures both semantic meaning and syntactic structure.
  2. Tree-Decoder: This novel component maps the continuous embedding back into a discrete sentence by traversing the dependency tree in level-order, ensuring the generated text adheres to valid grammar rules.
  3. Optimization and Attack Levels: T3 can perturb the root node (sentence-level, T3(SENT)) or leaf nodes (word-level, T3(WORD)). To avoid altering the ground truth of the original text, T3 generates a "distractor" sentence and appends it to the original paragraph.

Experimental Evaluation

The framework was evaluated on two primary benchmarks: the Yelp Dataset for sentiment classification and SQuAD v1.1 for reading comprehension.

Targeted attack success rates on sentiment classification models.

Key Results

  • High Effectiveness: In white-box settings, T3 achieved a nearly 100% success rate in forcing targeted sentiment changes on BERT models. Even in black-box scenarios, where the attacker does not have direct access to the target model's gradients, the attack remained highly effective through transferability.
  • Impact on QA Systems: On the SQuAD dataset, T3 significantly degraded performance. For instance, a position-targeted attack dropped BERT’s Exact Match (EM) score from 81.2 to 29.3.
  • Human Perception: A study involving Amazon Mechanical Turk workers revealed that while models were fooled in the vast majority of cases, humans were only misled by the adversarial text approximately 10% of the time. This confirms that the generated sentences are truly adversarial—breaking the machine's logic without compromising human understanding.

Discussion and Future Work

T3 demonstrates that syntax can act as a powerful regularizer. By using a tree structure rather than a flat sequence, the model ensures that even perturbed embeddings result in syntactically coherent sentences. This approach bypasses the non-differentiable nature of tokens, opening the door for sophisticated optimization tools previously restricted to continuous domains.

However, the framework currently depends on white-box access for initial generation and involves significant computational overhead for pre-training the tree-based autoencoder. Future research may focus on robust defense mechanisms, such as Adversarial Training, using large language models as anomaly detectors, or employing Interval Bound Propagation (IBP) to mathematically certify model robustness against such targeted distractions.

Summary updated

BibTeX
@inproceedings{wang2020t,
  author = {Boxin Wang and Hengzhi Pei and Boyuan Pan and Qian Chen and Shuohang Wang and Bo Li},
  title = {{T3: Tree-Autoencoder Constrained Adversarial Text Generation for Targeted Attack}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.495},
}
Figure