无需训练即可修复恶意微调导致的模型安全漏洞
NLSR: Neuron-Level Safety Realignment of Large Language Models Against Harmful Fine-Tuning
- 通过对比微调前后关键神经元差异,定位并替换受损部分
- 在多个任务上显著提升安全性,同时保持原有任务准确率
- 适合关注大模型安全、防御恶意微调的研究者与开发者
微调即服务的兴起暴露了大语言模型的新威胁:用户仅需上传少量恶意数据,就能隐秘地破坏模型对齐性,导致模型产生有害输出。现有防御方法多依赖高算力或梯度更新,难以实用。本文提出一种无需训练的神经元级安全重对齐框架 NLSR,其核心是构建一个初始对齐模型的安全参考模型,放大神经元中的安全特征;再利用该参考模型识别出安全关键神经元,并预先准备成补丁;最后仅对微调后相似性显著变化的神经元进行补丁移植,实现最小化修改下的安全修复。大量实验表明,该方法在多个下游任务中均显著增强模型安全性,同时维持任务性能。研究发现,部分安全关键神经元在微调后出现明显差异,可通过从参考模型移植神经元有效纠正,无需额外训练。代码将开源于 https://github.com/xinykou/NLSR。
原文摘要 · Abstract (English)
The emergence of finetuning-as-a-service has revealed a new vulnerability in large language models (LLMs). A mere handful of malicious data uploaded by users can subtly manipulate the finetuning process, resulting in an alignment-broken model. Existing methods to counteract fine-tuning attacks typically require substantial computational resources. Even with parameter-efficient techniques like LoRA, gradient updates remain essential. To address these challenges, we propose \textbf{N}euron-\textbf{L}evel \textbf{S}afety \textbf{R}ealignment (\textbf{NLSR}), a training-free framework that restores the safety of LLMs based on the similarity difference of safety-critical neurons before and after fine-tuning. The core of our framework is first to construct a safety reference model from an initially aligned model to amplify safety-related features in neurons. We then utilize this reference model to identify safety-critical neurons, which we prepare as patches. Finally, we selectively restore only those neurons that exhibit significant similarity differences by transplanting these prepared patches, thereby minimally altering the fine-tuned model. Extensive experiments demonstrate significant safety enhancements in fine-tuned models across multiple downstream tasks, while greatly maintaining task-level accuracy. Our findings suggest regions of some safety-critical neurons show noticeable differences after fine-tuning, which can be effectively corrected by transplanting neurons from the reference model without requiring additional training. The code will be available at \url{https://github.com/xinykou/NLSR}
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。