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.


翻译:微调大型语言模型(LLMs)可实现用户定制化,但会引入关键的安全风险:即使少量有害示例也可能破坏安全对齐。常见的缓解策略是对被判定为安全的示例进行更强化的模型更新,同时降低被标记为不安全示例的权重或将其排除。然而,由于安全语境可能在单个示例内部发生变化,对响应中有害和无害部分进行同等强度的模型更新并非最优策略——我们将这种粗粒度处理称为静态安全塑形。相比之下,我们提出动态安全塑形(DSS)框架,该框架利用细粒度安全信号来强化从响应安全片段中学习,同时抑制不安全内容。为实现微调过程中此类细粒度控制,我们引入一个关键洞见:传统用于过滤的护栏模型可被重新用于评估部分响应,逐段追踪安全风险在整个响应过程中的演变。由此产生了响应安全轨迹评估(STAR),这是一种令牌级信号,使塑形机制能在训练序列上动态运作。在此基础上,我们提出了基于STAR分数指导的STAR-DSS方法,该方法能稳健缓解微调风险,并在多样化威胁、数据集和模型族上实现显著的安全提升——且不损害目标任务的能力。我们鼓励未来的安全研究基于动态塑形原则,以更有效地应对不断演变的微调风险。代码已公开于 https://github.com/poloclub/star-dss。

0
下载
关闭预览

相关内容

国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员