用随机扰动修复大模型有害微调,既保安全又不丢性能。
Panacea: Mitigating Harmful Fine-tuning for Large Language Models via Post-fine-tuning Perturbation
- 微调后加自适应扰动,自动恢复模型安全
- 有害行为平均降低21.2%,微调性能基本不变
- 适合关注模型安全的开发者与研究者
有害微调攻击对大语言模型微调服务构成严重安全威胁。主流防御方法旨在提前‘疫苗接种’模型以增强抗性,但我们的评估显示其仍脆弱——仅需少量微调步骤,模型仍可习得有害知识。进一步实验发现,一个看似简单的方法——在微调后添加纯随机扰动,即可有效消除有害行为,尽管会轻微降低微调性能。为此,我们提出Panacea,通过优化一种自适应扰动,在微调后施加于模型,既能保持安全对齐效果,又不损害下游微调性能。在不同有害比例、任务及主流LLM上的综合实验表明,平均有害得分降低高达21.2%,同时维持良好微调表现。作为副产品,我们分析了自适应扰动,发现不同层在各模型中具有不同的安全亲和性,与多项前期研究结果一致。代码已开源:https://github.com/w-yibo/Panacea。
原文摘要 · Abstract (English)
Harmful fine-tuning attack introduces significant security risks to the fine-tuning services. Main-stream defenses aim to vaccinate the model such that the later harmful fine-tuning attack is less effective. However, our evaluation results show that such defenses are fragile--with a few fine-tuning steps, the model still can learn the harmful knowledge. To this end, we do further experiment and find that an embarrassingly simple solution--adding purely random perturbations to the fine-tuned model, can recover the model from harmful behaviors, though it leads to a degradation in the model's fine-tuning performance. To address the degradation of fine-tuning performance, we further propose Panacea, which optimizes an adaptive perturbation that will be applied to the model after fine-tuning. Panacea maintains model's safety alignment performance without compromising downstream fine-tuning performance. Comprehensive experiments are conducted on different harmful ratios, fine-tuning tasks and mainstream LLMs, where the average harmful scores are reduced by up-to 21.2%, while maintaining fine-tuning performance. As a by-product, we analyze the adaptive perturbation and show that different layers in various LLMs have distinct safety affinity, which coincide with finding from several previous study. Source code available at https://github.com/w-yibo/Panacea.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。