arXiv:2502.07985cs.CLcs.AI2025-02被引 5

动态优化提示词,让大模型推理时更安全。

MetaSC: Test-Time Safety Specification Optimization for Language Models

  • 推理时动态调整安全提示词,不改模型权重。
  • 对抗越狱攻击和道德风险任务中表现显著提升。
  • 适合需要实时安全控制的部署场景。

我们提出一种新颖的动态安全框架,在不修改模型权重的情况下,于推理阶段优化语言模型的安全性。基于自批判方法的最新进展,该方法引入元自批判机制,通过迭代更新安全提示(即规范),自适应地驱动批判与修正过程。这种测试时优化不仅显著提升了对对抗性越狱请求的防御能力,还在避免道德伤害、追求诚实回应等多样化的通用安全任务中表现优异。在多个语言模型上的实证评估表明,动态优化的安全提示相比固定系统提示和静态自批判防御,能带来更高的安全评分。代码已开源:https://github.com/vicgalle/meta-self-critique.git。

原文摘要 · Abstract (English)

We propose a novel dynamic safety framework that optimizes language model (LM) safety reasoning at inference time without modifying model weights. Building on recent advances in self-critique methods, our approach leverages a meta-critique mechanism that iteratively updates safety prompts-termed specifications-to drive the critique and revision process adaptively. This test-time optimization not only improves performance against adversarial jailbreak requests but also in diverse general safety-related tasks, such as avoiding moral harm or pursuing honest responses. Our empirical evaluations across several language models demonstrate that dynamically optimized safety prompts yield significantly higher safety scores compared to fixed system prompts and static self-critique defenses. Code released at https://github.com/vicgalle/meta-self-critique.git .

大模型安全提示优化推理时增强

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。