Abstract
NLP researchers propose different word-substitute black-box attacks that can fool text classification models. In such attack, an adversary keeps sending crafted adversarial queries to the target model until it can successfully achieve the intended outcome. State-of-the-art attack methods usually require hundreds or thousands of queries to find one adversarial example. In this paper, we study whether a sophisticated adversary can attack the system with much less queries. We propose a simple yet efficient method that can reduce the average number of adversarial queries by 3-30 times and maintain the attack effectiveness. This research highlights that an adversary can fool a deep NLP model with much less cost.
Introduction
Deep learning models for Natural Language Processing (NLP) are notoriously fragile. By swapping just a few words in a sentence with synonyms (e.g., changing "wonderful" to "wondrous"), an adversary can flip a sentiment classifier's prediction from "Positive" to "Negative."
However, in a black-box setting, the attacker doesn't know the model's internal architecture. They must rely on numerous queries to find successful perturbations, which is problematic for two reasons:
- Cost: Using cloud-based APIs can be expensive per adversarial example generated.
- Detection: High query volumes for a single sentence resemble DDoS attacks, making them easy to flag.
This paper introduces a framework that utilizes a logistic regression model and embedding "moving directions" to slash the number of required queries by 3x to 30x while maintaining attack success.
Methodology
The proposed method optimizes the attack process by integrating two strategies into existing "Greedy" and "Genetic" search algorithms:
1. Smart Word Ranking (The "Where to Attack" Strategy)
Standard attacks identify influential words by deleting them individually and observing model responses—a query-heavy process. Instead, the authors build a simple logistic regression model on the fly. This model treats every previous query (successful or failed) as a data point, learning which words correlate with successful prediction flips. This allows the attacker to prioritize word substitutions without redundant querying.
2. Directional Word Replacement (The "How to Attack" Strategy)
Once a target word is selected, the algorithm analyzes the "moving direction" in the word embedding space. If a substitution reduces model confidence, it suggests a trajectory toward the decision boundary. The algorithm then prioritizes synonyms aligned with that specific vector in the counter-fitting embedding space.
Experimental Results
The researchers evaluated their method on three standard NLP benchmarks: IMDB (sentiment), Yelp (sentiment), and AG’s News (topic classification), attacking a pre-trained BERT model.
The efficiency gains were dramatic across all datasets. On the IMDB dataset, a standard Genetic Attack required 6,493 queries; with the proposed optimization, this dropped to just 212 queries—a 30x reduction. Despite the lower query count, the attacks remained just as effective. For example, on the AG News dataset, the model's accuracy dropped from roughly 94% to approximately 12% using both the baseline and the optimized "Greedy + Ours" approach.
Key Insights
- Failed Queries are Data: Unsuccessful attempts contain critical information. By treating the attack as a real-time machine learning problem, the adversary maps the model's vulnerability landscape efficiently.
- Adversarial Trajectories: Adversarial perturbations are not random; they follow specific directions in embedding space. If a substitution works, similar substitutions in the same "vector direction" are likely to be effective.
- Model-Agnostic Efficiency: The method acts as an "efficiency booster" that can be bolted onto various existing search strategies.
Conclusion and Future Work
This research demonstrates that sophisticated adversaries can compromise deep NLP models at a fraction of the traditional cost. While highly effective, future work may address the "cold start" problem of the logistic regression model and explore defense mechanisms against such directional search patterns. Additionally, balancing attack speed with human-readability (semantic drift) remains an ongoing challenge for adversarial NLP.
Summary updated