Abstract
Deep learning models for Natural Language Processing (NLP) are notoriously vulnerable to word-level adversarial attacks. By swapping just a few words for synonyms, attackers can flip a model's prediction without changing the text's meaning for humans. We present CheckHARD, a novel "three-in-one" defense framework that detects these attacks, corrects compromised predictions, and identifies tampered words. Unlike existing defenses that rely on word frequency or white-box model access, CheckHARD exploits "adversarial instability"—the tendency of adversarial triggers to cause label fluctuations when further perturbed. Our evaluation shows that CheckHARD significantly outperforms state-of-the-art frequency-based defenses in both accuracy and computational efficiency.
The Vulnerability of NLP Models
Adversarial attacks in NLP often involve subtle synonym substitutions (e.g., changing "funny" to "laughable") that are imperceptible to humans but catastrophic for model accuracy. Existing defenses typically attempt to identify these "perturbed" words using language models or frequency analysis. However, these methods often suffer from high false-positive rates, flagging benign words as suspicious. Furthermore, many require access to a model's internal probability scores, making them unsuitable for real-world black-box applications.
Methodology: Exploiting Adversarial Instability
The core innovation of CheckHARD is the observation that adversarial words are inherently "unstable." While replacing a benign word like "film" with "movie" rarely changes a model's sentiment prediction, replacing an adversarial "trigger" word often breaks the attack's "spell," causing the model's prediction to flip back and forth.
CheckHARD operates through a four-step pipeline:
- Transformation: For every word in the input, the system generates a set of synonyms using an auxiliary tool.
- Hard Label Checking: These variants are fed into the target model to record the resulting "hard labels" (the final classification).
- Difference Rate ($R$) Calculation: The system calculates the ratio of transformed labels that differ from the original input's label.
- Multi-Objective Output:
- Detection: If $R$ exceeds a specific threshold, the text is flagged as adversarial.
- Correction: A "hard vote" across all transformed labels is used to recover the true prediction.
- Suggestion: Words with the highest $R$ values are suggested as the likely points of adversarial tampering.
To optimize performance, CheckHARD introduces Support Models (like RoBERTa) to provide additional voting power and a Word Proportion ($\tau$) parameter to sample only a fraction of the text, drastically reducing processing time.
Experimental Results
CheckHARD was evaluated using the SST-2 and IMDB sentiment analysis benchmarks against ten different state-of-the-art attacks (including TextFooler and BAE) across multiple architectures (CNN, LSTM, BERT, and RoBERTa).
Key findings include:
- Superior Detection: On the SST-2 dataset, CheckHARD achieved an F1-score of 86.9%, significantly higher than the 76.3% achieved by the previous state-of-the-art defense, FGWS.
- High Correction Accuracy: The system successfully corrected compromised predictions with up to 95.6% accuracy.
- Efficiency Gains: By tuning the word proportion ($\tau$), the researchers achieved speedups of up to 39.2x on the IMDB dataset while maintaining higher accuracy than baseline methods.
Conclusion
CheckHARD provides a robust, black-box compatible defense mechanism by leveraging the inherent instability of adversarial perturbations. While currently optimized for word-level attacks, its success in detection and correction sets a new benchmark for securing NLP models against malicious manipulation. Future research will explore extending this framework to phrase-level attacks and more complex generative tasks.
Summary updated