A Context-Aware Approach for Textual Adversarial Attack through Probability Difference Guided Beam Search

Huijun Liu, Jie Yu, Shasha Li, Jun Ma, Bin JiarXiv 2022 · DOI · OpenReview

TL;DR

This paper introduces PDBS, a novel method for generating adversarial text examples that are more effective and human-imperceptible. PDBS improves upon existing techniques by considering the probability differences across all class labels and employing a beam search strategy, leading to significantly higher attack success rates.

What Problem Does This Paper Address?

Textual adversarial attacks are crucial for understanding and improving the robustness of natural language processing (NLP) models, particularly text classifiers. These attacks involve making subtle modifications to input text that are imperceptible to humans but cause the model to misclassify the text. Existing methods often rely on a "greedy" approach, focusing solely on the probability of the correct (gold) label and exploring a limited set of modifications. This can lead to inefficient attacks that fail to find the most effective adversarial examples, especially in multi-class classification scenarios. The paper aims to address these limitations by developing a more sophisticated attack strategy that considers a broader range of label probabilities and explores a wider search space for modifications.

Methods

The proposed approach, PDBS (Probability Difference guided Beam Search), builds upon the "mask-then-infill" strategy commonly used in PLM-based attacks. This strategy involves masking tokens in the input text and then using a language model (like RoBERTa) to generate substitute tokens.

Here's what's new in PDBS:

  • Probability Difference: Instead of solely focusing on the probability of the correct label, PDBS calculates the "probability difference" – the difference between the gold label's probability and the maximum probability of any other class. This provides a more comprehensive signal for identifying vulnerable tokens and guiding the attack.
  • Beam Search: Traditional methods use a greedy search, which makes a single best choice at each step. PDBS employs a beam search, which maintains a set of top-k candidate attack paths at each iteration. This allows for a broader exploration of the search space, increasing the chances of finding a successful adversarial example.

The method uses three perturbation operations: Replace, Insert, and Merge, similar to prior work. The infilling process involves selecting substitute tokens that satisfy constraints on language model probability and textual similarity to the original text.

Datasets

The paper evaluates PDBS on several benchmark datasets for text classification and Natural Language Inference (NLI):

  • Yelp: Sentiment classification (positive/negative).
  • AG: News article classification (four classes).
  • MNLI: Natural Language Inference (entailment, contradiction, neutral).
  • QNLI: Natural Language Inference (binary classification).

Additionally, experiments were conducted on four other datasets: DBpedia ontology, Stanford sentiment treebank (SST-2), Microsoft Research Paraphrase Corpus (MRPC), and Quora Question Pairs (QQP). The authors note that for fair comparison, they used the exact 1,000 examples used in CLARE for each dataset.

Key Insights and Ideas

  • Beyond Gold Label Probability: The "probability difference" is a more effective heuristic than just the gold label probability for guiding adversarial attacks, especially in multi-class settings. It captures the model's uncertainty across all classes, not just its confidence in the correct one.
  • Beam Search for Exploration: Greedy search is too restrictive for finding optimal adversarial paths. Beam search, by exploring multiple promising paths simultaneously, significantly increases the attack success rate and avoids getting stuck in local optima.
  • Human Imperceptibility: PDBS not only achieves higher attack success but also generates adversarial examples that are more human-imperceptible, as evidenced by lower modification rates and higher textual similarity scores.

Key Results

PDBS consistently outperforms previous state-of-the-art models across various evaluation metrics.

  • Attack Success Rate (A-rate): PDBS achieves significant gains, ranging from +8.6% to +19.5% compared to the best previous model (CLARE). On some datasets, PDBS reaches near-perfect attack success rates (e.g., 99.2% on Yelp, 98.3% on MNLI).
  • Adversarial Example Quality: PDBS also excels in generating high-quality adversarial examples, consistently achieving optimal scores for textual similarity (Sim) and lower scores for modification rate (Mod), perplexity (PPL), and grammar error (GErr). This indicates that the generated examples are semantically close to the originals, fluent, and grammatically correct.
  • Human Evaluation: Human evaluations confirm that PDBS-generated examples maintain high similarity to original texts, exhibit good fluency and grammaticality, and are largely imperceptible.

Limitations and Future Work

  • Computational Cost: While beam search improves attack success, it also increases computational cost compared to greedy search. The paper notes that limited hardware capacity prevented them from exploring even larger beam sizes.
  • Trade-off between Attack Success and Quality: The paper observes that increasing the number of iteration times (T) improves attack success but can degrade the quality of adversarial examples. The authors select T=10 as a balance.
  • Future Work: The paper suggests exploring the transferability of adversarial examples to different target models and using PDBS for adversarial training to improve model robustness. They also hint at the possibility of achieving even better A-rates with larger beam sizes.

Summary updated

Abstract

Textual adversarial attacks expose the vulnerabilities of text classifiers and can be used to improve their robustness. Existing context-aware methods solely consider the gold label probability and use the greedy search when searching an attack path, often limiting the attack efficiency. To tackle these issues, we propose PDBS, a context-aware textual adversarial attack model using Probability Difference guided Beam Search. The probability difference is an overall consideration of all class label probabilities, and PDBS uses it to guide the selection of attack paths. In addition, PDBS uses the beam search to find a successful attack path, thus avoiding suffering from limited search space. Extensive experiments and human evaluation demonstrate that PDBS outperforms previous best models in a series of evaluation metrics, especially bringing up to a +19.5% attack success rate. Ablation studies and qualitative analyses further confirm the efficiency of PDBS.
BibTeX
@misc{liu2022context,
  author = {Huijun Liu and Jie Yu and Shasha Li and Jun Ma and Bin Ji},
  title = {{A Context-Aware Approach for Textual Adversarial Attack through Probability Difference Guided Beam Search}},
  year = {2022},
  eprint = {2208.08029},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2208.08029},
}
Figure