Interpretable Adversarial Training for Text

Samuel Barham, Soheil FeiziarXiv 2019

Abstract

Adversarial training (AT) has become a cornerstone for enhancing model robustness in computer vision, yet its application to Natural Language Processing (NLP) remains challenging due to the discrete nature of text. Traditional methods often produce adversarial perturbations in the embedding space that lack linguistic coherence. This paper discusses Sparse Projected Gradient Descent (SPGD), a novel framework that enforces interpretability and linguistic plausibility by constraining perturbations to move toward real-word neighbors and limiting changes to a sparse subset of influential tokens.

Introduction

Adversarial training involves augmenting the training process with examples designed to deceive the model, thereby improving its generalization and robustness. In continuous domains like image processing, small pixel-level changes are often imperceptible to humans. However, in text, the input space is discrete. Previous attempts to adapt AT to text have focused on adding noise to continuous word embeddings. While effective for performance, these methods often result in "noisy" embeddings that do not correspond to actual words, leading to ungrammatical or semantically inconsistent adversarial examples that can degrade the training signal.

Methodology: Sparse Projected Gradient Descent (SPGD)

To bridge the gap between continuous perturbations and discrete text, the authors propose SPGD, which introduces two primary constraints: Directional Projection and Sparsification.

Directional Projection

Instead of allowing adversarial noise to propagate in arbitrary directions within the embedding space, SPGD identifies the $K$ nearest neighbors of a target word. The algorithm then projects the calculated gradient onto the specific vector pointing toward the neighbor that most closely aligns with the adversarial direction. This ensures that the resulting perturbation represents a transition toward a semantically related, real-world token.

Illustration of the directional projection mechanism in SPGD. The raw perturbation is projected onto the direction of the nearest neighbor embedding to ensure semantic relevance.

Sparsification

Standard adversarial methods typically perturb every token in a sequence, which often destroys the sentence structure. SPGD utilizes a sparsity coefficient to restrict perturbations to only the most "influential" words—those with the highest gradient norms. By focusing on a small percentage of the input (e.g., 25%), the method preserves the overall grammatical integrity and meaning of the sentence while still providing sufficient regularization.

Experimental Setup

The effectiveness of SPGD was evaluated using the IMDB Movie Review dataset, a standard benchmark for sentiment analysis consisting of 50,000 labeled and 50,000 unlabeled reviews. The long-form nature of these reviews (averaging 235 words) provides a rigorous test for maintaining linguistic coherence over extended contexts.

Key Results and Discussion

Experimental results demonstrate that SPGD matches the predictive performance of state-of-the-art (SOTA) adversarial methods while significantly improving the quality of the generated examples.

  • Performance Parity: SPGD achieved a test accuracy of 93.54%, nearly identical to vanilla AdvT-Text (93.58%) and iAdvT-Text (93.58%).
  • Linguistic Quality: The "Perplexity Gap"—a measure of how natural the adversarial text appears to a language model—was significantly lower for SPGD (1.09) compared to vanilla methods (4.60) and iAdvT-Text (5.93).
  • Interpretability: Qualitative analysis shows that SPGD swaps words for semantically related alternatives (e.g., "compelling" to "startling") rather than creating the nonsensical "mushy" embeddings seen in previous methods.
Qualitative comparison of adversarial perturbations across different methods. SPGD (bottom) exhibits higher sparsity and more interpretable word substitutions compared to AdvT-Text and iAdvT-Text.

Conclusion and Future Work

SPGD demonstrates that sparsity and directional constraints are vital for making adversarial training in NLP both effective and interpretable. By narrowing the perplexity gap, SPGD ensures that the model learns from linguistically plausible "tricks" rather than random noise. Future research may explore the integration of class-conditional language models to further guarantee label invariance, ensuring that word swaps do not inadvertently flip the ground-truth sentiment of the training data.

Summary updated

BibTeX
@misc{barham2019interpretable,
  author = {Samuel Barham and Soheil Feizi},
  title = {{Interpretable Adversarial Training for Text}},
  year = {2019},
  eprint = {1905.12864},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.12864},
}
Figure