ShieldLM: Empowering LLMs as Aligned, Customizable and Explainable Safety Detectors

Zhexin Zhang, Yida Lu, Jingyuan Ma, Di Zhang, Rui Li +6 more
2/26/2024
cs.CL

Official code: thu-coai/ShieldLM (231 stars, MIT, last commit 2024-09-29).

Abstract

The safety of Large Language Models (LLMs) has gained increasing attention in recent years, but there still lacks a comprehensive approach for detecting safety issues within LLMs' responses in an aligned, customizable and explainable manner. In this paper, we propose ShieldLM, an LLM-based safety detector, which aligns with common safety standards, supports customizable detection rules, and provides explanations for its decisions. To train ShieldLM, we compile a large bilingual dataset comprising 14,387 query-response pairs, annotating the safety of responses based on various safety standards. Through extensive experiments, we demonstrate that ShieldLM surpasses strong baselines across four test sets, showcasing remarkable customizability and explainability. Besides performing well on standard detection datasets, ShieldLM has also been shown to be effective as a safety evaluator for advanced LLMs. ShieldLM is released at \url{https://github.com/thu-coai/ShieldLM} to support accurate and explainable safety detection under various safety standards.

View on arXivView PDF

Code Implementations(1)

thu-coai/ShieldLMOfficial100%
MIT

ShieldLM: Empowering LLMs as Aligned, Customizable and Explainable Safety Detectors [EMNLP 2024 Findings]

23110Shell, PythonFeb 26, 20242 years agoMIT

Similar Papers

Cite this paper

@article{zhang2024shieldlm,
  title  = {ShieldLM: Empowering LLMs as Aligned, Customizable and Explainable Safety Detectors},
  author = {Zhexin Zhang and Yida Lu and Jingyuan Ma and Di Zhang and Rui Li and Pei Ke and Hao Sun and Lei Sha and Zhifang Sui and Hongning Wang and Minlie Huang},
  year   = {2024},
  eprint = {2402.16444},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.16444v2}
}

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/2402.16444.svg)](https://codeofpaper.com/paper/2402.16444)

Discussion