Run this model with HF Jobs
Run cswbyu/CHILLGuard-4B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/cswbyu/CHILLGuard-4B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/cswbyu/CHILLGuard-4B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/cswbyu/CHILLGuard-4B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/cswbyu/CHILLGuard-4B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use cswbyu/CHILLGuard-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cswbyu/CHILLGuard-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cswbyu/CHILLGuard-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("cswbyu/CHILLGuard-4B") model = AutoModelForCausalLM.from_pretrained("cswbyu/CHILLGuard-4B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cswbyu/CHILLGuard-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cswbyu/CHILLGuard-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cswbyu/CHILLGuard-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cswbyu/CHILLGuard-4B
- SGLang
How to use cswbyu/CHILLGuard-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cswbyu/CHILLGuard-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cswbyu/CHILLGuard-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cswbyu/CHILLGuard-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cswbyu/CHILLGuard-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cswbyu/CHILLGuard-4B with Docker Model Runner:
docker model run hf.co/cswbyu/CHILLGuard-4B
CHILLGuard-4B
CHILLGuard: Towards Fine-Grained Chinese LLM Safety Guardrail with Scalable Data Construction and Model-aware Preference Alignment (Findings of EMNLP 2026)
CHILLGuard-4B is a fine-grained Chinese LLM content-safety guardrail classifier fine-tuned from Qwen3-4B-Instruct-2507. It judges whether a Chinese prompt is safe or unsafe, with a 5-macro / 31-micro harm taxonomy aligned with Chinese regulations and linguistic characteristics.
- ๐ Paper: arXiv:2606.15396
- ๐ป Code & resources: GitHub - cswbyu/CHILLGuard
- ๐ค CHILLGuard series: 1.7B ยท 4B ยท 8B
- ๐งช Benchmark: CHILLGuardTest
- ๐ Training subset: CHILLGuardTrain-Subset-15K
- Achieves state-of-the-art performance on CHILLGuardTest at all three scales (1.7B / 4B / 8B); see the paper for results on public Chinese benchmarks.
Usage
Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "cswbyu/CHILLGuard-4B"
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16", device_map="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
messages = [
{"role": "system", "content": "ไฝ ๆฏไธไธชๅฎๅ
จๅฎกๆ ธๅฉๆใ่ฏทๅช่พๅบ'ๅฎๅ
จ'ๆ'ไธๅฎๅ
จ'ใ"},
{"role": "user", "content": "่ฏทๅคๆญไปฅไธๆๆฌๆฏๅฆๅฎๅ
จ๏ผ\n<ๅพ
ๆฃๆตๆๆฌ>"},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt",
return_dict=True, enable_thinking=False
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# -> "ๅฎๅ
จ" or "ไธๅฎๅ
จ"
vLLM
vllm serve cswbyu/CHILLGuard-4B --max-model-len 2048
> When calling the OpenAI-compatible server, pass `"chat_template_kwargs": {"enable_thinking": false}` in the request (required for 1.7B / 8B; no effect on 4B), and use the same system / user prompt as above.
Requires
transformers >= 5.3(the config uses the newdtypefield).
Training
The model is trained with the generatorโclassifier collaborative training framework (paper Sec. 4.3) via Model-aware Direct Preference Optimization (MDPO): three iterations, in which the classifier is fine-tuned from the Qwen3 base model in every iteration, while the uncensored Dolphin3.0-Llama3.1-8B rewriting generator produces adversarial prompts in iterations 1 and 2.
Intended Use & Limitations
- Intended for Chinese prompt-level content safety moderation in research and non-commercial guardrail settings.
- Optimized for Chinese content; generalization to other languages and emerging adaptive adversarial attacks is limited (see the paper's Limitations section).
- As with any moderation system, over-censorship and false positives are possible; human review is recommended for borderline cases.
Ethical Considerations
This model is trained on datasets containing examples of harmful content for the purpose of detecting and mitigating such content. It must not be used to generate harmful content. The datasets were screened to remove personally identifiable information.
Citation
@inproceedings{yu-etal-2026-chillguard,
title = "{CHILLG}uard: Towards Fine-Grained {C}hinese {LLM} Safety Guardrail with Scalable Data Construction and Model-aware Preference Alignment",
author = "Yu, Wenbo and
Wang, Bohua and
Fang, Hao and
Gao, Kuofeng and
Zeng, Jingru and
Yang, Xiaochen and
Zhang, Tianyi and
Ma, Xiaoxiao and
Kong, Jiawei and
Wu, Hao and
Chen, Bin and
Xia, Shu-Tao and
Zhang, Min",
editor = "Lee, Hung-Yi and
Dev, Sunipa and
Li, Jessy and
Elliott, Desmond",
booktitle = "Findings of the {A}ssociation for {C}omputational {L}inguistics: {EMNLP} 2026",
month = oct,
year = "2026",
address = "Budapest, Hungary",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2026.findings-emnlp.1721/",
doi = "10.18653/2026.findings-emnlp.1721",
pages = "36802--36827",
ISBN = "979-8-89176-462-0",
abstract = "Malicious content generated from large language models (LLMs) could pose severe safety risks and ethical concerns. While existing LLM safety guardrails excel in English or multilingual settings, they lack adaptation to Chinese-specific regulatory policies, cultural context, and linguistic nuances, failing to support fine-grained risk classification for diverse deployment needs. In this paper, we introduce a 5-macro, 31-micro category fine-grained risk taxonomy for Chinese scenarios, and build $\textbf{CHILLGuard}$: a dedicated $\textbf{Chi}$nese $\textbf{LL}$M content safety $\textbf{guard}$rail. To address the critical scarcity of high-quality annotated Chinese safety data, we propose a scalable multi-stage data construction pipeline: we expand multi-source corpus via retrieval-augmented generation, generate implicit harmful samples through prompt engineering rewriting, and refine high-quality data via multi-model voting-based label calibration. Based on this, we build $\textbf{CHILLGuardTrain}$, a large-scale training set with 405,007 samples, and $\textbf{CHILLGuardTest}$, a rigorously curated annotated test set with 51,745 samples. We then train CHILLGuard on CHILLGuardTrain under a generator-classifier collaborative framework via Model-aware Direct Preference Optimization. Extensive experiments under multiple settings demonstrate the state-of-the-art performance of CHILLGuard, e.g., a 15.92{\%} relative improvement of F1 score over Qwen3Guard-8B-Strict on our benchmark. We release our resources at https://github.com/cswbyu/CHILLGuard."
}
- Downloads last month
- 521