Tiny Refinements Elicit Resilience: Toward Efficient Prefix-Model Against LLM Red-Teaming

Jiaxu Liu, Xiangyu Yin, Sihao Wu, Jianhong Wang, Meng Fang, Xinping Yi, Xiaowei HuangarXiv 2024 · DOI

Introduction: The Challenge of LLM Safety

As Large Language Models (LLMs) become more integrated into society, "red-teaming"—the practice of finding prompts that trigger harmful, biased, or toxic outputs—has become a critical area of safety research. However, defending against these attacks is difficult for two main reasons. First, traditional defense methods often involve fine-tuning the entire "victim" model, which is computationally ruinous for models with 70B+ parameters. Second, many powerful models are only accessible via API, meaning defenders cannot modify their internal weights.

The LLM-based Sentinel: A Lightweight Defense

The authors propose a way to defend these "black-box" models by intercepting the attack at the prompt level, essentially "steering" the model back toward safety before it even begins generating a response. The core of the paper is the LLM-based Sentinel, a small model (e.g., GPT-2 or TinyLlama) that acts as a protective layer.

Overview of the Sentinel model workflow for text and image generation.

When a potentially toxic prompt arrives, the Sentinel generates a short sequence of tokens (a "prefix") that is appended to the prompt. This combined input then goes to the target LLM. This tiny change in context—less than 30 tokens—is enough to override an adversarial prompt without changing the target model's weights.

Adversarial Training and Stability

The authors model the interaction as a two-player Stackelberg game. A "Red Team" model (the leader) tries to find prompts that maximize toxicity, while the Sentinel (the follower) learns to minimize that toxicity.

Optimization process for the Red Team and Sentinel agents using PPO.

Training two competing agents using Reinforcement Learning (PPO) is notoriously unstable. To fix this, the authors introduced a "Partially Shared" mechanism. While each agent has its own policy, their "critics" (the parts of the algorithm that judge performance) share information through auxiliary encoders. This provides the agents with a more "global" view of the environment, stabilizing the training process. Toxicity is measured using a pre-trained RoBERTa-based classifier, which provides the reward signal for the RL loop.

Key Results and Insights

The researchers evaluated their framework across several domains, including text continuation (IMDB), instruction following (Alpaca), and text-to-image generation (Stable Diffusion).

  • Dramatic Toxicity Reduction: In experiments against GPT-3.5-Turbo, prompts that previously elicited toxic responses with ~96.8% probability were neutralized to just 0.1% probability after the Sentinel's intervention.
  • Efficiency: For a 6B parameter model, using a 125M Sentinel prefix-model actually resulted in lower toxicity scores (0.1240) than fine-tuning the 6B model itself (0.1510).
  • Cross-Modal Success: The Sentinel successfully prevented Stable Diffusion 2.1 from generating NSFW images, even when the input prompt was specifically designed to trigger them.
  • Preserving Utility: Using the DeepEval framework, the authors showed that the Sentinel generally maintains the "Correctness" and "Answer Relevancy" of the target LLM, though a slight performance dip was noted in the largest models like Llama-2-7B.

Conclusion and Future Directions

The "Sentinel" acts as a universal adapter. Because it only modifies the input text, it is model-agnostic, protecting models of any size with the same lightweight architecture. While the Sentinel can sometimes introduce minor "noise" into the prompt, it represents a significant step toward efficient, dynamic AI safety. Future work will explore expanding the safety scope beyond toxicity and testing the transferability of Sentinels across different model architectures.

Summary updated

BibTeX
@misc{liu2024tiny,
  author = {Jiaxu Liu and Xiangyu Yin and Sihao Wu and Jianhong Wang and Meng Fang and Xinping Yi and Xiaowei Huang},
  title = {{Tiny Refinements Elicit Resilience: Toward Efficient Prefix-Model Against LLM Red-Teaming}},
  year = {2024},
  eprint = {2405.12604},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.12604},
}
Figure