Skip to main content
QUICK REVIEW

[Paper Review] Learning to Discriminate Perturbations for Blocking Adversarial Attacks in Text Classification

Yichao Zhou, Jyun‐Yu Jiang|arXiv (Cornell University)|Sep 6, 2019
Adversarial Robustness in Machine LearningComputer Science33 references16 citations
TL;DR

This paper proposes DISP, a novel defense framework that identifies and recovers adversarial perturbations in text classification without retraining models. Using a perturbation discriminator and embedding estimator with k-NN search, DISP restores original semantics and blocks attacks, significantly outperforming baselines on SST-2 and IMDb with robust transferability across datasets.

ABSTRACT

Adversarial attacks against machine learning models have threatened various real-world applications such as spam filtering and sentiment analysis. In this paper, we propose a novel framework, learning to DIScriminate Perturbations (DISP), to identify and adjust malicious perturbations, thereby blocking adversarial attacks for text classification models. To identify adversarial attacks, a perturbation discriminator validates how likely a token in the text is perturbed and provides a set of potential perturbations. For each potential perturbation, an embedding estimator learns to restore the embedding of the original word based on the context and a replacement token is chosen based on approximate kNN search. DISP can block adversarial attacks for any NLP model without modifying the model structure or training procedure. Extensive experiments on two benchmark datasets demonstrate that DISP significantly outperforms baseline methods in blocking adversarial attacks for text classification. In addition, in-depth analysis shows the robustness of DISP across different situations.

Motivation & Objective

  • To address the challenge of defending NLP models against adversarial attacks without modifying model architecture or training.
  • To develop a defense mechanism that identifies subtle, semantically plausible perturbations in text, which are hard to detect due to discrete token space and large vocabulary.
  • To restore perturbed tokens using contextualized embeddings and efficient nearest neighbor search, preserving sentence coherence and prediction accuracy.
  • To enable transferability of the defense across different text corpora and NLP tasks without retraining on target data.
  • To provide a plug-and-play solution for existing models, enhancing robustness against various attack types including word-level and character-level manipulations.

Proposed method

  • A perturbation discriminator is trained to classify each token as perturbed or not, using a contrastive learning objective on adversarial examples.
  • An embedding estimator learns to reconstruct the original word embedding from context and a candidate replacement token using a pre-trained corpus.
  • For each identified perturbed token, a k-NN search is performed over a hierarchical navigable small world (HNSW) graph of precomputed token embeddings to find the most semantically similar word.
  • The framework operates as a post-processing module, requiring no retraining of the target NLP model, enabling plug-and-play deployment.
  • The method leverages contextualized representations to ensure semantic consistency during token recovery, minimizing performance degradation.
  • The system is trained end-to-end on adversarial examples, enabling generalization across attack types and datasets.

Experimental results

Research questions

  • RQ1Can a defense mechanism detect and recover adversarial perturbations in text without modifying the target model’s architecture or training?
  • RQ2How effective is the proposed framework in blocking various types of adversarial attacks, including word substitution, insertion, deletion, and character-level swaps?
  • RQ3To what extent can the perturbation discriminator and embedding estimator generalize across different text corpora and NLP tasks?
  • RQ4How does the performance of the defense degrade when context is sparse or multiple perturbations are present?
  • RQ5Can the defense be transferred from one dataset (e.g., IMDb) to another (e.g., SST-2) without retraining?

Key findings

  • DISP achieved 87.96% accuracy on the SST-2 dataset under swap attacks, significantly outperforming baseline methods.
  • On the IMDb dataset, DISP maintained 86.81% accuracy under deletion attacks, demonstrating strong robustness across different attack types.
  • The transfer defense setting showed that DISP trained on IMDb achieved comparable performance to a model trained on SST-2, indicating strong cross-dataset generalization.
  • The embedding estimator achieved low RMSE scores of 0.0442 (SST-2) and 0.1030 (IMDb), indicating high-quality semantic reconstruction of original word embeddings.
  • In linguistic acceptability classification on CoLA, DISP reduced performance drop from 0.1209 (BERT) to 0.5502 accuracy under adversarial attacks, showing effectiveness beyond sentiment analysis.
  • Case studies confirmed that DISP successfully recovered perturbed words like 'orignal' to 'original' and 'bet' to 'best', though performance dropped in low-context or multi-perturbation cases.

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.