paper-with-me

홈 › Papers

GradSafe: Detecting Jailbreak Prompts for LLMs via Safety-Critical Gradient Analysis

2024-02-21 · Yueqi Xie, Minghong Fang, Renjie Pi, Neil Gong

Large Language Models (LLMs) face threats from jailbreak prompts. Existing methods for detecting jailbreak prompts are primarily online moderation APIs or finetuned LLMs. These strategies, however, often require extensive and resource-intensive data collection and training processes. In this study, we propose GradSafe, which effectively detects jailbreak prompts by scrutinizing the gradients of safety-critical parameters in LLMs. Our method is grounded in a pivotal observation: the gradients of an LLM's loss for jailbreak prompts paired with compliance response exhibit similar patterns on certain safety-critical parameters. In contrast, safe prompts lead to different gradient patterns. Building on this observation, GradSafe analyzes the gradients from prompts (paired with compliance responses) to accurately detect jailbreak prompts. We show that GradSafe, applied to Llama-2 without further training, outperforms Llama Guard, despite its extensive finetuning with a large dataset, in detecting jailbreak prompts. This superior performance is consistent across both zero-shot and adaptation scenarios, as evidenced by our evaluations on ToxicChat and XSTest. The source code is available at https://github.com/xyq7/GradSafe.

📄 PDF Abstract BibTeX arXiv:2402.13494

Code (1)

xyq7/gradsafe 공식 구현 pytorch

Similar Papers 제목 키워드 기반

Gradient-Controlled Decoding: A Safety Guardrail for LLMs with Dual-Anchor Steering

2026-04-06 · Purva Chiniya, Kevin Scaria, Sagar Chaturvedi arxiv

Large language models (LLMs) remain susceptible to jailbreak and direct prompt-injection attacks, yet the strongest defensive filters frequently over-refuse benign queries and degrade user experience. Previous work on ja…

Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editing

2024-05-28 · Wei Zhao, Zhe Li, Yige Li, Ye Zhang 외

Large language models (LLMs) are increasingly being adopted in a wide range of real-world applications. Despite their impressive performance, recent studies have shown that LLMs are vulnerable to deliberately crafted adv…

Steering Dialogue Dynamics for Robustness against Multi-turn Jailbreaking Attacks

2025-02-28 · Hanjiang Hu, Alexander Robey, Changliu Liu

Large language models (LLMs) are highly vulnerable to jailbreaking attacks, wherein adversarial prompts are designed to elicit harmful responses. While existing defenses effectively mitigate single-turn attacks by detect…

Safety Alignment

Does Safety Training of LLMs Generalize to Semantically Related Natural Prompts?

2024-12-04 · Sravanti Addepalli, Yerram Varun, Arun Suggala, Karthikeyan Shanmugam 외

Large Language Models (LLMs) are known to be susceptible to crafted adversarial attacks or jailbreaks that lead to the generation of objectionable content despite being aligned to human preferences using safety fine-tuni…

Adversarial Attack

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

2025-05-17 · Peng Ding, Jun Kuang, ZongYu Wang, Xuezhi Cao 외

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…