arXiv:2606.25782cs.CLcs.AI2026-06中稿 · to ICANN2026

用编码器模型替代大模型做安全评估,更省成本且速度更快。

Do Encoders Suffice? A Systematic Comparison of Encoder and Decoder Safety Judges for LLM Adversarial Evaluation

  • 用ModernBERT等编码器模型做有害内容识别,训练时用多数投票标签
  • 在多个对抗数据集上,编码器模型的准确率接近大模型裁判,误报率低
  • 适合需要快速低成本部署的安全检测场景,尤其对攻击手法有区分能力

随着大语言模型在聊天机器人和日常应用中的普及,企业亟需高效、低成本且低延迟的安全防护机制。当前主流的安全评估依赖大模型裁判,虽有效但部署成本高、响应慢。本文系统评估了现代编码器分类器(如ModernBERT、Ettin)是否能在不显著损失性能的前提下,可靠识别用户-模型对话中的有害输出。我们在开源对抗数据集上对比了编码器模型、基于规则的前缀匹配、微调后的LLM分类器以及多种大模型裁判(包括StrongReject、ShieldGemma、JailbreakBench、AILuminate、SorryBench及Claude-as-a-judge),采用多种提示策略进行评测。编码器模型在标注数据上通过多数投票策略微调,并在黄金标准测试集上评估其表现,使用F1分数、假负率和精确率-召回率等指标。结果按攻击类型(单轮提示、分解、升级、上下文操纵)细分,揭示编码器与大模型裁判在不同攻击下的表现差异。研究为在特定场景下以编码器替代大模型裁判提供了实证依据。

原文摘要 · Abstract (English)

With the widespread adoption of large language models (LLMs) in chatbots and everyday applications, companies increasingly need guardrails that are effective while remaining low-cost and low-latency. Safety evaluation of LLM outputs has generally relied on LLM-based judges, which can be effective but are often slow and expensive to deploy at scale. In this paper, we evaluate whether fine-tuned modern encoder classifiers from the ModernBERT family, including ModernBERT and Ettin, can reliably identify harmful LLM outputs in user-model conversations without substantial performance loss relative to LLM-based judges. We benchmark these encoder classifiers against rule-based prefix matching, fine-tuned LLM classifiers, and LLM judges using a range of judge-prompting strategies across open-source adversarial datasets. The LLM judges include evaluation methodologies from StrongReject, ShieldGemma, JailbreakBench, AILuminate, SorryBench, and a Claude-as-a-judge setup, as well as fine-tuned safety classifiers such as LlamaGuard 3 and LlamaGuard 4. The encoder classifiers are fine-tuned on judge-labeled data using a majority-voting label strategy and are then evaluated on a gold-standard holdout dataset to assess their performance relative to LLM judges. We report absolute performance using F1 score, false negative rate, and precision-recall metrics. We also break down results by attack technique, including single-turn prompting, decomposition, escalation, and context manipulation, to identify where encoder classifiers align with or diverge from LLM-based judges. Our findings provide guidance on when encoder classifiers can serve as cost- and latency-efficient alternatives to LLM-based safety evaluation.

安全评估编码器模型大模型对抗检测

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