arXiv:2601.10141cs.LGcs.AI2026-01被引 7

提出轻量级微调方法,让大模型在提升任务性能时仍保持安全对齐。

Understanding and Preserving Safety in Fine-Tuned LLMs

  • 发现安全与任务梯度在低秩子空间中存在方向冲突
  • 仅用单样本即可估算安全方向,实现高效防护
  • 可抵御深度微调和对抗性越狱攻击,适合高安全性场景

微调是将大语言模型应用于下游任务的关键技术,但可能显著削弱安全对齐,例如大幅增加越狱攻击的脆弱性,即使微调数据完全无害。现有方法面临安全与性能的权衡困境:强调安全会损害任务表现,而追求性能则需深度微调,导致安全严重下降。本文通过系统实证分析,揭示三大关键发现:(I) 安全梯度位于低秩子空间,任务梯度分布于更广的高维空间;(II) 二者子空间常呈负相关,导致微调时方向冲突;(III) 主导安全方向可由单一样本高效估计。基于此,提出安全保留微调(SPF),通过显式移除与低秩安全子空间冲突的梯度成分。理论上,SPF保证任务性能收敛并控制安全漂移;实验证明,SPF在对抗性微调场景下仍能维持任务性能并恢复几乎全部预训练安全对齐,且对深度微调和动态越狱攻击具有强鲁棒性。研究为始终对齐的微调提供了新机制理解与实用指导。

原文摘要 · Abstract (English)

Fine-tuning is an essential and pervasive functionality for applying large language models (LLMs) to downstream tasks. However, it has the potential to substantially degrade safety alignment, e.g., by greatly increasing susceptibility to jailbreak attacks, even when the fine-tuning data is entirely harmless. Despite garnering growing attention in defense efforts during the fine-tuning stage, existing methods struggle with a persistent safety-utility dilemma: emphasizing safety compromises task performance, whereas prioritizing utility typically requires deep fine-tuning that inevitably leads to steep safety declination. In this work, we address this dilemma by shedding new light on the geometric interaction between safety- and utility-oriented gradients in safety-aligned LLMs. Through systematic empirical analysis, we uncover three key insights: (I) safety gradients lie in a low-rank subspace, while utility gradients span a broader high-dimensional space; (II) these subspaces are often negatively correlated, causing directional conflicts during fine-tuning; and (III) the dominant safety direction can be efficiently estimated from a single sample. Building upon these novel insights, we propose safety-preserving fine-tuning (SPF), a lightweight approach that explicitly removes gradient components conflicting with the low-rank safety subspace. Theoretically, we show that SPF guarantees utility convergence while bounding safety drift. Empirically, SPF consistently maintains downstream task performance and recovers nearly all pre-trained safety alignment, even under adversarial fine-tuning scenarios. Furthermore, SPF exhibits robust resistance to both deep fine-tuning and dynamic jailbreak attacks. Together, our findings provide new mechanistic understanding and practical guidance toward always-aligned LLM fine-tuning.

大模型安全微调优化对抗防御

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。