NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning Diverse Attacks on Large Language Models for Robust Red-Teaming and Safety Tuning

Seanie Lee, Minsu Kim, Lynn Cherif, David Dobre, Juho Lee, Sung Ju Hwang, Kenji Kawaguchi, Gauthier Gidel, Yoshua Bengio, Nikolay Malkin, Moksh Jain

TL;DR

Researchers have developed a two-stage framework using Generative Flow Networks (GFlowNets) and MLE smoothing to automate the discovery of diverse and effective "attack" prompts for Large Language Models (LLMs). Unlike standard reinforcement learning, which often suffers from mode collapse, this approach consistently finds a wide variety of vulnerabilities that transfer across different models and significantly improve safety tuning.

The Problem: Mode Collapse in Automated Red-Teaming

Red-teaming—the process of intentionally prompting a model to elicit harmful or toxic responses—is essential for ensuring AI safety. However, manual red-teaming is slow and difficult to scale.

While automated methods exist, they face a severe "diversity vs. effectiveness" trade-off. Standard Reinforcement Learning (RL) methods like PPO or REINFORCE tend to suffer from mode collapse: the attacker model finds one "perfect" way to break the target and simply repeats it. Even when researchers add "novelty" rewards to force diversity, the generated attacks often become nonsensical or lose their effectiveness. This paper tackles the challenge of building an automated "attacker" that can find many different ways to bypass safety filters while remaining highly effective.

A Two-Stage Solution: GFlowNets and MLE Smoothing

To overcome mode collapse, the authors propose treating red-teaming as a probabilistic inference problem rather than a strict optimization one. They introduce a two-stage training pipeline for an "attacker" language model:

Two-stage GFlowNet and MLE smoothing framework
  1. Stage 1: GFlowNet Fine-tuning: Instead of maximizing the expected reward like standard RL, GFlowNets are trained to sample prompts with a probability proportional to their reward. This naturally encourages the model to explore the entire landscape of high-reward (highly toxic) prompts rather than converging on a single peak. The reward function balances toxicity (measured by a classifier like Llama-Guard) and naturalness (measured by deviation from a reference language model).
  2. Stage 2: MLE Smoothing: GFlowNets can sometimes be overly sensitive to the "peakiness" of the reward function. To fix this, the authors collect the high-reward prompts found in Stage 1 into a replay buffer and perform a secondary round of Maximum Likelihood Estimation (MLE) fine-tuning. This "smooths" the distribution, allowing the attacker to generalize better and adapt quickly to new target models. Remarkably, this stage is incredibly cheap, taking under 5% of the total training time while significantly boosting performance.

Key Insights and Results

The study evaluates the method against several popular open-source target models, including GPT-2, Dolly-v2-7b, Gemma-2b-it, Llama-2-7b-chat, and Llama-3.1-8B-Instruct.

The Diversity-Toxicity Trade-off

Most baseline methods sit on the extremes: they either find very toxic but repetitive prompts (REINFORCE), or diverse but harmless ones (Supervised Fine-Tuning/In-Context Learning).

Performance comparison across target models showing the diversity-toxicity trade-off

As seen in the charts above, GFlowNet + MLE is the first method to consistently hit the "sweet spot" in the top-right of the frontier. For example, on Llama-3.1-8B-Instruct, the method achieved a toxicity rate of ~81% while maintaining a high cosine distance (diversity) of 0.829. In contrast, PPO + Novelty struggled to find effective attacks on safety-tuned models.

Attack Transferability and Robust Safety Tuning

A major finding of the paper is that attacks discovered on one model often work on others. Remarkably, 65% of the prompts generated to attack Llama-2-7b-chat successfully elicited harmful responses from the much larger, proprietary GPT-4o.

Furthermore, the authors demonstrate that if you take the diverse attacks generated by their method and use them to safety-tune a model (teaching it to refuse those specific prompts), the resulting model becomes much more robust to other types of automated attacks without losing its general reasoning abilities.

Limitations and Future Work

While highly effective, the approach has a few limitations:

  • Classifier Dependency: The system is only as good as its reward signal. If the toxicity classifier has blind spots (a problem known as "reward hacking"), the GFlowNet will learn to exploit those blind spots rather than finding "true" toxicity.
  • Computational Cost: Training an attacker "online" (iteratively querying the target LLM) remains more computationally expensive than offline methods.

Future work could extend this framework to multimodal models (such as text-to-image generation) or utilize it to generate adversarial suffixes for more complex jailbreaking scenarios.

Summary updated

BibTeX
@inproceedings{lee2025learning,
  author = {Seanie Lee and Minsu Kim and Lynn Cherif and David Dobre and Juho Lee and Sung Ju Hwang and Kenji Kawaguchi and Gauthier Gidel and Yoshua Bengio and Nikolay Malkin and Moksh Jain},
  title = {{Learning Diverse Attacks on Large Language Models for Robust Red-Teaming and Safety Tuning}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=1mXufFuv95},
}
Figure