Accelerating Greedy Coordinate Gradient and General Prompt Optimization via Probe Sampling

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

TL;DR

Researchers have developed Probe Sampling, a method that accelerates adversarial prompt optimization for Large Language Models (LLMs) by up to 5.6x. By leveraging a tiny "draft" model to filter out unpromising candidates before evaluating them against a massive "target" model, the algorithm maintains—and sometimes even improves—the success rate of finding prompts that bypass safety filters.

The Bottleneck in LLM Safety Testing

As LLMs become more integrated into society, ensuring their safety against malicious inputs is paramount. One of the most effective ways to test these safeguards is through the Greedy Coordinate Gradient (GCG) algorithm. GCG searches for an adversarial "suffix"—a string of seemingly random tokens—that, when appended to a harmful query, forces the LLM to comply (often called a "jailbreak").

The primary drawback of GCG is its immense computational cost. To find a single successful suffix, the algorithm evaluates hundreds of candidate token replacements in every iteration. Each evaluation requires a full forward pass through a massive target model like Llama-2 or Vicuna. This computational bottleneck makes it difficult for researchers to conduct large-scale safety audits or thoroughly explore the landscape of LLM vulnerabilities.

Enter Probe Sampling

To address this inefficiency, the authors propose Probe Sampling. Inspired by speculative decoding, the core idea is simple: instead of using a giant, expensive model to evaluate every single candidate, use a small, cheap model to do the initial filtering.

Diagram illustrating the Probe Sampling architecture, where a draft model filters candidates before they reach the target model.

The process operates in three main steps:

  1. The Probe: The algorithm selects a small subset of candidates (the "probe set") and evaluates them on both a tiny draft model (e.g., GPT-2) and the large target model.
  2. Measuring Agreement: It calculates an "agreement score" using Spearman’s rank correlation. This score indicates how well the tiny model’s rankings currently match the giant model’s rankings for this specific prompt.
  3. Dynamic Filtering: The entire batch of candidates is then evaluated by the tiny draft model. If the agreement score is high, the algorithm aggressively filters out the lowest-scoring candidates, leaving only a few top contenders to be verified by the target model. If agreement is low, it retains more candidates to be safe.

By dynamically adjusting the filter based on the "agreement" between models, Probe Sampling avoids wasting expensive compute cycles on candidates that the draft model can reliably identify as poor choices.

Key Insights

  • The Locality Property: Because GCG candidates are generated by changing only one token at a time, they remain "local" to the original prompt. This locality makes it highly probable that a smaller model can accurately predict which minor changes will be beneficial.
  • Noise is a Feature, Not a Bug: Surprisingly, Probe Sampling often achieves a higher Attack Success Rate (ASR) than the original GCG. The researchers hypothesize that the filtering process introduces a healthy amount of randomness, helping the greedy search escape local minima where the original algorithm might stall.
  • Low Overhead: Because the draft model is orders of magnitude smaller than the target model, the extra computation required for the draft passes and correlation calculations is negligible compared to the massive time saved on the target model.

Performance and Results

The researchers evaluated their method across several standard benchmarks, including AdvBench for adversarial attacks, and various reasoning and NLP tasks (GSM8K, MMLU, BBH, SST-2) to test broader prompt optimization techniques like APE and AutoPrompt.

Bar chart showing the reduction in target model compute time when using Probe Sampling on Llama2-7b-chat compared to standard GCG.

The results demonstrate significant efficiency gains:

  • Massive Speedups: On the AdvBench dataset using Llama2-7b-chat, Probe Sampling achieved up to a 5.6x speedup when combined with simulated annealing.
  • Improved Success Rates: For Llama2-7b-chat, the Attack Success Rate jumped from 69.0% (original GCG) to 81.0% with Probe Sampling.
  • Broad Applicability: The method extends beyond adversarial attacks. It accelerated AutoPrompt by 1.8x, APE (Automatic Prompt Engineer) by up to 3.0x, and the genetic-algorithm-based attack AutoDAN by 2.4x.
  • Memory Efficiency: The approach requires minimal additional VRAM, as the draft model is small and the target model processes only a fraction of the original candidate batch.

Limitations and Future Directions

While highly effective, the authors acknowledge a few limitations. Currently, the method requires access to the model's internal log-likelihoods or gradients, meaning it cannot be directly applied to "black-box" proprietary models accessed via API (like GPT-4). Additionally, the choice of the draft model matters; if the draft model's behavior diverges too much from the target model (e.g., using a non-instruction-tuned draft for an instruction-tuned target), the speedup decreases.

Future work may involve extending this framework to multi-modal models or developing more sophisticated, on-the-fly methods for measuring model agreement, further streamlining the safety testing of next-generation AI systems.

Summary updated

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