用轻量提示词检测大模型有害内容,速度接近首字生成
Prefix Probing: Lightweight Harmful Content Detection for Large Language Models
- 通过对比特定前缀的条件概率判断内容危害性
- 检测延迟几乎等同于首个词生成时间,计算开销极小
- 无需额外模型或复杂流程,适合实际部署
大型语言模型在真实安全敏感应用中常面临检测准确率、推理延迟和部署成本三者之间的权衡。本文提出 Prefix Probing,一种黑盒有害内容检测方法,通过比较‘同意/执行’与‘拒绝/安全’前缀的条件对数概率,并利用前缀缓存将检测开销降至接近首个词生成的延迟水平。推理时仅需对探测前缀进行一次对数概率计算即可生成危害性评分并应用阈值,无需调用额外模型或多阶段推理。为进一步提升前缀判别能力,设计了一种高效的前缀构造算法,自动发现高信息量前缀,显著提升检测性能。大量实验表明,Prefix Probing 的检测效果可媲美主流外部安全模型,同时计算成本极低且无需额外模型部署,展现出强大的实用性和效率。
原文摘要 · Abstract (English)
Large language models often face a three-way trade-off among detection accuracy, inference latency, and deployment cost when used in real-world safety-sensitive applications. This paper introduces Prefix Probing, a black-box harmful content detection method that compares the conditional log-probabilities of "agreement/execution" versus "refusal/safety" opening prefixes and leverages prefix caching to reduce detection overhead to near first-token latency. During inference, the method requires only a single log-probability computation over the probe prefixes to produce a harmfulness score and apply a threshold, without invoking any additional models or multi-stage inference. To further enhance the discriminative power of the prefixes, we design an efficient prefix construction algorithm that automatically discovers highly informative prefixes, substantially improving detection performance. Extensive experiments demonstrate that Prefix Probing achieves detection effectiveness comparable to mainstream external safety models while incurring only minimal computational cost and requiring no extra model deployment, highlighting its strong practicality and efficiency.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。