Shape it Up! 修复微调过程中LLM的安全性
Shape it Up! Restoring LLM Safety during Finetuning
AI总结:
动态安全塑造(DSS)通过细粒度安全信号在微调过程中动态增强安全内容,有效缓解安全风险,提升模型安全性。
摘要:
微调大型语言模型(LLM)可以实现用户特定的定制化,但会引入关键的安全风险:即使几个有害的例子也会破坏安全对齐。一种常见的缓解策略是更新模型以处理被认为是安全的例子,同时降低或排除被标记为不安全的例子的权重。然而,由于安全情境可能在单个例子中发生变化,对响应中有害和无害部分等量更新模型是次优的——这是一种我们称之为静态安全塑造的粗略处理。相反,我们提出了动态安全塑造(DSS),一种框架,利用细粒度的安全信号来强化学习响应中的安全部分,同时抑制不安全的内容。为了在微调过程中实现这种细粒度的控制,我们引入了一个关键见解:传统的用于过滤的防护模型可以重新利用来评估部分响应,跟踪响应中安全风险如何随着响应的变化而变化,逐段进行。这导致了响应轨迹评估(STAR),一种基于标记的信号,使塑造能够在训练序列上动态运作。基于此,我们提出了STAR-DSS,由STAR分数引导,能够稳健地缓解微调风险,并在多样化的威胁、数据集和模型家族中提供显著的安全改进,所有这些都不影响在预期任务上的能力。我们鼓励未来的安全研究基于动态塑造原则,以更强的缓解微调风险。我们的代码可在https://github.com/poloclub/star-dss公开获取。
英文摘要:
Finetuning large language models (LLMs) enables user-specific customization but introduces critical safety risks: even a few harmful examples can compromise safety alignment. A common mitigation strategy is to update the model more strongly on examples deemed safe, while downweighting or excluding those flagged as unsafe. However, because safety context can shift within a single example, updating the model equally on both harmful and harmless parts of a response is suboptimal-a coarse treatment we term static safety shaping. In contrast, we propose dynamic safety shaping (DSS), a framework that uses fine-grained safety signals to reinforce learning from safe segments of a response while suppressing unsafe content. To enable such fine-grained control during finetuning, we introduce a key insight: guardrail models, traditionally used for filtering, can be repurposed to evaluate partial responses, tracking how safety risk evolves throughout the response, segment by segment. This leads to the Safety Trajectory Assessment of Response (STAR), a token-level signal that enables shaping to operate dynamically over the training sequence. Building on this, we present STAR-DSS, guided by STAR scores, that robustly mitigates finetuning risks and delivers substantial safety improvements across diverse threats, datasets, and model families-all without compromising capability on intended tasks. We encourage future safety research to build on dynamic shaping principles for stronger mitigation against evolving finetuning risks. Our code is publicly available at https://github.com/poloclub/star-dss.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。