Kestrel-Explainer-4B v3
Data protection law analysis
2 min readupdated
The Kestrel-Explainer-4B v3 model is designed to check texts for compliance with Hong Kong's Personal Data (Privacy) Ordinance (Cap. 486). It covers data protection principles, direct marketing, and anti-doxxing requirements. Built on Qwen3-4B, the model is available in full-size BF16 weights as well as optimized versions for vLLM and llama.cpp. It is useful for legal departments, compliance specialists, and software developers who need automated document auditing for leaks or legal violations.
Key features
- Specialization: Focuses on compliance with Hong Kong data privacy laws and marketing regulations.
- Architecture: Based on
Qwen3-4Bwith support for a precise chat template and thinking mode disabled. - High accuracy: Achieves verdict accuracy of up to 96.72% on a test set of 944 examples.
- Long context: Demonstrates 100% accuracy in long-context tests up to 6,000 tokens.
What you can do
- Text auditing: Check marketing materials and terms of service for compliance with privacy laws.
- vLLM deployment: Spin up a fast local server for handling requests with BF16 support.
- Ollama integration: Run the quantized GGUF version of the model on standard consumer hardware.
Example
import json
import torch
from pathlib import Path
from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_id = "udomain/kestrel-explainer-4b-v3"
tok = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForCausalLM.from_pretrained(repo_id, torch_dtype=torch.bfloat16, device_map="auto")
sys_p_path = hf_hub_download(repo_id=repo_id, filename="system_prompt.txt")
system_prompt = Path(sys_p_path).read_text(encoding="utf-8")
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": ""},
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1024, do_sample=False, repetition_penalty=1.05)
reply = tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True).strip()
print(json.loads(reply))Read more
Details• Verdict accuracy (`if_violate`): 96.72% and 97.03% on tests.
• Initial labeling accuracy (`label`): 93.43% and 96.08%.
• Hardware: From 8.1 GB VRAM for the BF16 version (10 GB+ recommended), from 3.52 GB for vLLM.
• Available formats: Full BF16 weights, 4-bit GPTQ weights, and GGUF Q5_K_M.










Comments