锁定微调LLMs的安全性
Locking Down the Finetuned LLMs Safety
AI总结:
本文提出SafetyLock,一种通过提取基础模型安全激活方向并应用于微调模型的对齐干预方法,在0.01秒内将有害指令响应率从60%降至1%以下,为定制LLMs提供高效、可扩展的安全保障。
摘要:
在额外数据集上微调大型语言模型(LLMs)以优化其特定下游任务往往是必要的。然而,现有的安全对齐措施(在推理期间限制有害行为)不足以缓解微调期间的安全风险。令人担忧的是,仅用10个有毒句子进行微调就能使模型遵从有害指令。我们引入了SafetyLock,一种新颖的对齐干预方法,通过高效且可迁移的机制在微调后保持稳健的安全性。SafetyLock利用了我们的发现:微调模型保留了与其基础模型相似的安全相关激活表示。这一见解使我们能够提取所谓的Meta-SafetyLock——一组安全偏置方向,代表原始模型中与安全响应相关的关键激活模式。随后可将这些方向普遍应用于微调模型以增强其安全性。通过在多个token维度搜索激活方向,SafetyLock实现了增强的稳健性和可迁移性。SafetyLock在0.01秒内重新对齐微调模型,无需额外计算成本。实验表明,SafetyLock可将有毒微调模型的有害指令响应率从60%降至1%以下。它在性能和效率上均超越传统方法,为确保定制LLMs的安全性提供了可扩展、非侵入式的解决方案。我们对各种微调场景的分析证实了SafetyLock的稳健性,提倡将其整合到对齐LLMs的安全协议中。代码发布于https://github.com/zhu-minjun/SafetyLock。
英文摘要:
Fine-tuning large language models (LLMs) on additional datasets is often necessary to optimize them for specific downstream tasks. However, existing safety alignment measures, which restrict harmful behavior during inference, are insufficient to mitigate safety risks during fine-tuning. Alarmingly, fine-tuning with just 10 toxic sentences can make models comply with harmful instructions. We introduce SafetyLock, a novel alignment intervention method that maintains robust safety post-fine-tuning through efficient and transferable mechanisms. SafetyLock leverages our discovery that fine-tuned models retain similar safety-related activation representations to their base models. This insight enables us to extract what we term the Meta-SafetyLock, a set of safety bias directions representing key activation patterns associated with safe responses in the original model. We can then apply these directions universally to fine-tuned models to enhance their safety. By searching for activation directions across multiple token dimensions, SafetyLock achieves enhanced robustness and transferability. SafetyLock re-aligns fine-tuned models in under 0.01 seconds without additional computational cost. Our experiments demonstrate that SafetyLock can reduce the harmful instruction response rate from 60% to below 1% in toxic fine-tuned models. It surpasses traditional methods in both performance and efficiency, offering a scalable, non-invasive solution for ensuring the safety of customized LLMs. Our analysis across various fine-tuning scenarios confirms SafetyLock's robustness, advocating its integration into safety protocols for aligned LLMs. The code is released at https://github.com/zhu-minjun/SafetyLock.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。