Gradient Co-occurrence Analysis for Detecting Unsafe Prompts in Large Language Models
Not on the map. Why?
Abstract (arXiv)
Unsafe prompts pose significant safety risks to large language models (LLMs). Existing methods for detecting unsafe prompts rely on data-driven fine-tuning to train guardrail models, necessitating significant data and computational resources. In contrast, recent few-shot gradient-based methods emerge, requiring only few safe and unsafe reference prompts. A gradient-based approach identifies unsafe prompts by analyzing consistent patterns of the gradients of safety-critical parameters in LLMs. Although effective, its restriction to directional similarity (cosine similarity) introduces ``directional bias'', limiting its capability to identify unsafe prompts. To overcome this limitation, we introduce GradCoo, a novel gradient co-occurrence analysis method that expands the scope of safety-critical parameter identification to include unsigned gradient similarity, thereby reducing the impact of ``directional bias'' and enhancing the accuracy of unsafe prompt detection. Comprehensive experiments on the widely-used benchmark datasets ToxicChat and XStest demonstrate that our proposed method can achieve state-of-the-art (SOTA) performance compared to existing methods. Moreover, we confirm the generalizability of GradCoo in detecting unsafe prompts across a range of LLM base models with various sizes and origins.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 8 of its 21 references that are in the map. First posted on arXiv 18 Feb 2025.
Builds on
8 of 21 references.
References · 8
- 2016Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localizationcited by 6,690
- 2017Axiomatic Attribution for Deep Networkscited by 3,350
- 2023NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Railscited by 347
- 2016Not Just a Black Box: Learning Important Features Through Propagating Activation Differencescited by 295
- 2023ToxicChat: Unveiling Hidden Challenges of Toxicity Detection in Real-World User-AI Conversationcited by 224
- 2020HateBERT: Retraining BERT for Abusive Language Detection in Englishcited by 206
- 2024Llama Guard 3 Vision: Safeguarding Human-AI Image Understanding Conversationscited by 118
- 2024ShieldLM: Empowering LLMs as Aligned, Customizable and Explainable Safety Detectorscited by 48
Built on by
Not cited yet.