SentGuard:面向大型语言模型的句子级流式护栏
SentGuard: Sentence-Level Streaming Guardrails for Large Language Models
AI总结:
提出SentGuard,一种与生成并行运行的句子级流式护栏,通过轻量级等待缓冲区将流式令牌分组为句子块并仅释放已验证块,以在低延迟下实现高精度不安全内容检测。
摘要:
大型语言模型越来越多地实时流式输出长篇幅、推理密集的响应,这使得何时进行审核与是否进行审核同样关键。现有的护栏分为两种不理想的极端:响应级方法延迟干预直到完整输出生成,而令牌级方法基于不完整的语义进行操作,往往产生不稳定的决策和过多的护栏调用。为应对这一挑战,我们提出SentGuard,一种与生成并行运行的句子级流式护栏。一个轻量级等待缓冲区将流式令牌分组为句子块,并仅向用户释放已验证的块,引入一个小偏移量,使得SentGuard能够在目标LLM解码后续内容时评估当前前缀。为支持这一点,我们构建了StreamSafe基准,包含8个危害类别的结构化逐句标注,捕捉推理和响应段中安全风险的演变。我们进一步使用从粗到细的目标训练SentGuard,以在不安全意图在句子边界出现时立即检测。在5个安全基准上的实验表明,SentGuard优于现有基线,在两个句子内检测到90.5%的不安全案例,同时保持7.41%的低流式误报率。
英文摘要:
Large language models increasingly stream long, reasoning-intensive responses in real time, making when to moderate as critical as whether to moderate. Existing guardrails fall into two unsatisfactory extremes: response-level methods delay intervention until the full output is generated, whereas token-level methods act on incomplete semantics, often producing unstable decisions and excessive guard invocations. To address this challenge, we propose SentGuard, a sentence-level streaming guardrail that operates in parallel with generation. A lightweight waiting buffer groups streamed tokens into sentence chunks and releases only verified chunks to the user, introducing a small offset that enables SentGuard to assess the current prefix while the target LLM decodes subsequent content. To support this, we construct StreamSafe, a benchmark with structured per-sentence annotations across 8 harm categories, capturing the evolution of safety risks across both reasoning and response segments. We further train SentGuard with a coarse-to-fine objective to detect unsafe intent as soon as it emerges at sentence boundaries. Experiments on 5 safety benchmarks show that SentGuard outperforms existing baselines, detecting 90.5% of unsafe cases within two sentences while maintaining a low streaming false-positive rate of 7.41%.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。