arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.12411cs.CLcs.AI
收藏

用于检测大语言模型中不安全提示词的梯度共现分析

Gradient Co-occurrence Analysis for Detecting Unsafe Prompts in Large Language Models

College of Intelligence and Computing, Tianjin University(天津大学智能与计算学部);IT Innovation and Research Center, Huawei Technologies(华为技术有限公司IT创新研究中心);Artificial Intelligence Academy, Beijing University of Posts and Telecommunications(北京邮电大学人工智能学院)

Jingyuan Yang, Bowen Yan, Rongjun Li, Ziyu Zhou, Xin Chen, Zhiyong Feng, Wei Peng

AI总结:

针对少样本梯度检测中的余弦方向偏差问题,提出GradCoo梯度共现分析方法,引入无符号梯度相似性,并在ToxicChat和XStest上取得SOTA性能。

摘要:

不安全提示词会给大语言模型(LLM)带来重大安全风险。现有的不安全提示词检测方法依赖数据驱动的微调来训练护栏模型,这需要大量数据和计算资源。相比之下,近期出现了基于梯度的少样本方法,仅需少量安全和不安全参考提示词。基于梯度的方法通过分析LLM中安全关键参数梯度的一致模式来识别不安全提示词。尽管有效,但其仅限于方向相似性(余弦相似度),这会引入“方向偏差”,从而限制其识别不安全提示词的能力。为克服这一局限,我们提出了GradCoo,这是一种新颖的梯度共现分析方法,将安全关键参数识别的范围扩展至包含无符号梯度相似性,从而降低“方向偏差”的影响并提高不安全提示词检测的准确性。在广泛使用的基准数据集ToxicChat和XStest上进行的综合实验表明,与现有方法相比,我们提出的方法能够达到最先进(SOTA)性能。此外,我们证实了GradCoo在一系列具有不同规模和来源的LLM基础模型中检测不安全提示词的泛化能力。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