TL;DR
Generating high-quality textual adversarial attacks in a hard-box setting (where only the top-1 predicted label is available) usually requires an excessive number of queries or gets trapped in local optima due to rigid greedy search strategies. This paper introduces LBA (Low-query Budget hard-label Attack), a Metropolis-Hastings-inspired sampling framework that combines prior quality constraints with query-driven posterior knowledge. LBA significantly outperforms state-of-the-art methods across various language models—including LLMs—while strictly adhering to tight query budgets.
What Problem Does This Paper Address?
Textual adversarial attacks expose vulnerabilities in NLP models by making subtle changes (like synonym substitutions) that flip a model's prediction while remaining imperceptible to humans. In real-world security deployment, attackers typically only have access to "hard labels" (the final predicted class, without confidence scores) and must operate under strict query budgets to avoid detection or high API costs.
Existing hard-label attacks rely heavily on a greedy local search paradigm: they select one word position to change, lock it in, and move to the next. This drastically shrinks the search space, prevents the algorithm from exploring complex combinations of word changes, and wastes valuable query budgets on suboptimal paths.
Methods
The authors shift the adversarial generation paradigm from a greedy local search to a distribution-based sampling problem.
- Metropolis-Hastings Framework: LBA uses a sampling strategy inspired by the Metropolis-Hastings (MH) algorithm to explore the combinatorial space of word substitutions without permanently locking in early decisions.
- Target Function Formulation: It defines a target distribution $\pi(x') = A(x') \cdot Q(x', x)$ composed of two core parts:
- Prior Knowledge (Quality, $Q$): Predefined constraints ensuring the text remains fluent and semantically similar to the original (measured via sentence encoders, GPT-2 perplexity, and grammar checkers).
- Posterior Knowledge (Aggressiveness, $A$): A feedback-driven component that tracks which word positions historically caused the model's label to flip during the attack process.
- Iterative Feedback Loop: Candidates are proposed via with-replacement synonym substitution. The algorithm probabilistically decides to accept or reject the candidate based on an acceptance rate. Accepted samples query the victim model, and the resulting feedback dynamically updates the posterior "aggressiveness" map, creating a positive feedback loop that sharpens the search over time.
Datasets
The method was evaluated on four popular NLP benchmarks:
- MR: A short-text movie review dataset.
- AG: A 4-class news classification dataset.
- YELP: A long-text binary sentiment classification dataset.
- IMDB: Another long-text binary sentiment dataset.
These datasets were tested against six target models spanning traditional Neural Networks (WordCNN, WordLSTM), Pre-trained LMs (BERT), and Large Language Models (LLaMA 2, Vicuna, GPT-4o-mini).
Key Insights and Ideas
- Sampling Beats Greedy: Instead of shrinking the search space iteration by iteration, treating adversarial generation as sampling from an approximate distribution preserves the ability to find globally optimal word combinations.
- Exploiting the History: Even without soft-label confidence scores, the history of successful label flips across iterations provides a powerful proxy for word importance (posterior knowledge).
- The Long-Text Advantage: The performance gap between LBA and greedy baselines widens significantly on longer texts (YELP, IMDB). This proves that LBA handles massive combinatorial search spaces far better than local search heuristics.
Key Results
LBA consistently achieves the highest similarity and fluency across all datasets and query budgets.
- BERT Attack: When attacking BERT under a "tiny" query budget, LBA reduced the average perturbation rate by 56.18%, reduced grammatical error increases by 58.56%, and lowered perplexity by 47.76% compared to the second-best baseline, while improving semantic similarity by 11.74%.
- LLM Robustness: On LLMs like LLaMA 2 and Vicuna, LBA maintained its dominance. For instance, on the YELP dataset, LBA achieved a ~12.4% lower perturbation rate and significantly lower perplexity than competing hard-label attacks.
- LLM & Human Validation: Using GPT-4o as an automated judge, LBA achieved the highest Consistency Rate (meaning the adversarial text still clearly retained its original human-perceived meaning) and Fully Understood Rate. Human annotators also confirmed that LBA preserved original semantics better than any baseline.
Limitations and Future Work
- Synonym Dependency: The proposal step relies heavily on the quality of the predefined synonym vocabulary. Poor synonym sets could bottleneck the algorithm's capability.
- Hyperparameter Tuning: The target function relies on several hyperparameters ($\lambda_1$ to $\lambda_4$) to balance similarity and fluency. While the authors provide an optimized configuration, these weights might require re-tuning for highly distinct domains or non-English languages.
- Future Directions: The authors suggest that extending this distribution-based sampling framework to open-ended generation tasks (rather than just text classification) represents a promising next step.
Summary updated