A Strong Baseline for Query Efficient Attacks in a Black Box Setting

Rishabh Maheshwary, Saket Maheshwary, Vikram Pudi

Abstract

Generating adversarial attacks against Natural Language Processing (NLP) models in a "black-box" setting is typically a slow, query-intensive process. This paper introduces a new baseline that leverages attention mechanisms and Locality Sensitive Hashing (LSH) to reduce the number of required queries by approximately 75% while maintaining a high attack success rate. By prioritizing word importance through proxy models and deduplicating the search space via LSH, the proposed method offers a significantly more efficient alternative to traditional combinatorial optimization techniques.

Introduction

Deep Neural Networks (DNNs) are susceptible to adversarial examples—inputs modified by human-imperceptible changes that cause incorrect model predictions. In practical scenarios, attackers often operate in a "black-box" environment, where they lack access to internal gradients and must rely solely on output scores. The primary bottleneck in these attacks is the query count. Existing methods, such as Genetic Algorithms or Particle Swarm Optimization (PSO), often require tens of thousands of queries to generate a single adversarial example, making them computationally expensive and easily detectable.

Methodology

The authors propose a two-step attack strategy designed to maximize query efficiency by addressing the "Where to Attack" and "How to Attack" phases separately.

1. Word Ranking (Where to Attack)

To avoid querying the target model for every possible word deletion, the method uses two proxy scoring mechanisms:

  • Attention-based Scoring: A separate, pre-trained "proxy" model (e.g., a Hierarchical Attention Network) identifies influential words in a single pass. This requires zero queries to the target model.
  • LSH-based Scoring: To estimate the impact of word replacements, the system generates potential synonyms. Instead of testing every perturbation, it uses Locality Sensitive Hashing (LSH) to group similar sentences into buckets. The target model is queried only once per bucket, assuming that semantically similar perturbations will yield similar model responses.
Architecture of the proposed two-step scoring mechanism using Attention and LSH.

2. Word Substitution (How to Attack)

After ranking words by importance, the algorithm greedily replaces them with synonyms (sourced from WordNet or HowNet) until the model's prediction is successfully flipped. This approach avoids the exponential search space explosion common in other optimization methods.

Experimental Setup

The attack was evaluated on three standard NLP benchmarks:

  • IMDB: Document-level sentiment classification.
  • Yelp Reviews: Restaurant review sentiment classification.
  • MultiNLI: Natural Language Inference.

These were tested against two target architectures: WordLSTM and BERT-base-uncased.

Key Results

The proposed method demonstrates that queries are the primary bottleneck in black-box settings and that attention serves as an effective, low-cost proxy for word importance.

  • Efficiency: The method reduced query counts by an average of 75% compared to state-of-the-art attacks like PSO and Genetic Algorithms. In one instance, the attack time was reduced from 72 hours (PSO) to just 1 hour.
  • Success Rate: The attack success rate remained within 2% of much slower, exhaustive methods.
  • Budget Performance: Under strict query limits (e.g., a budget of 1,000 queries), this method significantly outperforms competitors by identifying high-impact words much earlier in the process.
Comparison of attack success rates across different query budgets for various models and datasets.

Conclusion

By shifting the focus from exhaustive search to efficient word ranking and LSH-based deduplication, this research establishes a strong, query-efficient baseline for black-box NLP attacks. Future work may extend these principles to sentence-level perturbations and explore the generalization of attention proxies across more specialized domains.

Summary updated

BibTeX
@inproceedings{maheshwary2021strong,
  author = {Rishabh Maheshwary and Saket Maheshwary and Vikram Pudi},
  title = {{A Strong Baseline for Query Efficient Attacks in a Black Box Setting}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=ZF2-xv3I9Ky},
}
Figure