[论文解读] Prompt Attack Detection with LLM-as-a-Judge and Mixture-of-Models
本文提出一种将大语言模型作为裁判的框架,结合分类法引导的结构化推理和自我反思来在实时 guardrails 中检测提示攻击,并研究混合模型(Mixture-of-Models,MoM)以提高鲁棒性。研究表明轻量级通用型大语言模型在与编码器和专用模型的对比中可获更好表现,但集成模型结果混合不一。
Prompt attacks, including jailbreaks and prompt injections, pose a critical security risk to Large Language Model (LLM) systems. In production, guardrails must mitigate these attacks under strict low-latency constraints, resulting in a deployment gap in which lightweight classifiers and rule-based systems struggle to generalize under distribution shift, while high-capacity LLM-based judges remain too slow or costly for live enforcement. In this work, we examine whether lightweight, general-purpose LLMs can reliably serve as security judges under real-world production constraints. Through careful prompt and output design, lightweight LLMs are guided through a structured reasoning process involving explicit intent decomposition, safety-signal verification, harm assessment, and self-reflection. We evaluate our method on a curated dataset combining benign queries from real-world chatbots with adversarial prompts generated via automated red teaming (ART), covering diverse and evolving patterns. Our results show that general-purpose LLMs, such as gemini-2.0-flash-lite-001, can serve as effective low-latency judges for live guardrails. This configuration is currently deployed in production as a centralized guardrail service for public service chatbots in Singapore. We additionally evaluate a Mixture-of-Models (MoM) setting to assess whether aggregating multiple LLM judges improves prompt-attack detection performance relative to single-model judges, with only modest gains observed.
研究动机与目标
- 证明轻量级、通用型 LLM 可在生产约束下用作低延迟的提示攻击安全裁判。
- 设计鼓励结构化、多步推理过程的提示,包含明确的意图分解、安全信号验证、伤害评估和自我反思。
- 在结合良性真实世界提示与通过自动化红队化生成的对抗性提示的精选数据集上评估性能。
- 调查 Mixture-of-Models(MoM)集成是否能在提示攻击检测中优于单一模型裁判。
- 提供关于提示设计与输出结构的实用指南,以提升实时 guardrails 中的检测鲁棒性。
提出的方法
- 提出一个 LLM-as-a-Judge 框架,强制执行分类法引导的推理过程和带自我反思的结构化两轮评估。
- 实现 Framing Stripping,以将核心意图从框架语言中分离出来。
- 使用包含 Workflow Instruction、Factual Overview、Safety Knowledge、Detailed Harm Methods、Safety Bypass Attempt 的情境感知分类法,对提示进行分类。
- 应用多轮上下文分析以评估完整对话历史中的攻击。
- 采用结构化的两阶段推理(Structured CoT):起草分类与伤害评估,然后强制自我反思,最后给出带置信度分数的最终裁决。
- 将定性裁决转化为数值分数,以实现对风险的细粒度标定(0.0 至 1.0)。
- 引入 Mixture-of-Models(MoM)框架,通过加权分数和阈值来汇聚来自多个 LLM 裁判的输出,并通过网格搜索超参数优化以最大化 F1。
- curate 一个包含 929 个样本的评估集(770 个 benign,159 个 adversarial),结合生产流量与 Automated Red Teaming 提示(PAIR 使用 GPT-4o)。
- 在若干基础模型(如 Gemini、GPT、Claude)上分析性能,并比较非思考与思考配置。

实验结果
研究问题
- RQ1轻量级的通用型 LLM 是否能在生产延迟下实时检测提示攻击?
- RQ2在强制结构化推理、显式意图分解和自我反思的情况下,检测性能是否优于直接给出裁决的提示?
- RQ3Mixture-of-Models 在提示攻击检测方面相对于最佳单模型裁判的表现如何?
- RQ4提示设计与输出结构对不同 LLM 基础模型的检测效果有何影响?
主要发现
| Model Type | Backbone | Latency | Precision | Recall | F1 score |
|---|---|---|---|---|---|
| Proprietary | aws_prompt_attack | 0.63 | 0.0714 | 0.3711 | 0.1198 |
| Encoder-based | PromptGuard | 0.041 | 0.000? | 0.000? | 0.000? |
| Encoder-based | ProtectAI | 0.041 | 0.000? | 0.000? | 0.000? |
| Specialized LLM | Qwen3Guard (0.6B) | 1.00 | 1 | 1 | 0.5375 |
| Specialized LLM | gpt_oss_safeguard | 0.53 | 0.8864 | 0.7358 | 0.8041 |
| LLM Judge | gemini-2.0-flash-lite-001 | 1.52 | 0.8214 | 0.8679 | 0.8440 |
| LLM Judge | gemini-2.5-flash-lite | 1.44 | 0.8165 | 0.8113 | 0.8139 |
| LLM Judge | gemini-2.5-flash | 1.85 | 0.7730 | 0.8994 | 0.8314 |
| LLM Judge | gemini-3-flash-preview | 2.02 | 0.7978 | 0.9182 | 0.8538 |
| LLM Judge | gpt-5-mini | 2.67 | 0.8980 | 0.8302 | 0.8627 |
| LLM Judge | gpt-5.1 | 4.04 | 0.9766 | 0.7862 | 0.8711 |
| LLM Judge | claude-haiku-4-5@20251001 | 5.88 | 0.8353 | 0.8931 | 0.8632 |
- 以 taxonomy 指导的推理的 LLM-as-a-Judge 在对比基于编码器的分类器和专用安全型 LLM 的多项基线中呈现最强的整体检测性能。
- 观察到的最高 F1 分数为 0.8711(GPT-5.1),精确度 0.9766,召回率 0.7862;而 gemini-2.0-flash-lite-001 在 1.5s 内实现了 latency 与性能的良好平衡,F1 为 0.844。
- 基于编码器的分类器性能较差(F1 低),凸显了对灰色区域攻击的浅层关键词方法的局限性。
- 专用安全型 LLM 相较于编码器有所提升(如 gpt_oss_safeguard F1 0.8041),但在不同 backbone 上仍被 LLM-as-a-Judge 的配置所超越。
- 在 LLM-Judge 家族中,通常延迟越高,F1 越高,gpt-5.1 在约 4 秒每条提示时达到最佳性能,gemini-2.0-flash-lite-001 提供更有利的延迟-性能平衡。
- 集成(MoM)并不保证提升,且常常降低性能;仅在少数互补模型组合中取得收益(尤其涉及 gpt-5.1、gpt-5-mini、claude-haiku-4.5)。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。