GuardReasoner: Towards Reasoning-based LLM Safeguards

Yue Liu, Hongcheng Gao, Shengfang Zhai, Yufei He, Jun Xia +7 more
1/30/2025
cs.CRcs.AIcs.LG

Official code: yueliu1999/GuardReasoner (178 stars, last commit 2025-05-19).

Abstract

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/.

View on arXivView PDF

Code Implementations(1)

[ICLR Workshop 2025] An official source code for paper "GuardReasoner: Towards Reasoning-based LLM Safeguards".

17818Shell, PythonJan 27, 20251 years ago

Similar Papers

Cite this paper

@article{liu2025guardreasoner,
  title  = {GuardReasoner: Towards Reasoning-based LLM Safeguards},
  author = {Yue Liu and Hongcheng Gao and Shengfang Zhai and Yufei He and Jun Xia and Zhengyu Hu and Yulin Chen and Xihong Yang and Jiaheng Zhang and Stan Z. Li and Hui Xiong and Bryan Hooi},
  year   = {2025},
  eprint = {2501.18492},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2501.18492v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2501.18492.svg)](https://codeofpaper.com/paper/2501.18492)

Discussion