udomain/kestrel_v_1 (v0.1-preview)
Kestrel is a non-autoregressive System-One operational risk guardrail for Hong Kong enterprise LLM gateways (Threat Model A: Enterprise Employee -> External LLM).
It replaces slow autoregressive JSON generation with a single-forward-pass decision head pooled at each turn's <|im_end|> token (causal attention, zero future leakage, full multi-turn mosaic context support). LoRA adapters have been merged into the base Qwen/Qwen3-1.7B weights and saved purely as safetensors (no peft required at inference).
Preview Disclaimer:
v0.1-previewis trained on synthetic multi-turn HK counterfactual data (Cantonese, Traditional Chinese, English, HK code-mix) and calibrated onval.jsonl. It scores operational personal-data risk (allow/suspected/violation) for evaluation and red-teaming; it does not constitute legal advice under the HK PDPO.
Benchmark Comparison (RTX 3090 CUDA BF16, out-of-sample calibrated)
| Model | test PR-AUC |
test Recall / FPR / Hard-Neg FPR / Mosaic |
heldout_gen PR-AUC |
heldout_gen Recall / FPR / Hard-Neg FPR / Mosaic |
Calibrated ECE | Single-Turn Latency (p50 / p95) |
|---|---|---|---|---|---|---|
Legacy 4B (UD_model_v4_judge-mlx, Jev-ified) |
0.1259 |
100% / 100% / 100% / 100% |
0.1774 |
100% / 100% / 100% / 100% |
0.8221 / 0.7900 |
657.0 / 1984.8 ms (MPS) |
udomain/kestrel_v_1 (merged Qwen/Qwen3-1.7B) |
0.9972 |
97.23% / 0.67% / 0.00% / 100.00% |
0.9930 |
98.30% / 1.36% / 0.00% / 100.00% |
0.0045 / 0.0118 |
45.2 ms / 131.7 ms |
Quickstart (3 Lines, No peft Required)
import torch
from transformers import AutoModel, AutoTokenizer
repo = "udomain/kestrel_v_1"
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModel.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).cuda().eval()
messages = [
{"role": "user", "content": "我哋公司喺太古城有個客陳生,佢份 KYC 檔有啲問題。"},
{"role": "assistant", "content": "明白,請問想點樣跟進?"},
{"role": "user", "content": "幫我將佢 HKID B000009(A) 同電話 9876 5432 寫入推廣名單。"},
]
result = model.predict_conversation(tokenizer, messages, language="hk_cantonese")
print(result)
Legacy UD_model_v4_judge-mlx Mapping
predict_conversation returns both calibrated probability (risk_prob) and a legacy-compatible integer if_violate:
risk_prob >= 0.5(t_high) ->verdict = "violation",if_violate = 00.25 <= risk_prob < 0.5(t_low .. t_high) ->verdict = "suspected",if_violate = 1risk_prob < 0.25->verdict = "safe",if_violate = 2
You can override thresholds per call: model.predict_conversation(tokenizer, messages, t_low=0.25, t_high=0.50).
Calibration Metadata
- Global temperature:
1.3135 - Per-language temperatures:
{"code_mix": 1.4901984618591966, "en": 1.2029663715902748, "hk_cantonese": 1.4981812752693384, "trad_zh": 1.1762281001857002} - Operational categories (10):
direct_id_exposure, contact_financial_exposure, sensitive_medical_hr_exposure, client_customer_bulk_leak, mosaic_cross_turn_identification, purpose_deviation_dpp3, excessive_collection_profiling_dpp1, doxxing_harassment_s64, obfuscated_or_evasive_pii, unauthorized_cross_border_transfer
- Downloads last month
- -