Lune

ACL2024Top-tier venue

SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decoding

Zhangchen Xu, Fengqing Jiang, Luyao Niu, Jinyuan Jia, Bill Yuchen Lin, Radha Poovendran

Abstract

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, which aim to provoke unintended and unsafe behaviors from LLMs, remain a significant LLM safety threat. We analyze tokens, which are the smallest unit of text that can be processed by LLMs and make the following observations: (1) probabilities of tokens representing harmful responses are higher than those of harmless responses, and (2) responses containing safety disclaimers appear among the top tokens when token probabilities are sorted in descending order. In this paper, we leverage (1) and (2) to develop SafeDecoding, a safety-aware decoding strategy for LLMs, to defend against jailbreak attacks. We perform extensive experiments to evaluate SafeDecoding against six SOTA jailbreak attacks (GCG, AutoDAN, PAIR, DeepInception, SAP30, and template-based attack) on five LLMs (Vicuna, Llama2, Guanaco, falcon, and Dolphin) using four benchmark datasets (AdvBench, HEx-PHI, MT-Bench, and Just-Eval). Our results show that SafeDecoding significantly reduces attack success rate and harmfulness of jailbreak attacks without compromising the helpfulness of responses to benign user queries while outperforming six defense methods (Perpelexity, Paraphrase, Retokenization, Self-Reminder, ICD, and Self-Examination).

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

89 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher cites How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs
  • How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs cites GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher
  • GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher cites Training language models to follow instructions with human feedback
  • ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs cites Training language models to follow instructions with human feedback
  • LLMs know their vulnerabilities: Uncover Safety Gaps through Natural Distribution Shifts cites How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs
  • QLoRA: Efficient Finetuning of Quantized LLMs cites Training language models to follow instructions with human feedback
  • Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal Training cites Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!
  • Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal Training cites How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs
  • Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal Training cites Training language models to follow instructions with human feedback
  • Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To! cites Training language models to follow instructions with human feedback
  • Mission Impossible: A Statistical Perspective on Jailbreaking LLMs cites GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher
  • Mission Impossible: A Statistical Perspective on Jailbreaking LLMs cites Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!
  • Mission Impossible: A Statistical Perspective on Jailbreaking LLMs cites How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs
  • Mission Impossible: A Statistical Perspective on Jailbreaking LLMs cites Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attacks
  • Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attacks cites How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMs
  • Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attacks cites Training language models to follow instructions with human feedback
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers89

  1. GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via CipherYouliang Yuan, Wenxiang Jiao, Wenxuan Wang, Jen-tse Huang et al.ICLR 2024 · 441 citations
  2. Refuse Whenever You Feel Unsafe: Improving Safety in LLMs via Decoupled Refusal TrainingYouliang Yuan, Wenxiang Jiao, Wenxuan Wang, Jen-tse Huang et al.ACL 2025 · 65 citations
  3. LLMs know their vulnerabilities: Uncover Safety Gaps through Natural Distribution ShiftsQibing Ren, Hao Li, Dongrui Liu, Zhanxu Xie et al.ACL 2025 · 53 citations
  4. Mission Impossible: A Statistical Perspective on Jailbreaking LLMsJingtong Su, Julia Kempe, Karen UllrichNeurIPS 2024 · 38 citations
  5. ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMsFengqing Jiang, Zhangchen Xu, Luyao Niu, Zhen Xiang et al.ACL 2024 · 36 citations

Builds on8

  1. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  2. QLoRA: Efficient Finetuning of Quantized LLMsTim Dettmers, Artidoro Pagnoni, Ari Holtzman, Luke ZettlemoyerNeurIPS 2023 · 5,863 citations
  3. Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!Xiangyu Qi, Yi Zeng, Tinghao Xie, Pin-Yu Chen et al.ICLR 2024 · 1,104 citations
  4. Robust Prompt Optimization for Defending Language Models Against Jailbreaking AttacksAndy Zhou, Bo Li, Haohan WangNeurIPS 2024 · 198 citations
  5. How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMsYi Zeng, Hongpeng Lin, Jingwen Zhang, Diyi Yang et al.ACL 2024 · 64 citations

Related papers

  1. Safety Guardrails of Large Language Models Are Vulnerable to Value-Driven Adversarial PromptingXiaohao Luo, Ying Wei, Zhijun LiACL Findings 2026
  2. Why Not Act on What You Know? Unleashing Safety Potential of LLMs via Self-Aware Guard EnhancementPeng Ding, Jun Kuang, Zongyu Wang, Xuezhi Cao et al.ACL Findings 2025
  3. Catastrophic Jailbreak of Open-source LLMs via Exploiting GenerationYangsibo Huang, Samyak Gupta, Mengzhou Xia, Kai Li et al.ICLR 2024 · 481 citations
  4. SecDecoding: Steerable Decoding for Safer LLM GenerationJiayou Wang, Rundong Liu, Yue Hu, Huijia Wu et al.EMNLP Findings 2025
  5. A Comprehensive Study of Jailbreak Attack versus Defense for Large Language ModelsZihao Xu, Yi Liu, Gelei Deng, Yuekang Li et al.ACL Findings 2024 · 69 citations
Dusk over the sea between two cliffs drawn in fine vertical lines