Curiosity-driven Red teaming for Large Language Models

Zhang-Wei Hong, Idan Shenfeld, Tsun-Hsuan Wang, Yung-Sung Chuang, Aldo Pareja, James R. Glass, Akash Srivastava, Pulkit Agrawal · DOI

Abstract

As Large Language Models (LLMs) are increasingly integrated into consumer applications, ensuring their safety against toxic or biased outputs is paramount. While automated red teaming via Reinforcement Learning (RL) offers a scalable alternative to human testing, standard RL methods often suffer from "mode collapse," repeatedly generating a narrow set of successful triggers. This paper introduces Curiosity-driven Red Teaming (CRT), an approach that incentivizes the discovery of novel and diverse prompts. By incorporating entropy bonuses and textual/semantic novelty rewards, CRT achieves significantly higher coverage of model vulnerabilities. Experimental results demonstrate that CRT can elicit toxic responses even from safety-aligned models like LLaMA2-7b-chat, identifying hundreds of vulnerabilities missed by traditional methods.

1. Introduction

The deployment of Large Language Models (LLMs) necessitates rigorous safety evaluations to prevent the generation of harmful content. Red teaming—the process of intentionally prompting a model to trigger undesirable behavior—is the primary method for identifying these risks. However, manual red teaming is resource-intensive and difficult to scale. Automated red teaming using Reinforcement Learning (RL) has emerged as a promising alternative, yet it is often plagued by a lack of diversity. Once an RL agent finds a prompt that successfully elicits a toxic response, it tends to exploit that specific "mode," failing to explore the broader landscape of potential failures. This results in low coverage and leaves many vulnerabilities undiscovered.

2. Curiosity-driven Red Teaming (CRT)

To address the limitation of mode collapse, we propose Curiosity-driven Red Teaming (CRT). The core innovation lies in the reward function, which balances the objective of eliciting toxicity with a "curiosity" mechanism that rewards the generation of novel prompts.

The CRT framework augments the standard RL objective with three specific components designed to promote exploration:

  1. Entropy Bonus: This encourages the red-team model to maintain a degree of randomness in its output distribution, preventing it from becoming overly deterministic.
  2. Textual Novelty ($B_{SelfBLEU}$): This reward penalizes the model for generating prompts with high n-gram overlap with previously generated successful attacks. It ensures that the model varies its word choice and phrasing.
  3. Semantic Novelty ($B_{Cos}$): To prevent the model from simply using synonyms to bypass textual diversity metrics, this reward utilizes sentence embeddings to measure the semantic distance between prompts. The model is rewarded for finding prompts that are conceptually distinct from those already discovered.

By integrating these rewards, the CRT agent is incentivized to seek out "blind spots" across the entire input space rather than converging on a single known vulnerability.

3. Experimental Framework

The effectiveness of CRT was evaluated across various tasks and target models:

  • Tasks and Datasets: The study utilized the IMDb review dataset for text continuation tasks and the Alpaca and Databricks Dolly-15K datasets for instruction-following scenarios.
  • Target Models: Attacks were launched against GPT-2, Dolly-v2-7B, and the safety-aligned LLaMA2-7b-chat.
  • Evaluation: Toxicity was quantified using a RoBERTa-based hate speech classifier and cross-validated using GPT-4 as a judge.

4. Results and Discussion

4.1. Coverage and Diversity

CRT demonstrated a superior ability to map the vulnerability surface of LLMs compared to standard RL baselines. In tests against Dolly-v2-7B, CRT generated approximately 50,000 unique successful test cases, whereas the standard RL baseline collapsed to fewer than 500. Furthermore, CRT consistently outperformed baselines on both SelfBLEU and embedding distance metrics, maintaining high diversity even as the toxicity threshold for "success" was increased.

4.2. Challenging Safety-Aligned Models

The most significant finding was CRT's performance against LLaMA2-7b-chat. Despite LLaMA2's extensive safety alignment via Reinforcement Learning from Human Feedback (RLHF), CRT identified 196 prompts that elicited toxic responses, with some toxicity probabilities reaching as high as 94%. In contrast, a pilot study with 16 human participants failed to produce a single prompt that elicited a toxicity score above 0.5 from the same model. This suggests that automated curiosity-driven exploration can uncover edge cases that are non-obvious to human testers.

4.3. The Synergy of Exploration and Exploitation

A key insight from this research is that optimizing for novelty does not detract from the primary goal of finding toxic outputs. In fact, by exploring a wider range of the input space, CRT often discovers more effective and higher-toxicity triggers that a standard, exploitative RL agent would never encounter. Diversity is multi-faceted; the paper shows that relying on just one type of novelty reward (textual or semantic) allows the model to find loopholes, whereas combining them forces true exploration.

5. Limitations and Future Work

While CRT represents a significant step forward, it is not without limitations. The weights for the novelty rewards currently require manual tuning, which can be sensitive to the specific task. Future research could explore adaptive weighting schemes to automate this balance. Additionally, the model occasionally generates "gibberish" or incomplete prompts that happen to trigger toxicity; while these reveal technical vulnerabilities, they may not always reflect realistic user interactions. Finally, training a separate RL model for every target LLM remains computationally expensive.

6. Conclusion

Curiosity-driven Red Teaming provides a robust framework for systematically identifying vulnerabilities in LLMs. By prioritizing diversity and exploration, CRT moves beyond simple "jailbreaking" toward a more comprehensive understanding of model safety, offering a powerful tool for developers to harden their models before deployment.

Summary updated

BibTeX
@inproceedings{hong2024curiosity,
  author = {Zhang-Wei Hong and Idan Shenfeld and Tsun-Hsuan Wang and Yung-Sung Chuang and Aldo Pareja and James R. Glass and Akash Srivastava and Pulkit Agrawal},
  title = {{Curiosity-driven Red teaming for Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=4KqkizXgXU},
}
Figure