开口前先发现风险!揭示大型视觉语言模型中的安全注意力头
Spot Risks Before Speaking! Unraveling Safety Attention Heads in Large Vision-Language Models
AI总结:
本文发现LVLMs中存在稀疏“安全头”可在首token生成时感知恶意提示,并基于其激活构建轻量逻辑回归检测器,实现强零样本攻击检测且不损害模型效用。
摘要:
随着额外模态的融入,大型视觉语言模型(LVLMs)相比仅基于语言的前代模型,表现出对安全风险(例如越狱攻击)更高的脆弱性。尽管近期研究已在LVLMs的事后对齐方面投入大量精力,但其内部安全机制在很大程度上仍未得到探索。本文发现,LVLMs在首个token生成期间的内部激活能够有效识别不同攻击中的恶意提示。这种内在安全感知由稀疏的注意力头支配,我们将其称为“安全头”。进一步分析表明,这些头充当抵御恶意提示的专门护盾;消融它们会导致更高的攻击成功率,而模型效用仍不受影响。通过定位这些安全头并拼接其激活,我们构建了一个简单但强大的恶意提示检测器,它能以极小的额外推理开销无缝集成到生成过程中。尽管该检测器仅采用逻辑回归模型的简单结构,却令人惊讶地展现出强大的零样本泛化能力。跨多种基于提示的攻击的实验证实了利用安全头保护LVLMs的有效性。代码位于https://github.com/Ziwei-Zheng/SAHs。
英文摘要:
With the integration of an additional modality, large vision-language models (LVLMs) exhibit greater vulnerability to safety risks (e.g., jailbreaking) compared to their language-only predecessors. Although recent studies have devoted considerable effort to the post-hoc alignment of LVLMs, the inner safety mechanisms remain largely unexplored. In this paper, we discover that internal activations of LVLMs during the first token generation can effectively identify malicious prompts across different attacks. This inherent safety perception is governed by sparse attention heads, which we term ``safety heads." Further analysis reveals that these heads act as specialized shields against malicious prompts; ablating them leads to higher attack success rates, while the model's utility remains unaffected. By locating these safety heads and concatenating their activations, we construct a straightforward but powerful malicious prompt detector that integrates seamlessly into the generation process with minimal extra inference overhead. Despite its simple structure of a logistic regression model, the detector surprisingly exhibits strong zero-shot generalization capabilities. Experiments across various prompt-based attacks confirm the effectiveness of leveraging safety heads to protect LVLMs. Code is available at \url{https://github.com/Ziwei-Zheng/SAHs}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。