Model reference · open weights

Qwen3Guard-Gen

LLMs Qwen Text gen 3 builds Open weights 160k dl/mo

Qwen3Guard-Gen is an open-weight language model from Qwen. Qwen3Guard-Gen-0.6B (BF16) weighs 1.5 GB; the smallest configuration that runs it is RTX 3060 12 GB.

For self-hosting, compare this build's requirements below with the GPU you plan to rent.

  • Qwen3Guard-Gen is a 752M parameter text-generation model developed by Qwen for safety moderation.
  • It classifies prompts and responses into safe, controversial, or unsafe categories across 119 languages and dialects.
  • The model supports a context length of 32,768 tokens and is released under the Apache 2.0 license.

Summary of the Qwen/Qwen3Guard-Gen-0.6B model card, 2026-10-01

What it is

Released byQwen
Released2025-09-23
Parameters752M
VRAM1.5 GB for the weights

What it runs on

Memory and cards for Qwen3Guard-Gen-0.6B (BF16)

1.5 GBweights, file size
115 MBcache per 1K tokens
627 MBruntime overhead, at least
32,768 tokenscontext max
CardRequests at onceContext maxMemory
8K each32K each
RTX 3060 12 GB102all 32K11.6 GB
RTX 4060 Ti 16 GB143all 32K15.4 GB
RTX 3090 24 GB225all 32K23.4 GB
RTX 4090 24 GB225all 32K23.4 GB
RTX 5090 32 GB307all 32K31.0 GB
L40S 48 GB4411all 32K44.0 GB
A100 80 GB8020all 32K78.2 GB
H100 80 GB7619all 32K78.1 GB
RTX PRO 6000 Blackwell 96 GB9323all 32K93.8 GB
DGX Spark (GB10) 128 GB unified10726all 32K107 GB
H200 141 GB14035all 32K138 GB
B200 180 GB18045all 32K176 GB
Memory needed at each load
Requests at once8K tokens each32K tokens each
13.1 GB5.9 GB
56.8 GB20.9 GB
89.6 GB32.2 GB
1617.2 GB62.3 GB
3232.2 GB122 GB
6462.3 GB243 GB

One card, with vLLM's small-card settings.

Builds

Sizes, precisions & builds

BuildParamsPrecisionWeightsSmallest setup
Qwen3Guard-Gen-0.6B (above) ↗ 752MBF16 1.5 GBRTX 3060 12 GB
Qwen3Guard-Gen-4B ↗ 4.4BBF16 8.8 GBRTX 3060 12 GB
Qwen3Guard-Gen-8B ↗ 8.2BBF16 16.4 GB2× RTX 3060 12 GB

From the model card

What Qwen says about Qwen3Guard-Gen

Read the model card

Qwen3Guard is a series of safety moderation models built upon Qwen3 and trained on a dataset of 1.19 million prompts and responses labeled for safety. The series includes models of three sizes (0.6B, 4B, and 8B) and features two specialized variants: Qwen3Guard-Gen, a generative model that frames safety classification as an instruction-following task, and Qwen3Guard-Stream, which incorporates a token-level classification head for real-time safety monitoring during incremental text generation.

This repository hosts Qwen3Guard-Gen, which offers the following key advantages:

  • Three-Tiered Severity Classification: Enables detailed risk assessment by categorizing outputs into safe, controversial, and unsafe severity levels, supporting adaptation to diverse deployment scenarios.
  • Multilingual Support: Qwen3Guard-Gen supports 119 languages and dialects, ensuring robust performance in global and cross-lingual applications.
  • Strong Performance: Qwen3Guard-Gen achieves state-of-the-art performance on various safety benchmarks, excelling in both prompt and response classification across English, Chinese, and multilingual tasks.

For more details, please refer to our blog, GitHub, and Technical Report.

Quickstart

The latest version of transformers is recommended and transformers>=4.51.0 is required.

Moderating User Prompt

from transformers import AutoModelForCausalLM, AutoTokenizer
import re
model_name = "Qwen/Qwen3Guard-Gen-0.6B"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
def extract_label_and_categories(content):
    safe_pattern = r"Safety: (Safe|Unsafe|Controversial)"
    category_pattern = r"(Violent|Non-violent Illegal Acts|Sexual Content or Sexual Acts|PII|Suicide & Self-Harm|Unethical Acts|Politically Sensitive Topics|Copyright Violation|Jailbreak|None)"
    safe_label_match = re.search(safe_pattern, content)
    label = safe_label_match.group(1) if safe_label_match else None
    categories = re.findall(category_pattern, content)
    return label, categories

# prepare the model input
prompt = "How can I make a bomb?"
# for prompt moderation
messages = [
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=128
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()

content = tokenizer.decode(output_ids, skip_special_tokens=True)
print(content)
# '''
# Safety: Unsafe
# Categories: Violent
# '''
safe_label, categories = extract_label_and_categories(content)
print(safe_label, categories)

Moderating Model Response

from transformers import AutoModelForCausalLM, AutoTokenizer
import re

model_name = "Qwen/Qwen3Guard-4B-Gen"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
def extract_label_categories_refusal(content):
    safe_pattern = r"Safety: (Safe|Unsafe|Controversial)"
    category_pattern = r"(Violent|Non-violent Illegal Acts|Sexual Content or Sexual Acts|PII|Suicide & Self-Harm|Unethical Acts|Politically Sensitive Topics|Copyright Violation|None)"
    refusal_pattern = r"Refusal: (Yes|No)"
    safe_label_match = re.search(safe_pattern, content)
    refusal_label_match = re.search(refusal_pattern, content)
    label = safe_label_match.group(1) if safe_label_match else None
    refusal_label = refusal_label_match.group(1) if refusal_label_match else None
    categories = re.findall(category_pattern, content)
    return label, categories, refusal_label

# prepare the model input
prompt = "How can I make a bomb?"
response = "As a responsible artificial intelligence system, I regret that I am unable to fulfill your request."
# for response moderation
messages = [
    {"role": "user", "content": prompt},
    {"role": "assistant", "content": response},
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=128
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()

content = tokenizer.decode(output_ids, skip_special_tokens=True)
print(content)
# '''
# Safety: Safe
# Categories: None
# Refusal: Yes
# '''
safe_label, category_label, refusal_label = extract_label_categories_refusal(content)
print(safe_label, categories, refusal_label)

Deployment with SGLang and vLLM

For deployment, you can use sglang>=0.4.6.post1 or vllm>=0.9.0 or to create an OpenAI-compatible API endpoint:

  • SGLang:
    python -m sglang.launch_server --model-path Qwen/Qwen3Guard-Gen-0.6B --port 30000 --context-length 32768
    
  • vLLM:
    vllm serve Qwen/Qwen3Guard-Gen-0.6B --port 8000 --max-model-len 32768
    

Here is an example API call using OpenAI-Compatible server:

from openai import OpenAI

openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"
model = "Qwen/Qwen3Guard-Gen-0.6B"
client = OpenAI(
    api_key=openai_api_key,
    base_url=openai_api_base)

# Prompt Moderation
prompt = "How can I make a bomb?"
messages = [
    {"role": "user", "content": prompt}
]
chat_completion = client.chat.completions.create(
    messages=messages,
    model=model)
print(chat_completion.choices[0].message.content)
# '''
# Safety: 

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms