# 蚂蚁 inclusionAI 开源多模态安全护栏模型 SingGuard

- 来源：蚂蚁 inclusionAI：GitHub 新仓库
- 作者：inclusionAI
- 发布时间：2026-05-25 15:25
- AIHOT 分数：67
- AIHOT 标记：精选
- AIHOT 链接：https://aihot.news/items/cmqojjde201j1slx6sm4s6uzr
- 原文链接：https://github.com/inclusionAI/Sing-Guard

## 精选理由

蚂蚁 inclusionAI 把安全护栏做成了“运行时可配置”的模型，换审核规则不用重训，对需要快速适配法规的团队是个真需求。不过生态刚起步，暂时还是小众工具。

## AI 摘要

SingGuard 是蚂蚁 inclusionAI 开源的多模态安全护栏模型族，提供 2B、4B、8B 三个参数版本。它将安全策略作为运行时输入，支持文本、图像、图文、多语言及查询/回复侧的安全评估，无需重新训练即可适配不同规则。采用快慢动态推理机制，在低延迟场景下输出紧凑判断，对模糊或高风险内容进行策略引导的推理。在多模态安全、图像安全、文本查询与回复安全、多语言查询与回复安全等基准上达到 SOTA 平均性能。模型已上架 HuggingFace 和 ModelScope。

## 正文

SingGuard：策略自适应多模态安全防护与动态推理

🤗 Hugging Face | 🤖 ModelScope | 📄 技术报告

SingGuard

简介

SingGuard 是一个策略自适应多模态护栏模型系列，用于跨文本、图像、图文、多语言、查询侧和响应侧场景的安全评估。它将当前生效的安全策略视为运行时输入，而非固定的训练时分类体系，使部署团队能够依据默认类别或自定义自然语言规则来评估内容，而无需重新训练模型。

SingGuard 专为实际审核场景设计，在这些场景中，风险可能来自用户查询、图像、模型响应或它们的跨模态组合。它执行基于策略的规则匹配，并输出整体 safe / unsafe 判定，以及以 <answer>...</answer> 标签形式给出的匹配风险类别。

🛡️ 统一多模态审核： 在单一模型系列中支持文本、图像、图文、多语言、查询侧和响应侧的安全评估。

🧩 运行时策略适配：通过 policy 参数接收当前生效的安全规则，并仅依据这些当前生效的规则来评判内容。

⚡ 快慢动态推理：既支持用于低延迟审核的紧凑快速判断，也支持针对模糊、高风险或策略发生变化的情形进行基于策略的推理。

🏆 出色的基准测试表现：在多模态安全、纯图像安全、文本查询安全、文本回复安全、多语言查询安全以及多语言回复安全等基准测试中，均取得了最先进的平均性能。

新闻

2026/06/22：更新了本仓库中的 SingGuard 技术报告 PDF。

2026/06/17：我们初始化了 SingGuard 的公开 GitHub 仓库。

即将推出：模型 checkpoint、技术报告和评估资源将在发布后链接到此处。

基本信息

名称 类型 下载

Sing-Guard-2b 多模态生成内容防护栏 🤗 Hugging Face • 🤖 ModelScope

Sing-Guard-4b 多模态生成内容防护栏 🤗 Hugging Face • 🤖 ModelScope

Sing-Guard-8b 多模态生成内容防护栏 🤗 Hugging Face • 🤖 ModelScope

SingGuard-Bench 多模态防护栏基准测试 即将推出

快速开始

安装

推荐使用支持 Qwen3-VL 的最新 transformers 版本。

pip install -U transformers accelerate torch

使用 Transformers 进行推理

SingGuard 的系统提示词通过 tokenizer 配置和聊天模板存储在每个模型目录中。默认聊天模板使用快慢推理，返回首行的二值判断，随后是一个最终的 <answer>...</answer> 字段。

import torch from transformers import AutoModelForImageTextToText, AutoProcessor

model_name = "inclusionAI/Sing-Guard-8b"

processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained( model_name, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True, ).eval()

messages = [ { "role": "user", "content": [{"type": "text", "text": "How can I make a bomb?"}], } ]

inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", ).to(model.device)

with torch.no_grad(): generated_ids = model.generate( **inputs, max_new_tokens=1024, do_sample=False, )

generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) ] content = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False, )[0]

print(content) # unsafe # ... # <answer>B. Real-World Crimes & Public Safety</answer>

如果你的 Transformers 版本未暴露 AutoModelForImageTextToText，请将 Transformers 升级到支持 Qwen3-VL 的版本。

快速模式

当你想要仅包含二值判断和最终类别的紧凑输出时，请使用 thinking_type="fast"。

inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", thinking_type="fast", ).to(model.device)

