Instruction-following language models are trained to be helpful and safe, yet their safety behavior can deteriorate under benign fine-tuning and worsen under adversarial updates. Existing defenses often offer limited protection or force a trade-off between safety and utility. We introduce a training framework that adapts regularization in response to safety risk, enabling models to remain aligned throughout fine-tuning. To estimate safety risk at training time, we explore two distinct approaches: a judge-based Safety Critic that assigns high-level harm scores to training batches, and an activation-based risk predictor built with a lightweight classifier trained on intermediate model activations to estimate harmful intent. Each approach provides a risk signal that is used to constrain updates deemed higher risk to remain close to a safe reference policy, while lower-risk updates proceed with standard training. We empirically verify that harmful intent signals are predictable from pre-generation activations and that judge scores provide effective high-recall safety guidance. Across multiple model families and attack scenarios, adaptive regularization with either risk estimation approach consistently lowers attack success rate compared to standard fine-tuning, preserves downstream performance, and adds no inference-time cost. This work demonstrates a principled mechanism for maintaining safety without sacrificing utility.
翻译:指令跟随语言模型经过训练既要有用又要安全,但其安全行为可能在良性微调过程中退化,并在对抗性微调下进一步恶化。现有防御方法通常提供有限保护,或被迫在安全性与实用性之间做出权衡。我们提出一种训练框架,可根据安全风险自适应调整正则化强度,使模型在整个微调过程中保持对齐。为在训练时评估安全风险,我们探索了两种不同方法:一是基于评判器的安全批评器,为训练批次分配高级危害评分;二是基于激活的风险预测器,通过轻量级分类器利用中间层模型激活估计有害意图。每种方法产生的风险信号用于约束高风险更新使其接近安全参考策略,而低风险更新则按标准训练进行。我们通过实验验证,有害意图信号可从预生成激活中预测,且评判器评分能提供有效的高召回率安全引导。在多种模型系列和攻击场景下,与标准微调相比,采用任一风险估计方法的自适应正则化均可持续降低攻击成功率、保持下游任务性能,且不增加推理成本。本研究展示了在不牺牲实用性的前提下维持安全性的原则性机制。