Abstract
We address the challenge of generating diverse attack prompts for large language models (LLMs) that elicit harmful behaviors (e.g., insults, sexual content) and are used for safety fine-tuning. Rather than relying on manual prompt engineering, attacker LLMs can be trained with reinforcement learning (RL) to automatically generate such prompts using only a toxicity classifier as a reward. However, capturing a wide range of harmful behaviors is a significant challenge that requires explicit diversity objectives. Existing diversity-seeking RL methods often collapse to limited modes: once high-reward prompts are found, exploration of new regions is discouraged. Inspired by the active learning paradigm that encourages adaptive exploration, we introduce Active Attacks, a novel RL-based red-teaming algorithm that adapts its attacks as the victim evolves. By periodically safety fine-tuning the victim LLM with collected attack prompts, rewards in exploited regions diminish, which forces the attacker to seek unexplored vulnerabilities. This process naturally induces an easy-to-hard exploration curriculum, where the attacker progresses beyond easy modes toward increasingly difficult ones. As a result, Active Attacks uncovers a wide range of local attack modes step by step, and their combination achieves wide coverage of the multi-mode distribution. Active Attacks, a simple plug-and-play module that seamlessly integrates into existing RL objectives, unexpectedly outperformed prior RL-based methods -- including GFlowNets, PPO, and REINFORCE -- by improving cross-attack success rates against GFlowNets, the previous state-of-the-art, from 0.07% to 31.28% (a relative gain greater than $400\times$) with only a 6% increase in computation.
Introduction
Red-teaming—the process of identifying prompts that elicit harmful behaviors from AI—is essential for safety but is currently bottlenecked by human effort. While researchers have attempted to automate this using Reinforcement Learning (RL), these "attacker LLMs" often suffer from mode collapse. In a fixed environment, once an attacker finds a high-reward exploit (e.g., a specific way to ask for private home addresses), it tends to stay there. Even diversity-seeking algorithms like GFlowNets often get stuck in "easy" modes of harm. The challenge is to generate a dataset of attack prompts that covers the full spectrum of risks—from violent content to privacy violations—without getting stuck in a loop of repetitive insults.
Methodology: The Active Attacks Framework
Active Attacks is a "plug-and-play" module for RL-based red-teaming that treats the victim LLM as an adaptive environment rather than a static one. The core innovation is making the environment evolve in response to the attacker's successes.
- The RL Loop: An attacker LLM (the agent) generates prompts. A victim LLM responds, and a toxicity classifier (the reward function) scores the response.
- Victim Safety Fine-tuning: Periodically (e.g., every 1,000 steps), the victim LLM is fine-tuned on the harmful prompts discovered so far. This "patches" the easy vulnerabilities.
- Reward Reshaping: Because the victim is now safer against those specific attacks, the reward for those regions drops. This forces the attacker to explore "unexplored" regions of the prompt space to find new vulnerabilities.
- Attacker Reset: After the victim is updated, the attacker LLM is re-initialized to its pre-trained state. This prevents the attacker from overfitting to old, neutralized strategies and encourages fresh exploration.
Experimental Results
The study evaluated Active Attacks using the Qwen2.5 family, Llama-3.2-3B, and Mistral-7B. To ensure safety tuning doesn't break the model, general capabilities were monitored using the Open LLM Leaderboard.
A key insight of this work is the use of Categorical Distance based on Llama Guard’s hazard categories. Traditional diversity metrics (like cosine distance of embeddings) can be misleading; an attacker might generate 100 different ways to ask for a home address that are mathematically "diverse" but semantically identical. Categorical distance ensures true semantic breadth.
Integrating Active Attacks into GFlowNets improved cross-attack success rates from 0.07% to 31.28%—a relative gain of over 400× compared to the previous state-of-the-art. Furthermore, victim models fine-tuned on prompts from Active Attacks achieved a near 100% defense rate against all other automated red-teaming methods, all while adding only 6% to total computation time.
Conclusion
By "neutralizing" easy exploits through fine-tuning, Active Attacks naturally creates an easy-to-hard curriculum. The attacker first finds simple insults, then moves to more complex policy violations as the easier paths are blocked. While currently focused on single-turn prompts, this framework provides a robust foundation for automated, adaptive safety testing of large language models.
Summary updated