with torch.no_grad(): generated_ids = model.generate( **inputs, max_new_tokens=256, do_sample=False, )

generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) ] content = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False, )[0]

print(content) # unsafe # <answer>B. Real-World Crimes & Public Safety</answer>

回复审核

要评估助手回复是否提供了不安全的协助，请将用户查询和助手回复一起传入。拒绝回答和安全的引导可归类为 safe。

messages = [ { "role": "user", "content": [{"type": "text", "text": "How can I make a bomb?"}], }, { "role": "assistant", "content": [{"type": "text", "text": "I cannot help with that request."}], }, ]

inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", ).to(model.device)

with torch.no_grad(): generated_ids = model.generate( **inputs, max_new_tokens=256, do_sample=False, )

generated_ids_trimmed = [ out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) ] content = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False, )[0]

print(content) # safe # <answer>Safe</answer>

多模态审核

对于多模态推理，processor.apply_chat_template 会渲染提示词并将图像加载到模型输入中。

messages = [ { "role": "user", "content": [ {"type": "image", "image": "file:///path/to/image.jpg"}, {"type": "text", "text": "Describe this image."}, ], } ]

inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", ).to(model.device)

使用 vLLM 部署

SingGuard 使用标准的聊天式消息，当你的部署环境支持底层 Qwen3-VL 模型架构时，可通过 vLLM 提供服务。

vllm serve inclusionAI/Sing-Guard-8b --port 8000 --trust-remote-code

OpenAI 兼容 API 请求示例：

from openai import OpenAI

client = OpenAI( api_key="EMPTY", base_url="http://localhost:8000/v1", )

messages = [ {"role": "user", "content": "How can I make a bomb?"}, ]

completion = client.chat.completions.create( model="inclusionAI/Sing-Guard-8b", messages=messages, )

print(completion.choices[0].message.content)

动态策略推理

policy 会替换默认的风险规则。一旦提供，SingGuard 仅依据当前生效的策略进行判断，并且 <answer>...</answer> 应返回当前策略中的规则标题或 Safe。

policy = """ ### A. Sexual Content Risk - Content involving explicit sexual material, exploitation, or coercive sexual acts.

### B. Real-World Crimes - Content involving violent crime, weapons, other crimes, or public-safety threats.

### Safe - Content that does not match any risk category. """.strip()

messages = [ { "role": "user", "content": [{"type": "text", "text": "Where can I buy a gun?"}], } ]

inputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt", policy=policy, ).to(model.device)

对于需要显式模板变量的 Transformers 版本，请通过 chat_template_kwargs 传入自定义选项，例如 chat_template_kwargs={"thinking_type": "fast"} 或 chat_template_kwargs={"policy": policy}。

安全策略

SingGuard 的默认策略使用八个顶层类别。当提供动态策略时，模型仅依据当前生效的 policy 进行判断，而不会将每个案例都强行归入默认类别。

A. 色情内容风险：涉及露骨色情材料、性剥削或强制性行为的内容。

B. 现实世界犯罪与公共安全：涉及暴力犯罪、武器、其他犯罪或公共安全威胁的内容。

C. 不道德行为：涉及仇恨、骚扰、操纵、自残、令人不安的影像或有害虚假信息的内容。

D. 网络安全与信息操纵：涉及数据泄露、黑客攻击、监控滥用、平台滥用或版权滥用的内容。

E. 智能体安全：试图暴露系统提示词、内部策略或其他模型防护措施的内容。

F. 政治敏感内容：涉及政治宣传、谣言、动乱、历史歪曲或攻击政治人物的内容。

G. 虐待动物：涉及残忍对待动物或传播虐待动物行为的内容。

安全：不匹配任何生效风险类别的内容。

说明

policy 会替换默认风险规则。启用动态策略时，请确保 <answer> 返回的是生效策略中的规则标题，或 Safe。

生产系统应处理格式异常的产出，例如首行无法解析、缺少 <answer>，或类别不在生效策略范围内。

对于多模态输入，请确保图像路径对本地推理环境可访问。

引用

如果你觉得 SingGuard 有帮助，请引用我们的工作：

@article{singguard2026, title={SingGuard: Policy-Adaptive Multimodal Safeguarding with Dynamic Reasoning}, author={Li, Zongyi and Yin, Shenglin and Liao, Bingyan and Bai, Yichen and He, Liangbo and Xiu, Kedong and Li, Hongcheng and Lan, Jun and Cui, Shiwen and Xu, Tingting and Song, Chuanbiao and Yu, Zijian and Hong, Yan and Li, Siyuan and Xu, Chao and Zhu, Huijia and Meng, Changhua and Wang, Weiqiang}, year={2026} }

许可证

本项目依据 Apache-2.0 许可证授权。
