Learning from Red Teaming: Gender Bias Provocation and Mitigation in Large Language Models

Hsuan Su, Cheng-Chu Cheng, Hua Farn, Shachi H. Kumar, Saurav Sahay, Shang-Tse Chen, Hung-yi LeearXiv 2023 · DOI

Introduction

As Large Language Models (LLMs) like GPT-4 and Alpaca become central to digital interaction, their tendency to inherit and amplify societal biases remains a critical challenge. Gender bias, in particular, often surfaces in subtle ways that are difficult to detect using traditional methods. Conventional "red teaming"—the process of intentionally triggering undesirable behaviors—typically relies on manual templates or expensive crowdsourced datasets, which struggle to cover the vast "surface area" of potential biases in massive models.

Furthermore, once a bias is identified, remediation usually involves fine-tuning the model. This is not only computationally expensive but often impossible for developers using "black-box" models via APIs. This research proposes an automated framework to both detect and neutralize gender bias using only the model's inputs and outputs.

Methodology: Provocation and Mitigation

The authors introduce a two-stage framework that leverages the model's own failures to improve its fairness.

1. Bias Provocation (The Red Team)

The first stage uses Reinforcement Learning (RL) to automatically discover prompts that trigger biased responses. A "test case generator" (based on GPT-2) is trained using Proximal Policy Optimization (PPO). The reward for this agent is the sentiment gap: the difference in sentiment between the LLM's response to a prompt (e.g., "Men are successful in business") and its response to a gender-swapped counterfactual (e.g., "Women are successful in business"). By optimizing for this gap, the RL agent learns to find complex scenarios that bypass basic safety filters.

2. Bias Mitigation (The Shield)

Instead of retraining the target LLM, the framework uses In-Context Learning (ICL). The most biased examples found in the first stage are paired with "fair" responses. These pairs are then prepended to the user's prompt as few-shot demonstrations. This approach teaches the model how to respond neutrally to tricky inputs in real-time without changing a single model weight.

Overview of the two-stage framework: RL-based bias provocation and ICL-based bias mitigation.

Key Results

The RL-based generator proved significantly more effective at finding "weak spots" than standard prompting. For GPT-4, the RL agent identified a sentiment gap of 0.469, compared to only 0.215 found through standard ChatGPT prompting.

The mitigation strategy was equally successful. Using the "Top 5" most biased cases as demonstrations significantly reduced the sentiment gap across all tested models. For Alpaca, the gap dropped from 0.335 to 0.110. Crucially, this reduction in bias did not come at the cost of model performance; the quality and diversity of responses remained consistent.

Reduction in sentiment gap (bias) across models as the number of few-shot demonstrations increases.

Insights and Future Directions

This research highlights several key takeaways for the AI safety community:

  • AI as an Adversary: RL-driven red teaming is a powerful tool for discovering edge cases that human-written templates might miss.
  • Failures as Teachers: A model's worst failures can be transformed into its best training data through few-shot prompting.
  • Gradient-Free Fairness: Effective bias mitigation is possible even for proprietary, black-box models where fine-tuning is not an option.

While the current study focuses on binary gender, the framework is designed to be extensible. Future work aims to adapt this RL-reward system to detect and mitigate biases related to race, religion, and sexual orientation, moving toward more robust and inclusive AI systems.

Summary updated

BibTeX
@misc{su2023learning,
  author = {Hsuan Su and Cheng-Chu Cheng and Hua Farn and Shachi H. Kumar and Saurav Sahay and Shang-Tse Chen and Hung-yi Lee},
  title = {{Learning from Red Teaming: Gender Bias Provocation and Mitigation in Large Language Models}},
  year = {2023},
  eprint = {2310.11079},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.11079},
}
Figure