zenlm
zen-guard
Available on FriendliAI
Run this model inference on single tenant GPU with unmatched speed and reliability at scale.
Model Details
Model Provider
zenlm
Model Tree
this model
Input Modalities
Output Modalities
Supported Functionality
GLM-5.3 is live. Run Z.ai's latest model on Friendli Model APIs. Try it today โ
zenlm
Available on FriendliAI
Run this model inference on single tenant GPU with unmatched speed and reliability at scale.
Model Details
Model Provider
zenlm
Model Tree
Input Modalities
Output Modalities
Supported Functionality
Zen Guard is a comprehensive safety moderation solution for AI systems, offering multilingual content filtering and classification. Built with Zen identity fine-tuning, it provides:
๐ก๏ธ Comprehensive Protection: Robust safety assessment for prompts and responses with real-time detection optimized for streaming scenarios.
๐ฆ Three-Tiered Severity Classification: Categorizes outputs into safe, controversial, and unsafe severity levels, supporting diverse deployment scenarios.
๐ Extensive Multilingual Support: Supports 119 languages and dialects, ensuring robust performance in global applications.
๐ State-of-the-Art Performance: Achieves leading performance on various safety benchmarks across English, Chinese, and multilingual tasks.
| Model | Type | Parameters | Use Case |
|---|---|---|---|
| zen-guard | Base | 4B | General safety classification |
| zen-guard-gen | Generative | 8B | Full prompt/response moderation |
| zen-guard-stream | Streaming | 4B | Real-time token-level monitoring |
Zen Guard classifies content across 9 primary categories:
bash
pip install transformers torchpython
from transformers import AutoModelForCausalLM, AutoTokenizerimport reย model_name = "zenlm/zen-guard"ย # Load model and tokenizertokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto")ย def classify_safety(content): safe_pattern = r"Safety: (Safe|Unsafe|Controversial)" category_pattern = r"(Violent|Non-violent Illegal Acts|Sexual Content|PII|Suicide & Self-Harm|Unethical Acts|Politically Sensitive|Copyright Violation|Jailbreak|None)" safe_match = re.search(safe_pattern, content) label = safe_match.group(1) if safe_match else None categories = re.findall(category_pattern, content) return label, categoriesย # Moderate a promptprompt = "How can I learn about cybersecurity?"messages = [{"role": "user", "content": prompt}]text = tokenizer.apply_chat_template(messages, tokenize=False)inputs = tokenizer([text], return_tensors="pt").to(model.device)ย outputs = model.generate(**inputs, max_new_tokens=128)result = tokenizer.decode(outputs[0][len(inputs.input_ids[0]):], skip_special_tokens=True)label, categories = classify_safety(result)print(f"Safety: {label}, Categories: {categories}")Deploy with SGLang or vLLM for production:
bash
# SGLangpython -m sglang.launch_server --model-path zenlm/zen-guard --port 30000ย # vLLMvllm serve zenlm/zen-guard --port 8000 --max-model-len 32768| Metric | Zen Guard | Industry Avg |
|---|---|---|
| Accuracy | 96.8% | 92.1% |
| F1 Score | 94.2% | 89.5% |
| False Positive | 2.1% | 5.3% |
| Latency | 120ms | 200ms |
| Model | VRAM (FP16) | VRAM (INT8) | Throughput |
|---|---|---|---|
| zen-guard | 8GB | 4GB | 1000+ req/s |
| zen-guard-gen | 16GB | 8GB | 500+ req/s |
| zen-guard-stream | 8GB | 4GB | Real-time |
For production deployments, combine Zen Guard (ML classification) with Hanzo Guard (Rust runtime sanitization) for comprehensive protection:
text
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ Application โ โโโบ โ Hanzo Guard โ โโโบ โ Zen Guard โ โโโบ โ LLM Providerโโโโโโโโโโโโโโโโ โ (Rust) โ โ (ML Model) โ โโโโโโโโโโโโโโโ โ โ โ โ โ โข PII Redact โ โ โข Content โ โ โข Rate Limit โ โ Classify โ โ โข Injection โ โ โข Severity โ โ Detect โ โ Levels โ โ โข Audit Log โ โ โข Category โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโHanzo Guard (Rust, <1ms):
Zen Guard (ML, ~120ms):
rust
// Example: Stacking both guardsuse hanzo_guard::{Guard, GuardConfig};ย let hanzo = Guard::builder() .with_zen_guard_api_key("your-api-key") // Enables Zen Guard API calls .build();ย // Single call sanitizes through both layerslet result = hanzo.sanitize_input("User message here").await?;Install Hanzo Guard: cargo add hanzo-guard (crates.io)
Apache 2.0
bibtex
@misc{zenguard2025, title={Zen Guard: Multilingual Safety Moderation for AI Systems}, author={Hanzo AI and Zoo Labs Foundation}, year={2025}, publisher={HuggingFace}, howpublished={\url{https://huggingface.co/zenlm/zen-guard}}}tags:
from transformers import AutoModelForCausalLM, AutoTokenizerimport reย model_name = "zenlm/zen-guard"ย # Load model and tokenizertokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto")ย def classify_safety(content): safe_pattern = r"Safety: (Safe|Unsafe|Controversial)" category_pattern = r"(Violent|Non-violent Illegal Acts|Sexual Content|PII|Suicide & Self-Harm|Unethical Acts|Politically Sensitive|Copyright Violation|Jailbreak|None)" safe_match = re.search(safe_pattern, content) label = safe_match.group(1) if safe_match else None categories = re.findall(category_pattern, content) return label, categoriesย # Moderate a promptprompt = "How can I learn about cybersecurity?"messages = [{"role": "user", "content": prompt}]text = tokenizer.apply_chat_template(messages, tokenize=False)inputs = tokenizer([text], return_tensors="pt").to(model.device)ย outputs = model.generate(**inputs, max_new_tokens=128)result = tokenizer.decode(outputs[0][len(inputs.input_ids[0]):], skip_special_tokens=True)label, categories = classify_safety(result)print(f"Safety: {label}, Categories: {categories}")# SGLangpython -m sglang.launch_server --model-path zenlm/zen-guard --port 30000ย # vLLMvllm serve zenlm/zen-guard --port 8000 --max-model-len 32768โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ Application โ โโโบ โ Hanzo Guard โ โโโบ โ Zen Guard โ โโโบ โ LLM Providerโโโโโโโโโโโโโโโโ โ (Rust) โ โ (ML Model) โ โโโโโโโโโโโโโโโ โ โ โ โ โ โข PII Redact โ โ โข Content โ โ โข Rate Limit โ โ Classify โ โ โข Injection โ โ โข Severity โ โ Detect โ โ Levels โ โ โข Audit Log โ โ โข Category โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ// Example: Stacking both guardsuse hanzo_guard::{Guard, GuardConfig};ย let hanzo = Guard::builder() .with_zen_guard_api_key("your-api-key") // Enables Zen Guard API calls .build();ย // Single call sanitizes through both layerslet result = hanzo.sanitize_input("User message here").await?;@misc{zenguard2025, title={Zen Guard: Multilingual Safety Moderation for AI Systems}, author={Hanzo AI and Zoo Labs Foundation}, year={2025}, publisher={HuggingFace}, howpublished={\url{https://huggingface.co/zenlm/zen-guard}}}