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

对齐大语言模型中的安全层:LLM安全的关键

Safety Layers in Aligned Large Language Models: The Key to LLM Security

University of Science and Technology of China(中国科学技术大学);Institute of Artificial Intelligence, Hefei Comprehensive National Science Center(合肥综合性国家科学中心人工智能研究院)

Shen Li, Liuyi Yao, Lan Zhang, Yaliang Li

AI总结:

本文在参数层面揭示了对齐大语言模型的安全机制,识别出关键的安全层,并提出安全部分参数微调方法SPPFT,在微调时固定安全层梯度,以在保持性能的同时显著保留安全性并降低计算资源消耗。

摘要:

对齐后的大语言模型是安全的,能够识别并拒绝回答恶意问题。然而,内部参数在维持这种安全性方面的作用尚未被充分理解,而且这些模型在遭受微调攻击时可能面临安全性退化。为了解决这些挑战,我们的工作从参数层面揭示了对齐大语言模型的安全机制,识别出模型中间一小段连续层对区分恶意查询和正常查询至关重要,并将其称为“安全层”。我们首先通过分析模型内部层中输入向量的变化来确认这些安全层的存在。此外,我们利用过度拒绝现象和参数缩放分析来精确定位安全层。基于这些发现,我们提出了一种新颖的微调方法——安全部分参数微调(SPPFT),该方法在微调过程中固定安全层的梯度,以解决安全性退化问题。我们的实验表明,与全量微调相比,所提出的方法能够在保持性能的同时显著保留大语言模型的安全性,并减少计算资源消耗。

英文摘要:

Aligned LLMs are secure, capable of recognizing and refusing to answer malicious questions. However, the role of internal parameters in maintaining such security is not well understood yet, further these models can be vulnerable to security degradation when subjected to fine-tuning attacks. To address these challenges, our work uncovers the mechanism behind security in aligned LLMs at the parameter level, identifying a small set of contiguous layers in the middle of the model that are crucial for distinguishing malicious queries from normal ones, referred to as ``safety layers". We first confirm the existence of these safety layers by analyzing variations in input vectors within the model's internal layers. Additionally, we leverage the over-rejection phenomenon and parameters scaling analysis to precisely locate the safety layers. Building on these findings, we propose a novel fine-tuning approach, Safely Partial-Parameter Fine-Tuning (SPPFT), that fixes the gradient of the safety layers during fine-tuning to address the security degradation. Our experiments demonstrate that the proposed approach can significantly preserve LLM security while maintaining performance and reducing computational resources compared to full fine-tuning.

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

↑