Skip to content

Safe LoRA: A glimmer of hope for reducing safety risk when fine-tuning large language modelsSafe LoRA: the Silver Lining of Reducing Safety Risks when Fine-tuning Large Language Models

arXiv· arXiv:2405.16833· Chia-Yi Hsu, Yu-Lin Tsai, Chih-Hsun Lin, Pin-Yu Chen, Chia-Mu Yu, Chun-Ying HuangNational Yang Ming Chiao Tung University; IBM ResearchIndexed by this site · 27 days ago· Originally publishedDefenses

Translation in progress — untranslated text is omitted.

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

AI summaryThe researchers propose Safe LoRA, which reduces the safety risk brought by fine-tuning large language models by projecting the LoRA weights of selected layers onto a safety alignment subspace. Addressing the problem that fine-tuning may increase safety risk even without malicious data, this method serves as a one-line patch to the original LoRA implementation, requires no training or data, and needs only the weights of the base model and the aligned model. Experiments show that when fine-tuning on purely malicious data, Safe LoRA maintains safety close to that of the original aligned model; when the fine-tuning data mixes benign and malicious content, it preserves downstream task performance while mitigating the negative effects of malicious data. Code is open-sourced at https://github.com/IBM/SafeLoRA。

Questions
Existing research reports that fine-tuning an aligned LLM weakens safety guardrails, even when the data contains no malicious content; LoRA fine-tuning is low-cost and widely used, and the authors aim to mitigate this safety risk without adding data or further training.
Methods
Safe LoRA uses the difference between the base and chat/instruct model weights to construct the alignment matrix V, yielding the projection matrix C; after fine-tuning, it computes the cosine similarity of each layer's LoRA update before and after projection, and projects only the layers whose similarity is below a threshold τ (or top-K); it is a data-free, training-free one-line patch.
Experiments and results
On Llama-2-7B-Chat and Llama-3-8B-Instruct, after PureBad pure malicious fine-tuning, Safe LoRA's harmful scores are 1.055 and 1.10 respectively, close to the original models; on Dialog Summary mixed data and Alpaca purely benign data, the authors state that it lowers the harmful score while maintaining utility, and outperforms SafeInstr and BEA.
Limitations and future work
The authors note in Section 5 that the method is transparent and future attackers may bypass it adaptively; the authors believe the method can also be extended to multimodal models such as Text-to-Image. The experiments cover Llama-2-7B-Chat, Llama-3-8B-Instruct, and Gemma, and do not report the number of repetitions or variance.

Related papers

Show 3 more papers
Read originalarxiv.org