Skip to main content
QUICK REVIEW

[Paper Review] Contextualized Perturbation for Textual Adversarial Attack

Dianqi Li, Yizhe Zhang|arXiv (Cornell University)|Sep 16, 2020
Adversarial Robustness in Machine LearningComputer Science60 references20 citations
TL;DR

CLARE is a contextualized adversarial example generation model that uses a mask-then-infill approach with three context-aware perturbations—Replace, Insert, and Merge—based on a pre-trained masked language model. It generates fluent, grammatical, and semantically similar adversarial texts with higher attack success rates and fewer edits than baseline methods.

ABSTRACT

Adversarial examples expose the vulnerabilities of natural language processing (NLP) models, and can be used to evaluate and improve their robustness. Existing techniques of generating such examples are typically driven by local heuristic rules that are agnostic to the context, often resulting in unnatural and ungrammatical outputs. This paper presents CLARE, a ContextuaLized AdversaRial Example generation model that produces fluent and grammatical outputs through a mask-then-infill procedure. CLARE builds on a pre-trained masked language model and modifies the inputs in a context-aware manner. We propose three contextualized perturbations, Replace, Insert and Merge, allowing for generating outputs of varied lengths. With a richer range of available strategies, CLARE is able to attack a victim model more efficiently with fewer edits. Extensive experiments and human evaluation demonstrate that CLARE outperforms the baselines in terms of attack success rate, textual similarity, fluency and grammaticality.

Motivation & Objective

  • To address the limitations of heuristic, context-agnostic methods in generating adversarial text for NLP models.
  • To improve the fluency, grammaticality, and semantic similarity of adversarial examples by leveraging contextual knowledge from pre-trained language models.
  • To enable flexible perturbations that vary output length, overcoming the fixed-length constraint of token replacement methods.
  • To develop an effective, black-box attack strategy that minimizes input modifications while maximizing model evasion.
  • To demonstrate that CLARE-generated examples can improve model robustness through adversarial training, especially under data-scarce conditions.

Proposed method

  • CLARE employs a mask-then-infill procedure: it masks specific positions in the input and infills them using a pre-trained masked language model (e.g., RoBERTa).
  • It introduces three contextualized perturbation actions: Replace (substitute a token), Insert (add a new token), and Merge (combine a bigram into a single token).
  • Each perturbation is scored and ranked based on attack effectiveness and similarity to the original input, enabling iterative refinement.
  • The model operates in a black-box setting, relying only on the victim model’s predictions without access to its internal parameters.
  • Perturbations are applied at any position in the input sequence, allowing flexible and targeted modifications.
  • Textual similarity is preserved using sentence embeddings and cosine similarity thresholds, ensuring human-perceptible similarity to the original input.

Experimental results

Research questions

  • RQ1Can contextualized perturbations improve the fluency and grammaticality of adversarial text compared to heuristic, context-agnostic methods?
  • RQ2To what extent can CLARE generate adversarial examples with varied output lengths while maintaining high attack success rates?
  • RQ3How does CLARE compare to state-of-the-art baselines in terms of attack success rate, textual similarity, fluency, and grammaticality?
  • RQ4Can adversarial examples generated by CLARE improve the robustness of downstream NLP models, especially when training data is limited?
  • RQ5Does the use of a pre-trained masked language model enable more natural and semantically coherent adversarial examples?

Key findings

  • CLARE achieves a higher attack success rate than baseline methods across text classification, natural language inference, and sentence paraphrase tasks.
  • Human evaluation confirms that CLARE-generated examples are significantly more fluent and grammatical than those from baselines.
  • CLARE maintains higher textual similarity to original inputs, as measured by sentence embedding cosine similarity, compared to synonym-based and heuristic methods.
  • The model requires fewer edits to achieve successful attacks, demonstrating greater efficiency in perturbation.
  • Adversarial training using CLARE-generated examples improves the robustness of fine-tuned BERT models, particularly in low-data regimes.
  • The combination of Replace, Insert, and Merge perturbations enables flexible, context-aware modifications that preserve semantic meaning while evading detection.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.