让大模型微调后仍保持安全,靠的是约束关键词的输出概率。
Guardrails in Logit Space: Safety Token Regularization for LLM Alignment

- 通过识别安全模板中的重要词元,限制其对应logit值。
- 微调后安全性接近顶尖方法,且不影响任务表现。
- 适合需要持续安全对齐的模型部署场景。
在新领域上微调已对齐的大语言模型时,即使使用无害数据集,其安全对齐性能也常下降。现有安全对齐方法多聚焦预训练阶段,导致微调后模型易出现行为偏移。本文提出安全词元正则化(STR),一种轻量级方法,在微调过程中保留安全特性。该方法从对齐良好的模型的拒绝模板中识别显著词元,并在训练中约束其对应logit值,防止关键安全行为丢失。与强化学习或偏好优化不同,STR计算开销极小,可无缝集成到LoRA等参数高效微调技术中。大量实验表明,该方法在安全性上达到顶尖水平,同时保持任务性能,实现最小实施成本。此外,STR还能提升训练稳定性与整体性能。本工作为微调大模型的持续安全对齐提供了实用、可直接部署的解决方案。
原文摘要 · Abstract (English)
Fine-tuning well-aligned large language models (LLMs) on new domains often degrades their safety alignment, even when using benign datasets. Existing safety alignment techniques primarily focus on pretraining, leaving fine-tuned models vulnerable to behavioral shifts. In this work, we introduce safety token regularization (STR), a lightweight method designed to preserve safety properties during fine-tuning. Our approach identifies salient tokens from rejection templates of well-aligned models and constrains their associated logits during training, preventing the loss of critical safety behaviors. Unlike reinforcement learning or preference optimization methods, STR requires minimal additional computation and seamlessly integrates with parameter-efficient fine-tuning techniques such as LoRA. Comprehensive experiments demonstrate that our approach achieves safety performance on par with state-of-the-art methods, while preserving task-specific utility and requiring minimal implementation overhead. Furthermore, we show that safety token regularization enhances training stability and overall performance beyond safety considerations alone. This work offers a practical and readily deployable strategy for continual safety alignment in fine-tuned LLMs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。