Safe LoRA:降低大语言模型微调安全风险的一线希望
Safe LoRA: the Silver Lining of Reducing Safety Risks when Fine-tuning Large Language Models
AI总结:
本文提出 Safe LoRA,通过把选定层的 LoRA 权重投影到安全对齐子空间,在无需训练和数据的情况下降低 LLM 微调风险并保持任务性能。
摘要:
尽管 Llama-2 或 GPT-4 等大语言模型(LLM)已展现出令人瞩目的零样本性能,但为了提升其在定制数据集、特定领域任务或其他私有需求上的表现,微调仍然是必要的。然而,微调 LLM 的全部参数需要大量硬件资源,这对普通用户而言可能并不现实。因此,LoRA 等参数高效微调方法应运而生,使用户无需大量计算资源即可微调 LLM,并且与全参数微调相比性能下降很小。遗憾的是,近期研究表明,即使数据中不包含恶意内容,微调也可能增加 LLM 的安全风险。为应对这一挑战,我们提出了 Safe LoRA,这是对原始 LoRA 实现的一个简单一行代码补丁,通过将所选层的 LoRA 权重投影到安全对齐子空间,在保持效用的同时有效降低 LLM 微调中的安全风险。值得注意的是,Safe LoRA 是一种无需训练且无需数据的方法,因为它只需要知道基座 LLM 和对齐 LLM 的权重。我们的大量实验表明,在纯恶意数据上进行微调时,Safe LoRA 保持了与原始对齐模型相近的安全性能。此外,当微调数据集同时包含良性和恶意数据时,Safe LoRA 减轻了恶意数据造成的负面影响,同时保留了下游任务性能。我们的代码可在 https://github.com/IBM/SafeLoRA 获取。
英文摘要:
While large language models (LLMs) such as Llama-2 or GPT-4 have shown impressive zero-shot performance, fine-tuning is still necessary to enhance their performance for customized datasets, domain-specific tasks, or other private needs. However, fine-tuning all parameters of LLMs requires significant hardware resources, which can be impractical for typical users. Therefore, parameter-efficient fine-tuning such as LoRA have emerged, allowing users to fine-tune LLMs without the need for considerable computing resources, with little performance degradation compared to fine-tuning all parameters. Unfortunately, recent studies indicate that fine-tuning can increase the risk to the safety of LLMs, even when data does not contain malicious content. To address this challenge, we propose Safe LoRA, a simple one-liner patch to the original LoRA implementation by introducing the projection of LoRA weights from selected layers to the safety-aligned subspace, effectively reducing the safety risks in LLM fine-tuning while maintaining utility. It is worth noting that Safe LoRA is a training-free and data-free approach, as it only requires the knowledge of the weights from the base and aligned LLMs. Our extensive experiments demonstrate that when fine-tuning on purely malicious data, Safe LoRA retains similar safety performance as the original aligned model. Moreover, when the fine-tuning dataset contains a mixture of both benign and malicious data, Safe LoRA mitigates the negative effect made by malicious data while preserving performance on downstream tasks. Our codes are available at \url{https://github.com/IBM/SafeLoRA}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。