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. 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
- 🤖 Guardrail models: CHILLGuard-1.7B · CHILLGuard-4B · CHILLGuard-8B
- 📚 Datasets: CHILLGuardTest · CHILLGuardTrain-Subset-15K
- 💻 Code & resources: GitHub - cswbyu/CHILLGuard
- Achieves state-of-the-art performance on Chinese content-safety benchmarks (see the paper for detailed evaluation results).
Usage
Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "cswbyu/CHILLGuard-4B"
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
messages = [
{"role": "system", "content": "你是一个安全审核助手。请只输出'安全'或'不安全'。"},
{"role": "user", "content": "请判断以下文本是否安全:\n<待检测文本>"},
]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", enable_thinking=False
).to(model.device)
outputs = model.generate(inputs, max_new_tokens=5, do_sample=False)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
# -> "安全" or "不安全"
vLLM
vllm serve cswbyu/CHILLGuard-4B --max-model-len 4096
Requires
transformers >= 5.3(the config uses the newdtypefield).
Training
The model is trained with the generator–classifier collaborative training framework via Model-aware Direct Preference Optimization (MDPO) described in the paper: three iterations of adversarial prompt generation (uncensored Dolphin3.0-Llama3.1-8B rewriting generator) and full-parameter SFT of the Qwen3 classifier on the assembled training set (CHILLGuardTrain + adversarial augmentations).
Intended Use & Limitations
- Intended for Chinese prompt-level content safety moderation in research and production 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
@misc{yu2026chillguard,
title={CHILLGuard: Towards Fine-Grained Chinese LLM Safety Guardrail with Scalable Data Construction and Model-aware Preference Alignment},
author={Wenbo Yu and Bohua Wang and Hao Fang and Kuofeng Gao and Jingru Zeng and Xiaochen Yang and Tianyi Zhang and Xiaoxiao Ma and Jiawei Kong and Hao Wu and Bin Chen and Shu-Tao Xia and Min Zhang},
year={2026},
eprint={2606.15396},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2606.15396}
}
- Downloads last month
- 5