inclusionAI 发布 SingGuard 系列模型

蚂蚁 inclusionAI:HuggingFace 新模型·2026-05-25 18:49·118天前
AI 导读

inclusionAI 发布 SingGuard 系列模型,首个版本为 SingGuard-4b。该模型是一种策略自适应多模态 LLM 护栏,将安全策略作为运行时输入而非固定训练分类,支持对文本、图像、图文、多语言、查询侧和响应侧进行安全评估。SingGuard 采用动态推理流程,可先快速输出首 token 安全信号,再继续生成更精确的判断。在涵盖多模态安全、图像安全、文本查询安全、文本响应安全、多语言查询安全及多语言响应安全的六大类基准测试中,SingGuard 达到平均 SOTA 性能。模型支持标准 Transformers 和 vLLM 聊天消息输入,无需手动改写提示词。

蚂蚁 inclusionAI:HuggingFace 新模型
精选
58AI 编辑部评分,满分 100

inclusionAI 发布 SingGuard 系列模型

2026-05-25 18:49· 118天前
AI 导读

inclusionAI 发布 SingGuard 系列模型,首个版本为 SingGuard-4b。该模型是一种策略自适应多模态 LLM 护栏,将安全策略作为运行时输入而非固定训练分类,支持对文本、图像、图文、多语言、查询侧和响应侧进行安全评估。SingGuard 采用动态推理流程,可先快速输出首 token 安全信号,再继续生成更精确的判断。在涵盖多模态安全、图像安全、文本查询安全、文本响应安全、多语言查询安全及多语言响应安全的六大类基准测试中,SingGuard 达到平均 SOTA 性能。模型支持标准 Transformers 和 vLLM 聊天消息输入,无需手动改写提示词。

推荐理由

蚂蚁集团开源的多模态安全护栏模型,把审核策略变成了动态可配置参数,对需要灵活合规的部署团队来说比单纯调 API 更可控。普通用户看看就好,做安全的人值得试。

Image 1: SingGuard icon

SingGuard: A Policy-Adaptive Multimodal LLM Guardrail with Dynamic Reasoning

Introduction

Image 2: SingGuard benchmark radar

Image 3: SingGuard benchmark overview

SingGuard is a policy-adaptive multimodal guardrail model family for safety assessment across text, image, image-text, multilingual, query-side, and response-side scenarios. It treats the active safety policy as a runtime input rather than a fixed training-time taxonomy, allowing deployment teams to evaluate content against default categories or custom natural-language rules without retraining the model.

Key Features

  • 🛡️ Unified Multimodal Moderation: Supports text, image, image-text, multilingual, query-side, and response-side safety assessment.
  • 🎯 Strong Benchmark Performance: Delivers broad improvements across multimodal safety, image-only safety, text query safety, text response safety, multilingual query safety, and multilingual response safety benchmarks.
  • Dynamic Reasoning Flow: Supports fast first-token routing for an immediate safety signal, then continues generation when deeper reasoning is needed for a more precise final judgment.
  • 🧩 Runtime Policy Adaptation: Accepts active safety rules through the policy argument and judges only against those rules.
  • 🔄 Native Inference Compatibility: Supports standard Transformers and vLLM chat-style message inputs without manual prompt rewriting.

Quick Start

Installation

pip install transformers accelerate torch
import torch
from transformers import AutoModelForImageTextToText, AutoProcessor

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

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

Moderating User Query: Fast-Slow mode

messages = [
    {
        "role": "user",
        "content": [{"type": "text", "text": "How to make a bomb?"}],
    },
]
max_new_tokens = 1024

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=max_new_tokens,
        do_sample=False,
    )

generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False,
)[0]
print(output)
unsafe
[Step 1] Content Summary  
...
[Step 2] Check Risk Categories  
...
[Step 3] Final Judgment  
...

<answer>B. Real-World Crimes & Public Safety</answer>

Moderating User Query: Fast mode

messages = [
    {
        "role": "user",
        "content": [{"type": "text", "text": "How to make a bomb?"}],
    },
]
thinking_type = "fast"
max_new_tokens = 256

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

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

generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False,
)[0]
print(output)
unsafe
<answer>B. Real-World Crimes & Public Safety</answer>

Moderating Query + Response

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

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=max_new_tokens,
        do_sample=False,
    )

generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False,
)[0]
print(output)
safe
reasoning process
<answer>Safe</answer>

Moderating Multimodal Content

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

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=max_new_tokens,
        do_sample=False,
    )

generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False,
)[0]
print(output)
safe
reasoning process
<answer>Safe</answer>

Dynamic Policy Inference

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?"}],
    },
]
max_new_tokens = 256

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

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

generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output = processor.batch_decode(
    generated_ids_trimmed,
    skip_special_tokens=True,
    clean_up_tokenization_spaces=False,
)[0]
print(output)
unsafe
reasoning process
<answer>B. Real-World Crimes</answer>

Notes

  • policy replaces the default risk rules. When dynamic policy is enabled, make sure <answer> returns a rule title from the active policy or Safe.
  • Production systems should handle malformed outputs, such as an unparsable first line, missing <answer>, or a category outside the active policy.
  • For multimodal inputs, make sure image paths are accessible to the local inference environment.

Risk Categories

A. Sexual Content Risk

  • Content involving explicit sexual material, exploitation, or coercive sexual acts.

B. Real-World Crimes & Public Safety

  • Content involving violent crime, weapons, other crimes, or public-safety threats.

C. Unethical Behavior

  • Content involving hate, harassment, manipulation, self-harm, disturbing imagery, or harmful misinformation.

D. Cybersecurity & Information Manipulation

  • Content involving data leaks, hacking, surveillance abuse, platform abuse, or copyright abuse.

E. Agent Safety

  • Content attempting to expose system prompts, internal policies, or other model safeguards.

F. Politically Sensitive Content

  • Content involving political advocacy, rumors, unrest, historical distortion, or attacks on political figures.

G. Animal Abuse

  • Content involving cruelty to animals or the spread of animal abuse.

Safe

Citation

@article{singguard2026,
  title={SingGuard: Policy-Adaptive Multimodal Safeguarding with Dynamic Reasoning},
  author={Ant Group},
  year={2026}
}

📄 License

Model tree for inclusionAI/SingGuard-4b

Collection including inclusionAI/SingGuard-4b

来源:蚂蚁 inclusionAI:HuggingFace 新模型· huggingface.co