Accelerating Greedy Coordinate Gradient via Probe Sampling

Yiran Zhao, Wenyue Zheng, Tianle Cai, Xuan Long Do, Kenji Kawaguchi, Anirudh Goyal, Michael Shieh · DOI

Abstract

Greedy Coordinate Gradient (GCG) is a cornerstone of LLM red-teaming, yet its computational demands make large-scale safety evaluations difficult. We introduce Probe Sampling, a technique that leverages small "draft" models and a dynamic alignment mechanism to accelerate prompt optimization by up to 5.6x. Our results show that Probe Sampling not only reduces wall-clock time and floating-point operations (FLOPs) but also enhances attack success rates by introducing beneficial stochasticity into the optimization process.

Introduction

Ensuring the safety of Large Language Models (LLMs) requires robust "red-teaming" to identify prompts that bypass safety guardrails. Greedy Coordinate Gradient (GCG) is the standard method for this task, but it is notoriously slow. In every iteration, GCG evaluates hundreds of potential token replacements by performing full forward passes through a massive target model. This computational bottleneck limits the scope of safety research. We propose Probe Sampling to mitigate this cost without sacrificing optimization quality.

Methodology

Probe Sampling adapts the principles of speculative decoding to discrete optimization. Instead of evaluating all candidates on the target model, we use a much smaller draft model to filter the candidate pool.

The Probe Sampling workflow: Batch candidates are filtered by a draft model, with the filter size dynamically adjusted based on rank correlation with a target model probe set.

The workflow consists of the following components:

  • Drafting and Probing: Candidates are initially ranked by a small draft model (e.g., GPT-2). A small "probe set" is evaluated on both the draft and the target model (e.g., Llama-2-7b).
  • Dynamic Alignment: We calculate the Spearman’s rank correlation ($\alpha$) between the two models' losses on the probe set. This score indicates how well the draft model currently mimics the target model's ranking.
  • Adaptive Filtering: Based on $\alpha$, the algorithm dynamically adjusts the number of candidates passed to the target model. High alignment allows for more aggressive filtering, while low alignment triggers a larger filtered set to ensure the optimal candidate is not missed.

Experimental Results

We evaluated Probe Sampling across adversarial benchmarks (AdvBench) and prompt engineering tasks (GSM8K, MMLU, BBH).

Performance metrics showing speedups and accuracy across various tasks and models using Probe Sampling.

Key findings include:

  • Significant Speedups: Probe Sampling achieved 3.5x to 4.1x speedups for GCG. When combined with simulated annealing, the speedup reached 5.6x.
  • Enhanced Effectiveness: On Llama-2-7b-Chat, the Attack Success Rate (ASR) improved from 69.0% with vanilla GCG to 81.0% with Probe Sampling. The filtering process likely acts as a form of beneficial noise, helping the optimizer escape local minima.
  • Broad Utility: The method is not limited to attacks; it accelerated Automatic Prompt Engineer (APE) by up to 3.0x and AutoPrompt by 1.8x.

Discussion and Conclusion

The success of Probe Sampling stems from the "locality advantage": local token variations are often ranked similarly by both small and large models. By dynamically adjusting to the degree of model alignment, Probe Sampling provides a robust and efficient path for LLM optimization. While currently limited to white-box settings, this approach significantly lowers the barrier for comprehensive LLM safety testing and prompt engineering.

Summary updated

BibTeX
@inproceedings{zhao2024accelerating,
  author = {Yiran Zhao and Wenyue Zheng and Tianle Cai and Xuan Long Do and Kenji Kawaguchi and Anirudh Goyal and Michael Shieh},
  title = {{Accelerating Greedy Coordinate Gradient via Probe Sampling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=CMgxAaRqZh},
}
Figure