Sampling-aware Adversarial Attacks Against Large Language Models

Tim Beyer, Yan Scholten, Leo Schwinn, Stephan Günnemann

TL;DR

Most adversarial attacks on LLMs evaluate their success by looking at a single, greedily generated response, which drastically overestimates model safety. This paper introduces a "sampling-aware" framework that treats generating multiple responses as a core attack vector, proving that trading prompt optimization compute for sampling compute makes attacks over 130x more efficient and boosts success rates by up to 37%.

What Problem Does This Paper Address?

When researchers test the safety of Large Language Models (LLMs), they use adversarial attacks—often called "jailbreaks"—to see if they can force the model to output harmful content. Currently, the standard way to evaluate these attacks is to spend massive amounts of compute optimizing a malicious prompt, and then test it by generating just one response using greedy decoding (always picking the most likely next word).

The authors argue this approach is fundamentally flawed. LLMs are inherently stochastic by nature. In the real world, millions of users are sampling from these models at scale. If a model has even a 1% chance of outputting a dangerous recipe when prompted, that is a severe vulnerability. By ignoring the distribution of possible outputs and focusing only on the single most likely response, current evaluations give a false sense of security, missing dangerous tail risks and overestimating how robust our models actually are.

Methods: Attacks as Resource Allocation

The authors reframe adversarial attacks as a resource allocation problem. An attacker has a fixed compute budget (measured in FLOPs). They can spend this budget in two ways:

  1. Optimization: Tweaking the adversarial prompt to make it more likely to succeed (e.g., using algorithms like GCG or AutoDAN).
  2. Sampling: Querying the model with the current prompt to generate multiple candidate responses.
Comparison of previous adversarial attack paradigms versus the proposed sampling-aware approach, highlighting significant speedups and attack success rate (ASR) improvements.

The researchers tested various sampling schedules (e.g., optimizing first then sampling heavily at the end, or sampling uniformly throughout the optimization process) to find the compute-optimal sweet spot.

Additionally, they introduce a novel entropy maximization objective. Standard attacks try to force the model to output a specific affirmative prefix (like "Sure, here is a bomb recipe..."). Instead, the authors propose a label-free loss function that maximizes the entropy (randomness/diversity) of the model's first predicted token. This forces the model out of its standard, rigid refusal templates and generates diverse, natural-sounding completions that are more likely to stumble into harmful territory when sampled.

Experimental Setup

  • Prompts: The first 100 harmful prompts from the HarmBench dataset.
  • Judge: StrongREJECT, an LLM-based judge specifically designed to evaluate harmfulness with a low false-positive rate.
  • Models: Gemma 3 1B, Llama 3.1 8B, Llama 3 8B (protected by Circuit Breakers), and Llama 2 7B (Deeply Aligned).

Key Insights and Results

  • Sampling is dirt cheap: Taking a single optimization step to update a prompt can cost as much compute as generating hundreds of sampled responses. Shifting compute from optimization to sampling is a massive, untapped Pareto improvement.
  • Massive Efficiency Gains: Sampling-aware attacks achieved up to a 137.5x reduction in computational cost (for GCG) to reach the same level of attack success as greedy baselines.
  • Higher Success Rates: Integrating sampling into existing state-of-the-art attacks (GCG, AutoDAN, PAIR) boosted Attack Success Rates (ASR) by up to 37 percentage points at equal compute budgets.
  • Optimization just suppresses "No": Surprisingly, running heavy optimization algorithms doesn't actually make the model's compliant answers more harmful. It mostly just reduces the probability of an outright refusal. The underlying severity of the harm, once the model complies, stays relatively stable throughout the attack.
  • Safety rankings are an illusion: A model might look safer than a competitor when tested with a single greedy prompt, but actually be more vulnerable when sampled 50 times. This happens because some models have a thicker "tail" of rare but highly severe harmful responses.
  • Entropy beats forced compliance: The new entropy objective works beautifully with sampling. It reached a 64% ASR on Llama 3.1 8B after just 5 optimization steps, compared to 46% for the standard affirmative objective.

Limitations and Future Work

  • Static Schedules: The paper only tested fixed sampling schedules. Future work could explore adaptive schedules that dynamically decide whether to spend the next cycle optimizing or sampling based on intermediate results.
  • Decoding Strategies: The authors exclusively used standard multinomial sampling (at temperature 0.7). Exploring how other decoding strategies, like min-p or nucleus sampling, affect adversarial vulnerabilities remains an open question.
  • Model Size Constraints: Due to the massive compute required to track FLOPs across billions of generated tokens, the main experiments focused on smaller open-weight models (<10B parameters). Further verification on frontier-class models is needed.

Summary updated

BibTeX
@inproceedings{beyer2026sampling,
  author = {Tim Beyer and Yan Scholten and Leo Schwinn and Stephan Günnemann},
  title = {{Sampling-aware Adversarial Attacks Against Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=vBmRQHW7en},
}
Figure