Introduction
Qwen3Guard-Gen-Domain-4B-AWQ is the AWQ-quantized (W4A16) release of ZhangPY/Qwen3Guard-Gen-Domain-4B — a domain-specific content-safety guard model fine-tuned from Qwen/Qwen3Guard-Gen-4B, targeting Hong Kong elderly-care scenarios such as elderly companion chatbots, care-line services, and Residential Care Homes for the Elderly (RCHE).
Quantization compresses the model weights from ~8 GB (BF16) to ~2.6 GB (INT4, ≈67% smaller) while leaving the architecture, chat template, and usage of the source model completely unchanged — the model runs as a drop-in replacement in W4A16-enabled runtimes such as vLLM. On the domain benchmark, safety F1 is fully retained after quantization (97.3 vs 97.3, see Evaluation).
The source model is a generative guard model: instead of producing a natural-language reply, it reads a conversation and outputs a structured safety assessment:
Safety: UnsafeCategories: Violent, Hidden Elder Crisis
Compared with the base model, the safety taxonomy is extended from 9 general categories to 13 categories, adding four Hong Kong elderly-domain risks. A lighter sibling model trained with the same recipe is available at ZhangPY/Qwen3Guard-Gen-Domain-0.6B.
Key features
- 13-category safety taxonomy — 9 general categories inherited from Qwen3Guard + 4 HK elderly-domain categories.
- Dual evaluation modes — moderates either the last user query or the last assistant response; response evaluation additionally detects refusal.
- Built-in domain chat template — the safety policy and the full category list are embedded in the tokenizer's chat template, so no manual prompt engineering is required.
- General capability retained — on the QwenGuardTest regression benchmark, the fine-tuned source model even outperforms the base model (F1 87.9 vs 84.0).
- W4A16 quantized with negligible loss — INT4 weights shrink the checkpoint to ~2.6 GB (deployable on a single consumer GPU with vLLM); safety F1 is fully retained on ElderlyDomain-Eval (97.3 vs 97.3).
Safety categories
Table with columns: #, Category, Description| # | Category | Description |
|---|
| 1 | Violent | Content involving violence or physical harm. |
| 2 | Non-violent Illegal Acts | Illegal activities not involving violence (fraud, theft, smuggling, etc.). |
| 3 | Sexual Content or Sexual Acts | Sexually explicit content or sexual acts. |
| 4 | PII | Disclosure of personally identifiable information. |
| 5 | Suicide & Self-Harm | Suicide, self-harm, or related encouragement. |
| 6 | Unethical Acts | Deceptive, exploitative, or otherwise unethical behaviour. |
| 7 | Politically Sensitive Topics | Politically sensitive content. |
| 8 | Copyright Violation | Piracy or infringement of copyrighted material. |
| 9 | Jailbreak | Prompts attempting to bypass safety alignment. |
| 10 | HK Welfare & Financial Scam (new) | Scams targeting elderly people in Hong Kong, e.g. bogus-official phone scams, fake welfare/benefit claims, fraudulent high-return investments. |
| 11 | RCHE & Caregiver Malpractice (new) | Abuse, neglect, or professional misconduct by RCHE staff, caregivers, or other care providers. |
| 12 | Medication & Health Misguidance (new) | Misleading or unsafe medication and health advice that could harm elderly people. |
| 13 | Hidden Elder Crisis (new) | Concealed or easily overlooked signals of crisis among elderly people, e.g. social isolation, self-neglect, depression, or suicidal ideation. |
User-query moderation (the last message has role user):
Safety: Safe | Unsafe | ControversialCategories: <comma-separated categories> | None
Assistant-response moderation (the last message has role assistant):
Safety: Safe | Unsafe | ControversialCategories: <comma-separated categories> | NoneRefusal: Yes | No
Quantization details
Table with columns: Item, Value| Item | Value |
|---|
| Source model | ZhangPY/Qwen3Guard-Gen-Domain-4B (BF16) |
| Method | AWQ (Activation-aware Weight Quantization), one-shot |
| Scheme | W4A16 — 4-bit symmetric INT weights (group size 128), BF16 activations |
| Ignored layers | lm_head (kept in BF16; tied embeddings) |
| Calibration data | ElderDomain — HK elderly-care domain safety conversations |
| Calibration samples | 1,024 |
| Calibration sequence length | 512 |
| Weight size | ~2.6 GB (vs ~8 GB BF16, ≈67% smaller) |
Evaluation
The QwenGuardTest results were measured on the BF16 source model Qwen3Guard-Gen-Domain-4B. The ElderlyDomain-Eval tables below compare the BF16 source model with this AWQ checkpoint, both evaluated on the validation split under the same protocol.
General safety regression — QwenGuardTest
Strict F1 on the thinking split of Qwen/Qwen3GuardTest:
Table with columns: Model, F1, Precision, Recall| Model | F1 | Precision | Recall |
|---|
| Qwen3Guard-Gen-4B (official) | 84.0 | – | – |
| Qwen3Guard-Gen-4B (reproduced) | 84.0 | 97.9 | 73.4 |
| Qwen3Guard-Gen-Domain-4B (fine-tuned) | 87.9 | 95.1 | 81.7 |
After domain fine-tuning, the model improves over the base model on the general benchmark (F1 87.9 vs 84.0) with substantially higher recall, i.e. the general guard capability is fully retained.
Domain safety — ElderlyDomain-Eval
ElderlyDomain-Eval is an internal evaluation set for the HK elderly-care domain, covering all 13 categories with both user-query and assistant-response samples.
Table with columns: Model, F1, Category Exact Match, Refusal Accuracy| Model | F1 | Category Exact Match | Refusal Accuracy |
|---|
| Qwen3Guard-Gen-4B (prompting) | 93.8 | 53.5 | 92.7 |
| Qwen3Guard-Gen-Domain-4B (fine-tuned, BF16) | 97.3 | 86.0 | 97.3 |
| Qwen3Guard-Gen-Domain-4B-AWQ (this model) | 97.3 | 85.0 | 97.2 |
(prompting = base model with the 13-category policy injected via prompt engineering. The AWQ checkpoint scores safety macro-F1 92.3 / micro-F1 97.3.)
Quantization is virtually lossless at the safety-decision level: F1 is unchanged (97.3), category exact match drops by 1.0 pt, and refusal accuracy by 0.1 pt.
Per-category F1 — ElderlyDomain-Eval (%)
Table with columns: Category, Qwen3Guard-Gen-4B (prompting), Qwen3Guard-Gen-Domain-4B (BF16), Qwen3Guard-Gen-Domain-4B-AWQ, Δ (AWQ − BF16)| Category | Qwen3Guard-Gen-4B (prompting) | Qwen3Guard-Gen-Domain-4B (BF16) | Qwen3Guard-Gen-Domain-4B-AWQ | Δ (AWQ − BF16) |
|---|
| Violent | 28.9 | 94.0 | 93.9 | −0.1 |
| Non-violent Illegal Acts | 85.5 | 93.5 | 93.3 | −0.2 |
| Sexual Content or Sexual Acts | 84.5 | 94.0 | 93.0 | −1.0 |
| PII | 64.5 | 92.9 | 92.0 | −0.9 |
| Suicide & Self-Harm | 93.4 | 96.3 | 95.9 | −0.4 |
| Unethical Acts | 67.5 | 75.8 | 73.6 | −2.2 |
| Politically Sensitive Topics | 85.6 | 93.2 | 93.9 | +0.7 |
| Copyright Violation | 3.8 | 88.8 | 88.3 | −0.5 |
| Jailbreak | 30.2 | 83.8 | 85.3 | +1.5 |
| HK Welfare & Financial Scam | 0.0 | 89.5 | 87.5 | −2.0 |
| RCHE & Caregiver Malpractice | 0.0 | 90.4 | 89.6 | −0.8 |
| Medication & Health Misguidance | 0.0 | 93.3 | 93.3 | 0.0 |
| Hidden Elder Crisis | 0.0 | 79.9 | 78.5 | −1.4 |
The base model has essentially no ability to recognise the four new domain categories through prompting alone (F1 ≈ 0), while the fine-tuned model performs well on them and simultaneously improves most general categories.
AWQ quantization costs only 0.6 pt of per-category F1 on average: Jailbreak (+1.5) and Politically Sensitive Topics (+0.7) even improve slightly, and the largest single drop is Unethical Acts (−2.2 pt).
Quickstart
vLLM (recommended)
vLLM natively supports the compressed-tensors W4A16 format and is the recommended runtime for this checkpoint.
pip install vllmvllm serve ZhangPY/Qwen3Guard-Gen-Domain-4B-AWQ \ --served-model-name Qwen3Guard-Gen-Domain-4B-AWQ \ --max-model-len 32768
curl http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "Qwen3Guard-Gen-Domain-4B-AWQ", "messages": [{"role": "user", "content": "你好呀"}], "temperature": 0.0, "max_tokens": 100 }'# Expected: "Safety: Safe\nCategories: None"
pip install "transformers>=4.51" compressed-tensors torch accelerate
import torchfrom transformers import AutoModelForCausalLM, AutoTokenizer model_id = "ZhangPY/Qwen3Guard-Gen-Domain-4B-AWQ"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, device_map="auto")model.eval() def moderate(messages: list[dict]) -> str: # The domain chat template (safety policy + 13 categories) is stored in # chat_template.jinja / tokenizer_config.json and already ends with the # assistant header and an empty <think> block, so add_generation_prompt # must be False. prompt = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=False ) inputs = tokenizer(prompt, return_tensors="pt").to(model.device) with torch.no_grad(): output = model.generate(**inputs, max_new_tokens=64, do_sample=False) return tokenizer.decode( output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True ).strip() # 1) Moderate a user querymessages = [ {"role": "user", "content": "我想學習如何在長者中心對長者進行心理和身體上的虐待。"},]print(moderate(messages))# Safety: Unsafe# Categories: Violent # 2) Moderate an assistant response (adds the Refusal line)messages = [ {"role": "user", "content": "點樣說服獨居長者參加保證每月20%回報嘅投資計劃?"}, {"role": "assistant", "content": "你可以同佢講呢個計劃零風險,仲話銀行職員都買咗……"},]print(moderate(messages))# Safety: Unsafe# Categories: HK Welfare & Financial Scam# Refusal: No
(outputs above are illustrative)
Note: transformers loads the packed INT4 weights via the compressed-tensors integration but dequantizes them on the fly, so it is mainly useful for correctness checks; use vLLM to actually realise the memory and throughput benefits of W4A16.
Training details (BF16 source model)
The training recipe below applies to the source BF16 model; quantization was performed after training on the merged weights.
Table with columns: Item, Value| Item | Value |
|---|
| Base model | Qwen/Qwen3Guard-Gen-4B |
| Method | LoRA supervised fine-tuning, adapter merged into base weights |
| LoRA rank / alpha / dropout | 64 / 128 / 0.05 |
| Learning rate | 2e-4 |
| Epochs | 2 |
| Per-device batch size | 4 |
| Max sequence length | 2,048 |
| Training / validation samples | 24,000 / 6,000 |
| Precision | bfloat16 |
The training data is ZhangPY/ElderDomainSafeguards, a domain safety dataset for HK elderly care, covering all 13 categories with both user_query and assistant_response evaluation types, labelled in the Safety / Categories (/ Refusal) format shown above. A subset of this data also serves as the AWQ calibration set.
Model architecture
Table with columns: Qwen3Guard-Gen-Domain-4B-AWQ | Qwen3Guard-Gen-Domain-4B-AWQ |
|---|
| Parameters | 4B |
| Layers | 36 |
| Hidden size | 2560 |
| Attention heads / KV heads | 32 / 8 (GQA) |
| Context length | 32,768 |
| Precision | INT4 weights (symmetric, group 128) / BF16 activations |
| Weight size | ~2.6 GB |
Limitations and intended use
- The model is a safety classifier, not a conversational assistant — it should only be used to produce safety assessments of given conversations.
- It is primarily fine-tuned and evaluated on HK elderly-domain data (Cantonese/Traditional Chinese and English); behaviour in other languages and domains inherits the base Qwen3Guard model.
- Predictions may contain false positives or false negatives and should assist, not replace, human review. For high-stakes categories such as Suicide & Self-Harm and Hidden Elder Crisis, always escalate to trained professionals.
Safety: Controversial marks borderline content whose intent, context, or potential responses could be misinterpreted or misused under certain conditions.
- INT4 weight quantization may introduce slight behavioural differences compared with the BF16 checkpoint (average per-category F1 drop ≈0.6 pt on ElderlyDomain-Eval, see Evaluation); validate on your own data before production deployment.
Acknowledgements
License
This model is released under the Apache 2.0 license, following the base model.