REINFORCE Adversarial Attack on Large Language Models: An Adaptive, Distribution-Based, and Semantic ObjectiveREINFORCE Adversarial Attacks on Large Language Models: An Adaptive, Distributional, and Semantic Objective
The authors used the REINFORCE objective on HarmBench to increase Llama 3 8B's GCG ASR@512 from 0.35 to 0.73.
White-box evasion attack: θ is fixed, only the input is changed; the attacker needs to know the architecture, implementation, and parameters, and uses token gradients to maximize the probability of a harmful response in Φ(x). GCG modifies the ASCII suffix, PGD modifies the prefix and suffix. The victim systems are aligned LLMs and circuit breakers; the HarmBench judge deems success if it says yes for greedy generation.
- Optimization-based jailbreaks typically maximize the likelihood of a single human-affirmative response. That objective does not adapt to the model and does not treat the output as a distribution; the authors believe low success rates overestimate robustness.
- Write the attack as maximizing the expected reward over the response distribution, estimate the gradient with REINFORCE, and integrate it into GCG and PGD. Sampling includes seed responses, random, greedy, and harmful responses that appear during the attack; the reward comes from the HarmBench judge.
- On HarmBench, Llama 3 8B: REINFORCE-GCG's ASR@512 is 0.73, affirmative is 0.35. On circuit breaker, affirmative is 0.02, and on the y_history subset, REINFORCE is 0.50. Llama 2 7B's PGD goes from 0.17 to 0.22.
- The authors note that judge insufficiency can affect the target, and improving the judge is left for future work; evaluation uses only greedy generation. The experiments are white-box GCG and PGD, with a single trial per prompt, covering five open-source models, HarmBench's 200 items, and Llama 3 circuit breakers. Judge–human agreement is not reported.
- Evaluated models
- Llama 2 7BLlama 3 8BGemma 1.1 2BGemma 1.1 7BVicuna 1.5 7BLlama 3 8B + Circuit breaker
- Benchmarks
- HarmBench standard behaviors
- Metrics
- ASR@512ASR@128
The paper proposes an adversarial attack objective function based on REINFORCE policy gradient for optimizing jailbreak prompts against large language models. The authors point out that existing optimization-based attacks typically construct prompts by maximizing the likelihood of so-called affirmative responses, but the attacked models often do not actually produce harmful responses, and this objective ignores that LLMs output a distribution of responses, so measuring robustness this way may severely overestimate the model's true robustness. The new objective performs adaptive, semantic optimization over the response distribution and is validated on Greedy Coordinate Gradient (GCG) and Projected Gradient Descent (PGD). The authors claim that this method doubles the attack success rate on Llama3 and increases ASR from 2% to 50% under circuit breaker defenses.
Paper analysis
What problem does this paper attempt to solve?
The affirmative-response likelihood is non-adaptive and inconsistent, and the authors believe it overestimates robustness.
Optimization-based jailbreaks often maximize the likelihood of a fixed affirmative response, an objective that does not look at harmful semantics and does not adapt to the attacked model's response distribution.
- Scenario: aligned LLMs reject many inappropriate prompts, but the jailbreak literature shows small changes usually bypass them. The authors believe that if low attack success rates under such objectives are treated as robustness, true robustness may be overestimated.
- Existing shortcomings: the affirmative response is a manually designed harmful response opening. In Figure 2a, on Gemma 1.1 7B, GCG makes that opening's probability exceed 60%, yet the continuation is still harmless. This objective is usually not model-specific and ignores that the output is a distribution. The authors cite Tramer et al. (2020), stating that an inconsistent loss is a key obstacle to strong adaptive attacks.
- Observation: the authors believe one should optimize any harmful response the attacked model would reasonably produce. When the judge is well calibrated, the expected reward over the response distribution equals the probability of a harmful response.
- This paper's approach: propose an adaptive, distributional, semantic optimization problem, derive the objective with REINFORCE, and integrate it into GCG and PGD. After changing the reward, the same form can also be used for factuality or forgetting.
- Threat model:
- Objective: maximize the expected reward over the response distribution within the acceptable input set Φ(x); for jailbreaking, increase the probability of a harmful response.
- Knowledge: test-time evasion attack, parameters θ unchanged. The Impact Statement calls this scenario white-box: requires knowing the architecture, implementation details, and parameters; optimization uses one-hot token gradients.
- Capability: only changes the input. With an appended suffix, Φ(x) is the set of possible suffixes; in experiments, GCG only perturbs ASCII tokens, and PGD changes both prefix and suffix. Φ(x)=X is also usually feasible.
- Victim systems and judgment: aligned LLMs, and includes Llama 3's circuit breaker defense. The HarmBench judge deems success if the greedy generation is yes (ignoring case).
What related research exists?
Related work is grouped into gradient-optimization jailbreaks, generative red teaming, affirmative improvements, and judges.
- Gradient-optimization jailbreaks: GCG by Zou et al. (2023) and PGD by Geisler et al. (2024) use gradients to search for adversarial prefixes and suffixes, with the objective of maximizing the likelihood of a fixed affirmative response; GCG builds on AutoPrompt by Shin et al. (2020), and PGD is related to projected gradient attacks on graph neural networks. The same group includes Wallace et al. (2021), Guo et al. (2021, 2024), Wen et al. (2023), Zhu et al. (2023), etc. The paper names Andriushchenko et al. (2025): its self-transfer, templates, restarts, etc., are orthogonal to this paper, but it still uses a non-distributional objective, e.g., the log probability of "Sure".
- Generative models and reinforcement learning red teaming: Perez et al. (2022), Mehrotra et al. (2023), Chao et al. (2023), Chen et al. (2024), etc., train or use another LLM to generate jailbreak prompts. The paper classifies these methods as type (2), differing from this paper's test-time prompt-parameterized policy.
- Semantic objectives and affirmative improvements: Qiu et al. (2020) and others have done adversarial attacks capturing semantics in other modalities. Wichers et al. (2024) also use a judge for red teaming, but generate with Gumbel softmax relaxation and backpropagate through the attacked model and judge. Jia et al. (2024) modify templates, Thompson and Sklar (2024) distill responses from a modified model; concurrent Zhu et al. (2024)'s AdvPrefix finds model-dependent prefixes with high prefill success rate and low negative log-likelihood. The paper compares AdvPrefix with this paper in §G and calls them complementary.
- Judges: This paper uses the HarmBench (Mazeika et al., 2024) judge for reward and evaluation. Shen et al. (2024), Chao et al. (2023), Bhatt et al. (2023) proposed other judges. The paper mentions Souly et al. (2024) aligns slightly better with human evaluation, and states that all existing harmfulness judges are imperfect.
Baselines and benchmarks: affirmative GCG and affirmative PGD; HarmBench's standard behaviors total 200 default behaviors, excluding copyright and contextual.
The authors position this paper as replacing the objective of type (1) gradient attacks with one that targets response semantics, is distribution-aware, and adaptive, rather than retraining an LLM to generate attack prompts.
How does the paper address this problem?
Use REINFORCE to maximize the expected reward over the response distribution, and integrate it into GCG and PGD.
The authors write the jailbreak as maximizing the expected reward over the response distribution of a conditional generative model, use REINFORCE to obtain a computable gradient, and then replace the loss of GCG and PGD. The remaining attack hyperparameters keep the original method's defaults.
Problem setup
At test time θ is fixed, only the input is changed. The core objective is x̃∗=argmaxx̃∈Φ(x)𝔼y∼ Pfθ(Y|X=x̃)[Reward(y,x̃)] i.e., maximize the expected reward over the response distribution among acceptable adversarial inputs. For jailbreaking, the reward is harmfulness. The authors state that if the reward equals the probability that a given response is harmful, this expectation is P(Harmful|X=x̃).
The affirmative objective maximizes the likelihood of a single fixed y_affirmative. The authors state it is a biased estimate of the above: that response has reward 1, and the sampler only takes it, so it does not adjust with the current generation and reward.
REINFORCE estimation
An autoregressive LLM is viewed as a Markov decision process, with the next-token distribution as the policy. With discount factor γ=1 and only terminal reward, the value function equals the above expectation. At test time θ is not updated, but the policy is indirectly parameterized by the initial state X=x̃.
The policy gradient theorem gives an estimate proportional to the true gradient: ∇𝔼[Reward]∝𝔼[Reward(y,X̃)∇log Pfθ(y|X̃)] In implementation, the gradient is removed and its negative is used as the loss, which is equivalent to a signed weighting of the sample cross-entropy. Generations below the current sample average reward have their likelihood decreased, and those above the average are encouraged.
Variance control uses RLOO: each sample's reward subtracts the mean reward of the other samples. When K=1, the baseline is 0. Additionally, a constant 0.1 is added to the baseline and K is increased by 1, so that when all are harmless it behaves like a pure decrease loss, and when all are harmful it behaves like a pure increase loss. The authors state the dynamic baseline may be undesirable when all are harmful or all are harmless, so they make this stabilization.
Sampling and reward
The expectation is approximated with at most four samples: y_seed, y_random, y_greedy, y_harmful. y_seed defaults to the affirmative response, and can also be replaced with historical successful responses or AdvPrefix; when shorter than 128 tokens, it is greedily completed, and the reward of its original prefix is clipped from [0,1] to [0.5,1.0]. y_greedy takes the most likely token at each step, used as a mode approximation. y_random samples with temperature 0.7 among the 256 most likely tokens. y_harmful is a harmful generation seen during the attack: included when the reward exceeds 0.2, before 0.75 the most harmful is taken, and above 0.75 the longer or lower average cross-entropy one is preferred. The authors state this is a biased, off-policy-flavored sampling introduced for sample efficiency, and the estimator itself does not debias.
During optimization, generation is truncated to 128 tokens, and evaluation at most 512. The first token weight is five times that of the 128th token, decreasing linearly in between. Matching prefixes take the higher reward at the token level.
The reward is computed on the clean prompt. The attack succeeds if the HarmBench judge's greedy generation is yes (ignoring case). The reward is the log-odds of the most likely yes token versus the most likely non-yes token, then passed through sigmoid; if greater than 0.5, the target metric is true.
Integrating into two attacks
REINFORCE-GCG has four steps: sample according to the current prompt, compute the gradient of the REINFORCE loss, mutate one token at a time to get candidates, and select candidates using the loss of the same batch of samples. When the loss is cross-entropy and the samples are fixed to the affirmative response, it reduces to the original GCG. Since the judge reward is close to 0 or 1, intermediate rewards are also computed for prefixes of lengths 20, 40, 80, and the length closest to the seed's original length, to decide how long a generation to use for selection. Random samples are not used in selection. Once the mode is harmful, only candidates that keep the mode harmful are accepted; the returned prompt is the best one selected by the modified loss emphasizing the mode, not the last step.
REINFORCE-PGD similarly replaces sampling and loss, and reduces to the original PGD when the affirmative cross-entropy is fixed. It follows the original implementation: multiple prompts in parallel, Adam, return to the best intermediate solution after 100 steps without improvement, and with 50% probability use effective prefixes and suffixes from other prompts in the batch; the learning rate and entropy projection first increase linearly, then cosine anneal with warm restarts.
What experiments did the paper conduct?
REINFORCE-GCG's ASR@512 is higher than affirmative GCG; on Llama 2, PGD goes from 0.17 to 0.22.
Experimental setup
- Models tested: Llama 2 7B, Llama 3 8B, Gemma 1.1 2B, Gemma 1.1 7B, Vicuna 1.5 7B, and a circuit breaker version of Llama 3 8B.
- Data: all 200 default standard behaviors from HarmBench, excluding copyright and contextual. Fig. 3 and §4.3 sample 50. Each prompt is a single trial.
- Attacks: GCG search width 512, 500 steps, suffix initialized with 20 "!". PGD 5000 steps, learning rate 0.11, entropy projection 40%, prefix and suffix each 25 "!", batch size 17. Baseline hyperparameters are not tuned, no per-model configuration. Default y_seed is the affirmative response.
- Judges: main evaluation and GCG reward use HarmBench's Llama 2 13B judge. PGD optimization uses its Mistral 7B validation judge due to 80GB GPU memory. Success condition is the judge saying yes for greedy generation, ignoring case.
- Metrics: ASR@512 is scored after the target model generates 512 tokens, right-truncated to 512 according to the judge's tokenizer; the reward during the attack uses at most 128 tokens. ASR@128 is also reported. Only greedy generation is scored.
- Hardware: 80GB A100/H100, models and judges in bfloat16.
Main results
Swipe horizontally to read the table
Model GCG affirmative GCG REINFORCE PGD affirmative PGD REINFORCE Gemma 1.1 2B 0.57 0.88 0.56 0.82 Gemma 1.1 7B 0.63 0.87 0.54 0.84 Llama 2 7B 0.32 0.56 0.17 0.22 Llama 3 8B 0.35 0.73 0.57 0.69 Vicuna 1.5 7B 0.86 0.95 0.87 0.94 From Table 1 (GCG) and Table 2 (PGD), 200 behaviors, ASR@512.
- In all five rows, REINFORCE is higher than the affirmative objective in the same column. The authors state the gains are consistent, and state that on Llama 2 7B and Llama 3 8B, GCG roughly doubles; the abstract writes that it doubles on Llama 3.
- The exception the authors name is PGD on Llama 2 7B, which they say only improves slightly.
- The authors state that successful attacks elicit harmful behaviors different from affirmative responses, and sometimes refuse in the first few sentences but still answer afterward (§4.2, examples in Table 13).
Circuit breaker and seed responses
Table 3 attacks Llama 3 8B's circuit breaker, suffix still 20 tokens. Affirmative GCG's ASR@128/512 is 0.01/0.02; REINFORCE-GCG with y_seed as the affirmative response is 0.21/0.23. When the most harmful generation from successful attacks on the base model is used as y_history, on the subset where the base affirmative attack succeeds it is 0.46*/0.50*.
- The main text writes from 2% to 23% on the full set; the abstract writes from 2% to 50%. 50% corresponds to the starred subset, not all 200 behaviors.
- §G's Table 9: treating AdvPrefix as an affirmative objective, Llama 3 8B's ASR@512 is 0.70, circuit breaker is 0.14; when the same prefix is used as REINFORCE's y_seed, they are 0.81 and 0.48, respectively. The authors state REINFORCE is not overly sensitive to the seed, but benefits from a reasonable choice, and that making the seed sufficiently likely must be sufficiently easy.
- The authors state that this defense often shows stuttering-like generation later (examples in §J), and consider this result to indicate that adaptive attacks need a consistent objective.
Sampling strategies and GCG choices
Table 4 ablates sampling on Llama 3 8B, baseline is affirmative GCG: ASR@128/512 is 0.29/0.35. Adding random samples is 0.22/0.36; greedy extension of the seed then adding random samples is 0.24/0.34; then adding y_harmful is 0.42/0.56; with all four sample types it is 0.66/0.73. The authors state random samples do not bring improvement and even seem harmful; extending the seed improves slightly; harmful samples improve a lot; the full strategy is highest.
Fig. 4 compares mutation and selection, the text does not give bar heights. The authors state random mutation is worst, but random mutation with REINFORCE selection still greatly outperforms affirmative GCG; affirmative gradients with REINFORCE selection are already sufficient, and they relate this to search width 512 and GCG's mutation sampling.
Other ablations and analyses
- Fig. 3: on Gemma 1.1 2B and Llama 3 8B, ASR@128 of the judge used by the attack versus H100 runtime. The authors state REINFORCE's final value is high and outperforms standard GCG at most time scales; this trade-off is not specifically tuned. The text does not give endpoint values of the curves.
- Appendix E: on Llama 3, H100, vanilla GCG is about 1.3 seconds/step; REINFORCE-GCG is about 2.6 seconds best and about 13.2 seconds worst. In the Fig. 3 experiments, on average, each step is 9.4x and 33.3x more expensive than vanilla GCG and PGD, respectively.
- Table 7: REINFORCE-GCG from 128 to 512 tokens, Llama 3 8B is 0.66 to 0.73, Llama 2 7B is 0.63 to 0.56, Vicuna 1.5 7B is 1.00 to 0.95. The authors state this generalization is good.
- Table 8: the Mistral 7B used for PGD optimization and the Llama 2 13B used for testing can differ a lot. Llama 3 8B's REINFORCE on attack 128, test 128, test 512 is 0.60, 0.48, 0.69.
- Fig. 5: in one example over the first 50 steps, at step 7 a random generation is harmful and included, and at step 17 a greedy generation is harmful. The authors state the seed's cross-entropy does not need to drop very low, and the attack can turn to very different generations.
What are some points that can be further explored?
The authors list judge insufficiency and evaluating only greedy generation as limitations, and leave improving the judge as future work.
Limitations and future directions noted by the authors
- Insufficiencies of LLM-as-a-judge can affect the REINFORCE objective (§6 Limitations).
- The authors state they did not observe systematic judge issues in the random examples in §I, and leave improving the judge as future work; they also state that if the judge continues to improve, this attack objective may improve accordingly (§6).
- Evaluation relies on greedy generation: a harmful greedy generation does not imply other random generations are harmful, and it is not stable on adversarial inputs (§6).
- More complex decoding in practice can affect alignment; the authors state they tried to avoid designs that only work because of greedy evaluation (§6).
Experimental coverage
- Attacked models are Llama 2 7B, Llama 3 8B, Gemma 1.1 2B, Gemma 1.1 7B, Vicuna 1.5 7B, and a circuit breaker version of Llama 3 8B (§4).
- Main results use 200 standard behaviors from HarmBench; Fig. 3 and §4.3 use 50 of them. Each prompt is a single trial (§4.1).
- Baselines are affirmative GCG and affirmative PGD; the defense evaluation is circuit breaker. On Llama 3 8B and its circuit breaker version, AdvPrefix and y_history are also compared (Table 3, Table 9).
- Evaluation and GCG reward use the Llama 2 13B judge, and PGD optimization uses the Mistral 7B judge. The paper does not report agreement between the judge and human evaluation.
- Attacks are white-box gradient methods, GCG 500 steps, PGD 5000 steps; the paper gives per-step time on H100, and does not report query counts. ASR is scored only for greedy generation.
Summarize the main content of the paper
REINFORCE changes the jailbreak objective to the expected reward over the response distribution and improves the ASR of GCG and PGD.
The authors use REINFORCE to rewrite the objective of optimization-based jailbreaks: searching for harmfulness over the attacked model's response distribution, rather than a fixed affirmative prefix.
- Problem: The affirmative likelihood can be pushed high, yet continuations can still be harmless, and it does not adapt to the model. The authors believe using it to measure robustness overestimates robustness, and state that the inconsistent objective hinders strong adaptive attacks.
- Method: At test time, parameters are fixed, and the policy is indirectly parameterized through the input, maximizing the expected reviewer reward. The RLOO policy gradient suppresses relatively harmless generations in the current sample and encourages relatively harmful ones. Sampling mixes seed, greedy, random, and harmful responses that appear during attacks, then integrates GCG and PGD.
- Main results: On 200 HarmBench items, Llama 3 8B GCG ASR@512 goes from 0.35 to 0.73, and Llama 2 7B from 0.32 to 0.56. PGD also mostly rises, but Llama 2 7B only goes from 0.17 to 0.22.
- Defenses: On the circuit breaker, affirmative GCG ASR@512 is 0.02; full REINFORCE-GCG is 0.23. The 50% in the abstract is on y_history and only on the subset where the base affirmative attack succeeds (0.50* in Table 3).
- Authors' conclusion: The authors state that when the reviewer is well calibrated, this objective maximizes the probability of harmful responses and is asymptotically consistent. The authors believe manually written improper responses are unlikely to suffice long-term, and adaptive objectives will be the basis for evaluating future models.