Why Not Act on What You Know? Unleashing Safety Potential of LLMs via Self-Aware Guard Enhancement

Peng Ding, Jun Kuang, Zongyu Wang, Xuezhi Cao, Xunliang Cai +2 more
5/17/2025
cs.CL

Official code: NJUNLP/SAGE (10 stars, MIT, last commit 2025-08-26).

Abstract

Large Language Models (LLMs) have shown impressive capabilities across various tasks but remain vulnerable to meticulously crafted jailbreak attacks. In this paper, we identify a critical safety gap: while LLMs are adept at detecting jailbreak prompts, they often produce unsafe responses when directly processing these inputs. Inspired by this insight, we propose SAGE (Self-Aware Guard Enhancement), a training-free defense strategy designed to align LLMs' strong safety discrimination performance with their relatively weaker safety generation ability. SAGE consists of two core components: a Discriminative Analysis Module and a Discriminative Response Module, enhancing resilience against sophisticated jailbreak attempts through flexible safety discrimination instructions. Extensive experiments demonstrate SAGE's effectiveness and robustness across various open-source and closed-source LLMs of different sizes and architectures, achieving an average 99% defense success rate against numerous complex and covert jailbreak methods while maintaining helpfulness on general benchmarks. We further conduct mechanistic interpretability analysis through hidden states and attention distributions, revealing the underlying mechanisms of this detection-generation discrepancy. Our work thus contributes to developing future LLMs with coherent safety awareness and generation behavior. Our code and datasets are publicly available at https://github.com/NJUNLP/SAGE.

View on arXivView PDF

Code Implementations(1)

NJUNLP/SAGEOfficial100%
MIT

The official implementation of our ACL 2025 paper "Why Not Act on What You Know? Unleashing Safety Potential of LLMs via Self-Aware Guard Enhancement".

101PythonMay 17, 20251 years agoMIT

Similar Papers

Cite this paper

@article{ding2025what,
  title  = {Why Not Act on What You Know? Unleashing Safety Potential of LLMs via Self-Aware Guard Enhancement},
  author = {Peng Ding and Jun Kuang and Zongyu Wang and Xuezhi Cao and Xunliang Cai and Jiajun Chen and Shujian Huang},
  year   = {2025},
  eprint = {2505.12060},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.12060v1}
}

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

Discussion