提出GuardSpace框架,让大模型微调时既保安全又提性能。
A Guardrail for Safety Preservation: When Safety-Sensitive Subspace Meets Harmful-Resistant Null-Space

- 分离安全相关与无关权重,冻结前者以保护安全机制。
- 在有害提示下保持拒绝响应,将有害率从14.4%降至3.6%。
- 适合需要高安全性的模型微调场景,如对话系统。
大型语言模型在多样化任务中表现卓越,但其安全对齐在微调过程中仍易被破坏。即使在良性数据上微调或使用低秩适配,预训练的安全行为也常被削弱,导致生成有害输出。为此,我们提出GuardSpace,一种贯穿微调全过程的安全防护框架,包含两个核心组件:安全敏感子空间和有害抵抗零空间。首先,通过协方差预条件奇异值分解,显式分解预训练权重为安全相关与无关部分,从无关部分初始化低秩适配器,并冻结安全相关部分以保留其安全机制。其次,构建零空间投影器,限制适配器更新改变有害提示下的安全输出,从而维持原始拒绝行为。在多个下游任务和预训练模型上的实验表明,GuardSpace优于现有方法。以Llama-2-7B-Chat在GSM8K上微调为例,相比最优方法AsFT,GuardSpace将平均有害分数从14.4%降至3.6%,同时准确率从26.0%提升至28.0%。
原文摘要 · Abstract (English)
Large language models (LLMs) have achieved remarkable success in diverse tasks, yet their safety alignment remains fragile during adaptation. Even when fine-tuning on benign data or with low-rank adaptation, pre-trained safety behaviors are easily degraded, leading to harmful responses in the fine-tuned models. To address this challenge, we propose GuardSpace, a guardrail framework for preserving safety alignment throughout fine-tuning, composed of two key components: a safety-sensitive subspace and a harmful-resistant null space. First, we explicitly decompose pre-trained weights into safety-relevant and safety-irrelevant components using covariance-preconditioned singular value decomposition, and initialize low-rank adapters from the safety-irrelevant ones, while freezing safety-relevant components to preserve their associated safety mechanism. Second, we construct a null space projector that restricts adapter updates from altering safe outputs on harmful prompts, thereby maintaining the original refusal behavior. Experiments with various pre-trained models on multiple downstream tasks demonstrate that GuardSpace achieves superior performance over existing methods. Notably, for Llama-2-7B-Chat fine-tuned on GSM8K, GuardSpace outperforms the state-of-the-art method AsFT, reducing the average harmful score from 14.4% to 3.6%, while improving the accuracy from from 26.0% to 28.0%.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。