Skip to main content
QUICK REVIEW

[Paper Review] TextDefense: Adversarial Text Detection based on Word Importance Entropy

Lujia Shen, Xuhong Zhang|arXiv (Cornell University)|Feb 12, 2023
Topic ModelingComputer Science3 citations
TL;DR

TextDefense is a novel, attack-agnostic adversarial text detection framework that leverages word importance entropy from a target model's predictions to detect adversarial examples. By analyzing shifts in word importance distributions, it achieves high detection performance (AUC > 0.95) across diverse models, datasets, and attack types, outperforming state-of-the-art methods without requiring prior attack knowledge or significant computational overhead.

ABSTRACT

Currently, natural language processing (NLP) models are wildly used in various scenarios. However, NLP models, like all deep models, are vulnerable to adversarially generated text. Numerous works have been working on mitigating the vulnerability from adversarial attacks. Nevertheless, there is no comprehensive defense in existing works where each work targets a specific attack category or suffers from the limitation of computation overhead, irresistible to adaptive attack, etc. In this paper, we exhaustively investigate the adversarial attack algorithms in NLP, and our empirical studies have discovered that the attack algorithms mainly disrupt the importance distribution of words in a text. A well-trained model can distinguish subtle importance distribution differences between clean and adversarial texts. Based on this intuition, we propose TextDefense, a new adversarial example detection framework that utilizes the target model's capability to defend against adversarial attacks while requiring no prior knowledge. TextDefense differs from previous approaches, where it utilizes the target model for detection and thus is attack type agnostic. Our extensive experiments show that TextDefense can be applied to different architectures, datasets, and attack methods and outperforms existing methods. We also discover that the leading factor influencing the performance of TextDefense is the target model's generalizability. By analyzing the property of the target model and the property of the adversarial example, we provide our insights into the adversarial attacks in NLP and the principles of our defense method.

Motivation & Objective

  • To address the lack of universal, attack-agnostic defenses against adversarial text in NLP.
  • To identify a universal signal—disruption in word importance distribution—that distinguishes adversarial from clean text.
  • To develop a detection framework that uses the target model’s own behavior, requiring no prior attack knowledge or model retraining.
  • To evaluate the method’s robustness across diverse architectures, datasets, and attack types, including unseen or adaptive attacks.
  • To understand the role of model generalizability in adversarial detection performance.

Proposed method

  • TextDefense computes the importance score of each word in a text based on its influence on the model’s prediction confidence.
  • It measures the entropy of the word importance distribution as a signal to detect adversarial perturbations.
  • The method perturbs the input text by replacing words with synonyms or random words and observes changes in the importance entropy across multiple forward passes.
  • It uses a threshold on the entropy shift to classify a sample as adversarial or clean, leveraging the model’s internal consistency.
  • The framework is designed to be agnostic to attack type, relying only on the target model’s prediction behavior.
  • It supports transferability: a small surrogate model can be used to reduce inference cost when the original model is large.

Experimental results

Research questions

  • RQ1Can word importance entropy serve as a universal signal to detect adversarial text across diverse attack types?
  • RQ2How does the performance of TextDefense depend on the generalizability of the target model?
  • RQ3Can TextDefense detect both known and unknown adversarial attacks without prior knowledge of the attack method?
  • RQ4How does TextDefense compare to state-of-the-art detection and adversarial training methods in terms of AUC and robustness?
  • RQ5What are the limitations of TextDefense in detecting adversarial examples with label-reversal patterns?

Key findings

  • TextDefense achieves an average AUC of 0.954 across five datasets and multiple attack methods, significantly outperforming state-of-the-art detection and adversarial training baselines.
  • The method maintains high detection performance (AUC > 0.95) even under black-box, query-efficient, and semantic-preserving attacks like TextFooler and PWWS.
  • When the target model’s confidence drops to 0.02, TextDefense still achieves an AUC of 0.6449, indicating it remains partially effective even under strong attacks.
  • The performance of TextDefense is strongly correlated with the generalizability of the target model, as models with better generalization show higher detection accuracy.
  • False negatives occur primarily in label-reversal attacks (e.g., replacing toxic words with non-toxic ones), where the model’s confidence shifts in a way that mimics clean text.
  • TextDefense is robust to transfer attacks, as it can effectively detect adversarial examples even when the surrogate model is used for inference, reducing computational cost.

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.