Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal Training

Youliang Yuan, Wenxiang Jiao, Wenxuan Wang, Jen-tse Huang, Jiahao Xu +3 more
7/12/2024
cs.CLcs.AI

No official code found. Best implementation: RobustNLP/DeRTa (72 stars, MIT, last commit 2025-05-22).

Abstract

This study addresses a critical gap in safety tuning practices for Large Language Models (LLMs) by identifying and tackling a refusal position bias within safety tuning data, which compromises the models' ability to appropriately refuse generating unsafe content. We introduce a novel approach, Decoupled Refusal Training (DeRTa), designed to empower LLMs to refuse compliance to harmful prompts at any response position, significantly enhancing their safety capabilities. DeRTa incorporates two novel components: (1) Maximum Likelihood Estimation (MLE) with Harmful Response Prefix, which trains models to recognize and avoid unsafe content by appending a segment of harmful response to the beginning of a safe response, and (2) Reinforced Transition Optimization (RTO), which equips models with the ability to transition from potential harm to safety refusal consistently throughout the harmful response sequence. Our empirical evaluation, conducted using LLaMA3 and Mistral model families across six attack scenarios, demonstrates that our method not only improves model safety without compromising performance but also surpasses baseline methods in defending against attacks.

View on arXivView PDF

Code Implementations(1)

RobustNLP/DeRTaCommunity100%
MIT

A novel approach to improve the safety of large language models, enabling them to transition effectively from unsafe to safe state.

722Shell, PythonJun 18, 20241 years agoMIT
chatgptdefensejailbreakllm

Similar Papers

Cite this paper

@article{yuan2024refuse,
  title  = {Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal Training},
  author = {Youliang Yuan and Wenxiang Jiao and Wenxuan Wang and Jen-tse Huang and Jiahao Xu and Tian Liang and Pinjia He and Zhaopeng Tu},
  year   = {2024},
  eprint = {2407.09121},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.09121v2}
}

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

Discussion