AdaGuard:一种具有用户自定义策略的自适应防护模型
研究论文 · 2026/09/29
Guard模型支持语言模型代理的安全部署,但固定的风险分类法限制了其适应不同应用和任务需求的能力。在用户定义策略下,检测违规需要解释适用规则和代理行为,因为相同行为在不同策略下可能得到不同判断。为支持学习这一能力,我们引入了AdaptiveSafety数据集,包含10,939个训练示例和1,000个测试示例,覆盖1-100条规则的策略。该数据集结合了来自多个来源的轨迹与策略和行为反事实,每个示例都配有解释和完整的违规规则集。这些反事实揭示了改变合规性的变化,而结构增强为规则重排序和标识符重映射下的一致性提供了监督。基于此监督,我们提出了SafePO,一种强化学习算法,用于细化违规识别,同时平衡解释性推理和最终裁决。SafePO使用结构化奖励评估预测正确性,在响应级别保留组相对优势,并采用单独训练的价值模型来调节解释和裁决区域内令牌权重。单独的归一化控制它们对训练的贡献,尽管长度不同。通过监督初始化后接SafePO,我们开发了AdaGuard,一系列0.6B、4B和8B的Guard模型,可在推理时根据提供的策略评估代理轨迹。我们的4B模型在AdaptiveSafety上达到89.30%的二元准确率,在DynaBench上达到71.82%。项目仓库见https://github.com/Yunhao-Feng/AdaGuard。
该研究解决了用户定义策略下代理行为合规性检测的挑战,提供了新的数据集、算法和模型,并在多个基准上取得了领先性能,对于安全部署语言模型代理具有重要意义。
Guard models support the safe deployment of language model agents, but fixed risk taxonomies limit their ability to accommodate requirements that vary across applications and tasks. Under user-defined policies, detecting violations requires interpreting both the applicable rules and the agent's behavior, since identical actions can receive different judgments under different policies. To support learning this capability, we introduce AdaptiveSafety, a dataset of 10,939 training examples and 1,000 test examples covering policies with 1--100 rules. The dataset combines trajectories from multiple sources with policy and behavioral counterfactuals, pairing each example with an explanation and the complete set of violated rules. These counterfactuals expose changes that alter compliance, while structural augmentations provide supervision for consistency under rule reordering and identifier remapping. Building on this supervision, we propose SafePO, a reinforcement learning algorithm for refining violation identification while balancing explanatory reasoning and final verdicts. SafePO uses structured rewards to assess prediction correctness, retains group-relative advantages at the response level, and employs a separately trained value model to modulate token weights within explanation and verdict regions. Separate normalization controls their relative contribution to training despite differences in length. Through supervised initialization followed by SafePO, we develop AdaGuard, a family of 0.6B, 4B, and 8B guard models that assess agent trajectories under policies supplied at inference time. Our 4B model achieves binary accuracies of 89.30\% on AdaptiveSafety and 71.82\% on DynaBench. The project repository is available at https://github.com/Yunhao-Feng/AdaGuard