让大模型拒绝有害请求时不受文字包装干扰,提升安全可靠性。
Towards Context-Invariant Safety Alignment for Large Language Models

- 用可验证提示作为锚点,只对模糊提示施加约束,避免误导。
- 在标准测试上准确率提升12.71%,跨场景一致性提高33.49%。
- 适合关注模型安全鲁棒性的研究者和应用开发者。
基于偏好的后训练能对齐大语言模型与人类意图,但安全行为仍易脆弱:同一有害意图在不同表述下可能触发不同响应。本文提出上下文无关对齐,即行为应仅依赖本质意图而非表面形式。现有方法因训练信号可信度不一而失效——可验证提示(如多选)反馈可靠,开放性提示则依赖噪声大、易被操纵的奖励代理。标准对称正则化会降低可靠提示性能以换取稳定性,反而削弱泛化。为此,我们提出锚定不变性正则化(AIR),将可验证提示视为锚点,通过停止梯度目标仅引导开放提示向锚点表现靠拢。AIR作为插件式辅助损失,与分组偏好优化(如GRPO)结合使用。在Safety、Moral Reasoning和Math任务中,AIR显著提升上下文不变性:分布内组准确率提升12.71%,分布外一致性提升33.49%,使安全约束对对抗性表述更具鲁棒性。
原文摘要 · Abstract (English)
Preference-based post-training aligns LLMs with human intent, yet safety behavior often remains brittle. A model may refuse a harmful request in a standard prompt but comply when the same intent is wrapped in adversarial wording. We suggest that robust safety requires context-invariant alignment, where behavior depends on the underlying intent rather than surface form. Enforcing invariance is difficult in alignment because not all training signals are equally trustworthy; for some prompt variants we can obtain verifiable feedback (e.g., multiple-choice), while for open-ended variants we typically rely on noisy, gameable reward proxies (e.g., learned judges). As a result, standard symmetric invariance regularizers can reduce cross-context discrepancies by lowering performance on reliable variants instead of improving open-ended robustness. To address this, we introduce Anchor Invariance Regularization (AIR), which treats verifiable prompts as anchors and uses a stop-gradient target to regularize only the open-ended variants toward the anchor performance. AIR is implemented as a plug-in auxiliary loss and combined with group-based preference optimization (e.g., GRPO) via heterogeneous prompt grouping. Across Safety, Moral Reasoning, and Math, AIR improves context invariance, boosting in-distribution group accuracy by 12.71% and out-of-distribution consistency by 33.49%, making safety constraints robust to adversarial framings.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。