# ShieldGemma

ShieldGemma 是 [Google DeepMind](https://www.edgepedia.org/zh/google-deepmind) 开发的一系列开放权重安全内容审核分类器，基于 Gemma 模型系列构建，以大型语言模型的形式发布，用作分类器而非聊天机器人。首个发布版本是一组基于 Gemma 2 构建的英文文本分类器，参数规模为 2B、9B 和 27B，针对四类危害：色情内容、危险内容、仇恨与骚扰。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> 第二个发布版本 ShieldGemma 2 是一个基于 [Gemma 3](https://www.edgepedia.org/zh/gemma-3) 构建的 40 亿参数图像安全分类器，于 2025 年 3 月与 Gemma 3 同时发布。<sup>[2](https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063)</sup>

本文通篇适用一项警示：公开记录中的每一个基准测试数字和能力声明都来自 Google 自身。截至 2025 年 4 月可获取的资料中，没有出现任何对 ShieldGemma 的独立评估、排行榜结果或第三方审计。

| 事实 | 详情 |
|---|---|
| 开发者 | Google DeepMind（厂商发布记录）<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> |
| 首次发布 | 基于 Gemma 2 的文本分类器，技术报告 2024 年 7 月<sup>[3](https://arxiv.org/html/2407.21772v1)</sup> |
| 规模（文本） | 2B、9B 和 27B 参数，英文，开放权重<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> |
| 第二次发布 | ShieldGemma 2，基于 Gemma 3 的 4B 图像分类器，2025 年 3 月发布<sup>[2](https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063)</sup> |
| 文本危害类别 | 色情内容、危险内容、仇恨、骚扰<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> |
| 图像策略 | 性内容、危险内容、暴力（三项策略）<sup>[4](https://arxiv.org/html/2504.01081v2)</sup> |
| 获取方式 | Hugging Face 上的开放权重<sup>[5](https://huggingface.co/google/shieldgemma-2-4b-it)</sup> |

## ShieldGemma 是什么

根据 2024 年 7 月的技术报告，ShieldGemma 是一种“大语言模型即分类器”：当提示词配置正确时，其输出被限制为以“是”或“否”标记作为第一个输出标记的大型语言模型。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup> 实践中它是一组分类器，因为每个模型实例一次只针对一个策略定义检查一个危害类别；要筛查全部四种文本危害类型的部署需要发起四次独立调用。<sup>[6](https://ai.google.dev/responsible/docs/safeguards/shieldgemma_on_huggingface)</sup>

它基于 Gemma 模型构建，是一种可自托管的开放权重组件，开发者将其置于自身模型的输入和输出周围。Google 的文档区分了两种过滤位置：纯提示词模式，筛查用户输入是否直接包含违规内容或试图诱导违规内容；以及提示词-响应模式，在模型输出到达用户之前对其进行筛查。<sup>[6](https://ai.google.dev/responsible/docs/safeguards/shieldgemma_on_huggingface)</sup>

## 工作原理

输入是按特定模式拼接的文本字符串：一段前导语、待分类的内容、所检查危害类型的策略定义集合，以及一段提示词尾缀。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> 模型随后生成一个违规概率。

Google 的文档对模型的运行方式有明确要求。它在评分模式下效果最佳，该模式生成 0 到 1 之间的预测值，数值越接近 1 表示违规概率越高，以便部署者根据自身用例调整过滤阈值。类似“大语言模型即评判者”方法的生成模式虽然可行，但被描述为可控性更差且更不透明。技术报告更进一步，建议用户仅将模型用于“是/否”标记评分，避免聊天式使用，因为该模型缺乏针对对话的额外安全指令微调，在聊天模式下可能产生不道德或不安全的内容。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup><sup> • </sup><sup>[6](https://ai.google.dev/responsible/docs/safeguards/shieldgemma_on_huggingface)</sup>

出于同样的原因，ShieldGemma 2 对每次预测输出一个连续的置信度分数，让下游用户能够调整分类阈值。<sup>[4](https://arxiv.org/html/2504.01081v2)</sup> 根据模型卡，文本模型在合成生成的内部数据和公开数据集上进行了微调。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup>

## 发布时间线与版本

**2024 年 7 月：** 最初的 ShieldGemma 技术报告描述了基于 Gemma 2 构建的文本分类器，规模为 2B、9B 和 27B，以开放权重覆盖英文四种危害类别。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup><sup> • </sup><sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup>

**2025 年 3 月：** 随着 Gemma 3 亮相，Google 发布了 ShieldGemma 2——一个基于 Gemma 3 构建的 40 亿参数模型，用于检查合成图像和自然图像的安全性，扩展了前一年仅限文本的套件。<sup>[2](https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063)</sup> 随附的技术报告日期为 2025 年 4 月，针对三项图像策略对其进行评估：性内容、危险内容和暴力。<sup>[4](https://arxiv.org/html/2504.01081v2)</sup>

在 ShieldGemma 2 的发布公告中，Google 表示期待探索更小的规模、更多危害领域，以及与多模态 ML Commons 分类体系的对齐。2025 年 4 月之后没有任何资料记录 ShieldGemma 的后续开发；记录中没有 2026 年的新版本、弃用或路线图更新。<sup>[2](https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063)</sup>

## 基准测试结果：厂商与独立评估

以下所有已公布数字均为厂商报告，由 Google 在 Google 选定的基准上测得，包括其自有的内部 SG Prompt 和 SG Response 数据集，以及 OpenAI Mod 和 ToxicChat 等外部数据集。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup>

对于文本模型，模型卡报告了 F1/AU-PRC 配对数据：ShieldGemma 27B 在 SG Prompt 上得分 0.830/0.883，在 OpenAI Mod 上 0.805/0.886，在 ToxicChat 上 0.729/0.811，在 SG Response 上 0.758/0.806；9B 模型在 SG Prompt 上得分 0.828/0.894，在 OpenAI Mod 上 0.821/0.907。同一表格中的对比对象包括：OpenAI Mod API 在 SG Prompt 上为 0.782/0.840，但在 ToxicChat 上仅为 0.254/0.588；LlamaGuard2（8B）在 OpenAI Mod 上为 0.761，在 ToxicChat 上为 0.471；GPT-4 在 SG Prompt 上为 0.810/0.847。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> 技术报告补充称，所有 ShieldGemma 规模在二分类中均优于所有基线审核模型，包括 LlamaGuard1、WildGuard 和 GPT-4；在相似模型规模和训练数据量下，SG-9B 在外部基准上的平均 AU-PRC 比 LlamaGuard1 高 10.8%；其 F1 比 WildGuard 高 4.3%，比 GPT-4 高 6.4%。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup>

对于图像模型，ShieldGemma 2 报告称其在 Google 内部图像安全基准上取得了 89.1% 的平均 PR-AUC，分别比 Gemma-3-4B-IT、GPT-4o mini 和 LlavaGuard 7B 高出 6.8%、12.9% 和 14.8%。同一报告将 GPT-4o mini 描述为召回率极高但严重过度触发，导致精确率低得多。<sup>[4](https://arxiv.org/html/2504.01081v2)</sup>

未发现独立评估。所有对比均在 Google 选定的基准上运行，其中两个（SG Prompt、SG Response）是 Google 自有的内部数据集，因此在现有记录中，所报告的相对竞争对手的优势尚未被第三方复现。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup><sup> • </sup><sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup>

## 与其他审核工具的对比

正面对比记录完全由 Google 自己的表格构成：与 LlamaGuard1 和 LlamaGuard2、WildGuard、OpenAI Mod API、GPT-4 的对比，以及图像方面与 GPT-4o mini 和 LlavaGuard 7B 的对比。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup><sup> • </sup><sup>[4](https://arxiv.org/html/2504.01081v2)</sup><sup> • </sup><sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> 资料中没有延迟测量数据，没有与 OpenAI 的 omni-moderation 或 [Azure AI Content Safety](https://www.edgepedia.org/zh/azure-ai-content-safety) 等托管审核 API 的价格比较，也没有使用情况的数据。资料未量化自托管开放权重与托管审核服务之间的成本权衡。

## 可用性、许可与部署

ShieldGemma 2 以 google/shieldgemma-2-4b-it 的名称在 [Hugging Face](https://www.edgepedia.org/zh/hugging-face) 上分发，基于 Gemma 3 的 4B IT 检查点训练，开放权重支持本地部署和微调。<sup>[5](https://huggingface.co/google/shieldgemma-2-4b-it)</sup> Google 表示所有支持 Gemma 3 的工具均支持 ShieldGemma 2，包括 [Transformers](https://www.edgepedia.org/zh/transformers)、JAX、Keras 和 Ollama，并可在 [Google Colab](https://www.edgepedia.org/zh/google-colab) 或用户自己的 GPU 上进行微调。<sup>[2](https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063)</sup>

## 反响、失效模式与批评

有据可查的局限性来自 Google 自己的报告。技术报告承认存在安全性与有用性之间的权衡：模型对策略违规的解读可能过于保守，在过滤大语言模型响应时可能干扰有用性，Google 建议下游客户根据用例调整过滤阈值。<sup>[3](https://arxiv.org/html/2407.21772v1)</sup> 模型卡补充称，ShieldGemma 对用户提供的安全原则描述高度敏感，在需要良好理解语言歧义和细微差别的条件下可能表现不可预测。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup>

覆盖范围在某些方面按设计就较为狭窄：文本模型仅覆盖英文四种危害类别，ShieldGemma 2 并未针对性内容、危险和暴力之外的图像策略进行专门微调，更广泛的危害策略覆盖留待未来工作。<sup>[4](https://arxiv.org/html/2504.01081v2)</sup><sup> • </sup><sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> Google 还警告称，评估内容审核的基准有限，因此训练和评估数据可能无法代表真实世界场景。<sup>[1](https://ai.google.dev/gemma/docs/shieldgemma/model_card)</sup> 除上述一般性歧义警告外，资料中未出现关于方言偏见、改写规避或多语言攻击的研究结果。

## References

1. ShieldGemma model card, Google AI for Developers. https://ai.google.dev/gemma/docs/shieldgemma/model_card
2. Safer and Multimodal: Responsible AI with Gemma, Google Developers Blog, March 2025. https://developers.googleblog.com/en/safer-and-multimodal-responsible-ai-with-gemma/?linkId=13401063
3. ShieldGemma: Generative AI Content Moderation Based on Gemma (technical report), arXiv, July 2024. https://arxiv.org/html/2407.21772v1
4. ShieldGemma 2: Robust and Tractable Image content Moderation (technical report), arXiv, April 2025. https://arxiv.org/html/2504.01081v2
5. google/shieldgemma-2-4b-it, Hugging Face. https://huggingface.co/google/shieldgemma-2-4b-it
6. Evaluating content safety with ShieldGemma and Hugging Face Transformers, Google AI for Developers. https://ai.google.dev/responsible/docs/safeguards/shieldgemma_on_huggingface

---
*Initially written Sep 17, 2026 · Edited: Oct 11, 2026; Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training › Safety methods, interpretability, and red-teaming

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/shieldgemma

English original: https://www.edgepedia.org/shieldgemma
