GuardReasoner: Towards Reasoning-based LLM Safeguards
About
As LLMs increasingly impact safety-critical applications, ensuring their safety using guardrails remains a key challenge. This paper proposes GuardReasoner, a new safeguard for LLMs, by guiding the guard model to learn to reason. Concretely, we first create the GuardReasonerTrain dataset, which consists of 127K samples with 460K detailed reasoning steps. Then, we introduce reasoning SFT to unlock the reasoning capability of guard models. In addition, we present hard sample DPO to further strengthen their reasoning ability. In this manner, GuardReasoner achieves better performance, explainability, and generalizability. Extensive experiments and analyses on 13 benchmarks of 3 guardrail tasks demonstrate its superiority. Remarkably, GuardReasoner 8B surpasses GPT-4o+CoT by 5.74% and LLaMA Guard 3 8B by 20.84% F1 score on average. We release the training data, code, and models with different scales (1B, 3B, 8B) of GuardReasoner : https://github.com/yueliu1999/GuardReasoner/.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Response Harmfulness Detection | HarmBench | F1 Score96.31 | 100 | |
| Response Harmfulness Detection | XSTEST-RESP | Response Harmfulness F194.34 | 76 | |
| Response Harmfulness Detection | Beavertails | F1 Score87.6 | 59 | |
| Safety Classification | SafeRLHF | F1 Score0.7004 | 48 | |
| Harmfulness Detection | WildGuard | Macro F1 Score89.17 | 47 | |
| Toxicity Detection | ToxicChat | F1 Score0.7879 | 45 | |
| Harmfulness Detection | OpenAI Moderation | Macro F1 Score72 | 45 | |
| Prompt Harmfulness Detection | AegisSafety (test) | F1 Score91.39 | 41 | |
| Response Harmfulness Detection | SafeRLHF | F1 Score70.04 | 41 | |
| Response Classification | BeaverTails V Text-Image Response | F1 Score84.02 | 39 |