Skip to main content
QUICK REVIEW

[Paper Review] Bridge the Gap Between CV and NLP! A Gradient-based Textual Adversarial Attack Framework

Lifan Yuan, Yichi Zhang|arXiv (Cornell University)|Oct 28, 2021
Adversarial Robustness in Machine LearningComputer Science11 citations
TL;DR

This paper proposes a unified gradient-based adversarial attack framework that bridges computer vision and NLP by optimizing perturbations in the continuous embedding space, then decoding them via a masked language model to generate fluent, grammatical adversarial texts. The method, T-PGD, achieves state-of-the-art attack success rates in transfer black-box settings, outperforming strong baselines while maintaining high text quality.

ABSTRACT

Despite recent success on various tasks, deep learning techniques still perform poorly on adversarial examples with small perturbations. While optimization-based methods for adversarial attacks are well-explored in the field of computer vision, it is impractical to directly apply them in natural language processing due to the discrete nature of the text. To address the problem, we propose a unified framework to extend the existing optimization-based adversarial attack methods in the vision domain to craft textual adversarial samples. In this framework, continuously optimized perturbations are added to the embedding layer and amplified in the forward propagation process. Then the final perturbed latent representations are decoded with a masked language model head to obtain potential adversarial samples. In this paper, we instantiate our framework with an attack algorithm named Textual Projected Gradient Descent (T-PGD). We find our algorithm effective even using proxy gradient information. Therefore, we perform the more challenging transfer black-box attack and conduct comprehensive experiments to evaluate our attack algorithm with several models on three benchmark datasets. Experimental results demonstrate that our method achieves overall better performance and produces more fluent and grammatical adversarial samples compared to strong baseline methods. The code and data are available at \url{https://github.com/Phantivia/T-PGD}.

Motivation & Objective

  • To close the gap between adversarial attack methods in computer vision (CV) and natural language processing (NLP), where discrete text limits gradient-based optimization.
  • To address the challenge of crafting effective, fluent adversarial texts in black-box settings where only model decisions are accessible.
  • To develop a generalizable framework that enables optimization-based attacks in NLP by operating on continuous embeddings rather than discrete tokens.
  • To improve transferability and robustness of adversarial attacks in NLP by leveraging proxy models and masked language modeling for decoding.
  • To produce adversarial samples that are both highly effective and linguistically coherent, surpassing heuristic or discrete substitution-based methods.

Proposed method

  • The framework operates in the continuous embedding space, where gradient-based perturbations are applied directly to token embeddings rather than discrete tokens.
  • Perturbations are amplified through forward propagation in the neural network, increasing their impact on the final hidden representations.
  • A masked language model (MLM) head is used to decode the perturbed latent representations back into discrete, fluent, and grammatically correct text.
  • The attack uses a local proxy model to generate gradient signals when the true victim model’s gradients are unavailable, enabling decision-based black-box attacks.
  • The method is instantiated as T-PGD, an adaptation of PGD that leverages proxy gradients and MLM decoding to generate high-quality adversarial examples.
  • The framework enables transfer attacks across different datasets and models by training the proxy model on a different dataset than the victim, simulating real-world constraints.

Experimental results

Research questions

  • RQ1Can gradient-based adversarial attack methods from computer vision be effectively adapted to natural language processing despite the discrete nature of text?
  • RQ2How can adversarial perturbations be optimized in the embedding space to generate high-quality, fluent, and grammatical adversarial texts?
  • RQ3To what extent can adversarial attacks be transferred in a black-box setting when only model predictions are accessible and gradients are not available?
  • RQ4Can a masked language model head effectively reconstruct coherent adversarial texts from perturbed latent representations?
  • RQ5How does the performance of the proposed T-PGD method compare to strong baselines in terms of attack success rate, fluency, and grammaticality across diverse models and datasets?

Key findings

  • T-PGD achieved a 45.29% attack success rate on RoBERTa when attacking BERT using adversarial examples crafted on a different model, significantly outperforming baseline methods.
  • On the SST-2 dataset, T-PGD achieved a 97.00% attack success rate when the local proxy model was trained on the same dataset, demonstrating high effectiveness.
  • The method produced adversarial samples with a 343.65 average PPL (perplexity), indicating strong fluency and grammaticality compared to baselines.
  • In transfer settings across different datasets (e.g., IMDB, Amazon), T-PGD maintained strong performance with attack success rates of 93.30% and 96.40%, respectively.
  • The framework enabled successful decision-based black-box attacks using only model predictions, proving effective even without access to victim model gradients.
  • The use of an MLM head significantly improved the quality of adversarial texts, ensuring they remained fluent and grammatically correct despite perturbations.

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.