DA³: A Distribution-Aware Adversarial Attack against Language Models

Yibo Wang, Xiangjue Dong, James Caverlee, Philip S. Yu

Introduction

Adversarial attacks on language models (LMs) typically involve making subtle modifications to input text to trigger incorrect model predictions. While many existing attacks achieve high success rates, they often produce "loud" signals that are easily caught by anomaly detectors. DA³ (Distribution-Aware Adversarial Attack) addresses this lack of stealth by ensuring adversarial examples remain "in-distribution," making them nearly invisible to standard defenses.

Conceptual overview of the DA³ attack framework where adversarial examples are designed to evade detectors.

The Problem: Detectable Adversarial Attacks

Current adversarial tools like BERT-Attack or TextFooler often cause a significant "distribution shift." This shift manifests in two primary ways:

  1. Confidence Drops: The victim model’s Maximum Softmax Probability (MSP) often decreases significantly, indicating the model is "unsure" even when it makes a wrong prediction.
  2. Statistical Anomalies: Adversarial text often looks statistically different from natural training data. This can be quantified using the Mahalanobis Distance (MD), which measures the distance between a sample and the distribution of the training data.

As shown in the figure below, standard adversarial examples exhibit a clear statistical separation from the original data distribution, allowing Out-of-Distribution (OOD) detectors to easily flag them.

Distribution of Mahalanobis Distance (MD) on the SST-2 dataset, showing the clear shift between original and adversarial samples.

The DA³ Framework

The authors propose a two-phase framework to bypass these detectors:

1. Fine-tuning Phase

Instead of simple synonym substitution, DA³ fine-tunes an attack model using LoRA (Low-Rank Adaptation) for efficiency. The core innovation is the Data Alignment Loss (DAL), which optimizes for two objectives:

  • MSP Loss: Encourages the model to maintain high confidence in its (incorrect) adversarial prediction.
  • MD Loss: Minimizes the statistical distance between adversarial examples and the original training distribution.

2. Inference Phase

The fine-tuned model generates token replacements that are statistically indistinguishable from natural text. To evaluate this, the researchers introduced the Non-detectable Attack Success Rate (NASR), a metric that only counts an attack as successful if it both fools the victim model and evades detection.

Key Results and Insights

DA³ was evaluated across multiple benchmarks (SST-2, CoLA, RTE, MRPC) against both white-box models (BERT, RoBERTa) and black-box LLMs (Llama 2, Mistral).

  • Superior Stealth: On the MRPC dataset, DA³ achieved a 74.86% NASR (MSP), significantly outperforming BERT-Attack, which dropped to 55.31%.
  • Cross-Model Transferability: Attacks optimized for stealth on smaller models transferred remarkably well to large-scale models like Llama2-7B. This suggests that "naturalness" is a universal property that helps bypass safety filters across different architectures.
  • Human Evaluation: Human raters found DA³'s adversarial examples to have better grammar and semantic preservation than traditional baselines, confirming that the mathematical "in-distribution" optimization translates to more natural-sounding text.

Conclusion

DA³ represents a shift in adversarial research from simply maximizing error rates to prioritizing stealth. By formalizing adversarial examples as a specific type of Out-of-Distribution data and optimizing to minimize that gap, DA³ creates a more potent and harder-to-detect threat. Future defense mechanisms must evolve beyond simple statistical checks to address these increasingly sophisticated, distribution-aware attacks.

Summary updated

BibTeX
@inproceedings{wang2024da,
  author = {Yibo Wang and Xiangjue Dong and James Caverlee and Philip S. Yu},
  title = {{DA³: A Distribution-Aware Adversarial Attack against Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.107},
}
Figure