Abstract
Adversarial attacks pose a significant threat to NLP models, yet existing detection methods often rely on extensive adversarial training data and fail to generalize across different attack strategies. We present VoteTRANS, a training-free, "plug-and-play" detection framework that identifies adversarial text by leveraging the inherent instability of adversarial examples. By comparing a model's prediction on an input to the majority vote of its synonym-based transformations, VoteTRANS achieves state-of-the-art detection performance without prior exposure to adversarial datasets.
Introduction
Deep learning models for Natural Language Processing (NLP) are notoriously vulnerable to adversarial attacks—small, human-imperceptible changes, such as replacing "test" with "tryout," that drastically flip a model's prediction. Current state-of-the-art detectors typically require training on large adversarial datasets, which leads to two major flaws: high data dependency and a significant generalization gap when facing unseen attack strategies.
VoteTRANS addresses these challenges by offering a "black-box" solution that works across different models and attacks without requiring any prior training. It treats the model's prediction consistency as a proxy for truth, identifying malicious edits by observing how the model reacts to natural variations of the input.
Methodology
The core intuition behind VoteTRANS is that adversarial examples are inherently "unstable." While an attacker might find one specific word swap that fools a model, most other similar swaps (synonyms) will likely result in the correct prediction. In contrast, natural text tends to be "robust," meaning its classification should not change simply because a word is replaced by a synonym.
The VoteTRANS process follows four main steps:
- Word Importance Ranking: It identifies which words in the input text are most critical for the model's prediction using auxiliary tools like the PWWS attack.
- Transformation Generation: For the most important words, it generates a set of transformations (synonyms) using databases like WordNet to ensure meaning is preserved.
- Hard Label Voting: It feeds these transformed versions into the target model and optional "support models" (like RoBERTa). It records the "hard label" (the final category prediction) for each.
- Comparison: It compares the original text's label to the majority vote of the transformations. If the original label is an outlier compared to its own synonyms, it is flagged as adversarial.
Experimental Evaluation
The authors evaluated VoteTRANS across several standard NLP benchmarks, including AG News (topic classification), IMDB & Yelp (sentiment analysis), and Rotten Tomatoes (short-text sentiment). They tested the system against a wide battery of attacks, including PWWS, TextFooler, IGA, and BAE, targeting models such as CNN, LSTM, BERT, and DistilBERT.
Results and Discussion
VoteTRANS consistently outperformed existing trained detectors like FGWS and WDR. On the IMDB dataset, it achieved an F1 score of 96.9% and a Recall of 98.4% without any training. Crucially, the method remained highly effective in "Unknown Attack" scenarios, where trained detectors often see significant performance degradation.
Efficiency is another major advantage. The authors found that they do not need to transform every word in a document. By targeting only the top 10-20% of important words (the $\alpha$ ratio), VoteTRANS maintains high detection accuracy while drastically reducing computation time. For long IMDB texts, it processed detections in roughly 0.37 seconds when using RoBERTa as a support model.
Limitations and Future Work
Despite its strengths, VoteTRANS struggles with very short snippets (like Rotten Tomatoes reviews) because fewer words provide less "voting power," leading to lower confidence. Additionally, some natural text is inherently "brittle" due to poor grammar or ambiguity, which can lead to false positives. Future research may focus on adaptive attacks where adversaries attempt to find "robust" adversarial examples that can also fool the transformation-based voting process.
Conclusion
VoteTRANS provides a robust, efficient, and training-free defense against adversarial text attacks. By shifting the focus from pattern recognition to consistency checking, it offers a scalable solution for securing NLP models in real-world, black-box environments where adversarial data is scarce.
Summary updated