SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decoding

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Xu, Zhangchen, Jiang, Fengqing, Niu, Luyao, Jia, Jinyuan, Lin, Bill Yuchen, Poovendran, Radha
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866929437822418944
author Xu, Zhangchen
Jiang, Fengqing
Niu, Luyao
Jia, Jinyuan
Lin, Bill Yuchen
Poovendran, Radha
author_facet Xu, Zhangchen
Jiang, Fengqing
Niu, Luyao
Jia, Jinyuan
Lin, Bill Yuchen
Poovendran, Radha
contents As large language models (LLMs) become increasingly integrated into real-world applications such as code generation and chatbot assistance, extensive efforts have been made to align LLM behavior with human values, including safety. Jailbreak attacks, aiming to provoke unintended and unsafe behaviors from LLMs, remain a significant/leading LLM safety threat. In this paper, we aim to defend LLMs against jailbreak attacks by introducing SafeDecoding, a safety-aware decoding strategy for LLMs to generate helpful and harmless responses to user queries. Our insight in developing SafeDecoding is based on the observation that, even though probabilities of tokens representing harmful contents outweigh those representing harmless responses, safety disclaimers still appear among the top tokens after sorting tokens by probability in descending order. This allows us to mitigate jailbreak attacks by identifying safety disclaimers and amplifying their token probabilities, while simultaneously attenuating the probabilities of token sequences that are aligned with the objectives of jailbreak attacks. We perform extensive experiments on five LLMs using six state-of-the-art jailbreak attacks and four benchmark datasets. Our results show that SafeDecoding significantly reduces the attack success rate and harmfulness of jailbreak attacks without compromising the helpfulness of responses to benign user queries. SafeDecoding outperforms six defense methods.
format Preprint
id arxiv_https___arxiv_org_abs_2402_08983
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decoding
Xu, Zhangchen
Jiang, Fengqing
Niu, Luyao
Jia, Jinyuan
Lin, Bill Yuchen
Poovendran, Radha
Cryptography and Security
Artificial Intelligence
Computation and Language
As large language models (LLMs) become increasingly integrated into real-world applications such as code generation and chatbot assistance, extensive efforts have been made to align LLM behavior with human values, including safety. Jailbreak attacks, aiming to provoke unintended and unsafe behaviors from LLMs, remain a significant/leading LLM safety threat. In this paper, we aim to defend LLMs against jailbreak attacks by introducing SafeDecoding, a safety-aware decoding strategy for LLMs to generate helpful and harmless responses to user queries. Our insight in developing SafeDecoding is based on the observation that, even though probabilities of tokens representing harmful contents outweigh those representing harmless responses, safety disclaimers still appear among the top tokens after sorting tokens by probability in descending order. This allows us to mitigate jailbreak attacks by identifying safety disclaimers and amplifying their token probabilities, while simultaneously attenuating the probabilities of token sequences that are aligned with the objectives of jailbreak attacks. We perform extensive experiments on five LLMs using six state-of-the-art jailbreak attacks and four benchmark datasets. Our results show that SafeDecoding significantly reduces the attack success rate and harmfulness of jailbreak attacks without compromising the helpfulness of responses to benign user queries. SafeDecoding outperforms six defense methods.
title SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decoding
topic Cryptography and Security
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2402.08983