arXiv:2508.17739cs.LGcs.AI2025-08EMNLP被引 6

用小模型实时检测并防护大模型的越狱攻击,同时提速推理。

Speculative Safety-Aware Decoding

  • 用小模型在解码时动态检测越狱风险,决定是否启用安全模式。
  • 在保持有用性的同时,有效防御越狱攻击,推理速度提升30%以上。
  • 适合追求高效安全推理的工业级LLM部署场景。

尽管大规模语言模型(LLMs)已广泛对齐人类价值观与安全规则,但利用特定漏洞的越狱攻击仍持续出现,凸显出为现有模型增强安全属性的必要性。然而,调优大模型成本日益增高,且难以保证性能一致性。本文提出一种轻量级解码阶段方法——推测性安全感知解码(SSD),可在不改变大模型的前提下赋予其期望的安全属性,并加速推理过程。假设存在一个具备目标安全属性的小语言模型,SSD通过在解码中引入推测采样,利用小模型与复合模型输出的匹配率量化越狱风险,动态切换解码策略以平衡效用与安全。最终输出从原模型与小模型分布的融合分布中采样。实验表明,SSD成功使大模型具备所需安全属性,同时保持对良性请求的帮助性,并因推测采样设计使推理速度提升30%以上。

原文摘要 · Abstract (English)

Despite extensive efforts to align Large Language Models (LLMs) with human values and safety rules, jailbreak attacks that exploit certain vulnerabilities continuously emerge, highlighting the need to strengthen existing LLMs with additional safety properties to defend against these attacks. However, tuning large models has become increasingly resource intensive and may have difficulty ensuring consistent performance. We introduce Speculative Safety-Aware Decoding (SSD), a lightweight decoding-time approach that equips LLMs with the desired safety property while accelerating inference. We assume that there exists a small language model that possesses this desired property. SSD integrates speculative sampling during decoding and leverages the match ratio between the small and composite models to quantify jailbreak risks. This enables SSD to dynamically switch between decoding schemes to prioritize utility or safety, to handle the challenge of different model capacities. The output token is then sampled from a new distribution that combines the distributions of the original and the small models. Experimental results show that SSD successfully equips the large model with the desired safety property, and also allows the model to remain helpful to benign queries. Furthermore, SSD accelerates the inference time, thanks to the speculative sampling design.

安全推理越狱防御轻量级优化

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