Run this model with HF Jobs

Run akhilvarsh/NitiGuard-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 to fine-tune https://huggingface.co/akhilvarsh/NitiGuard-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/akhilvarsh/NitiGuard-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/akhilvarsh/NitiGuard-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/akhilvarsh/NitiGuard-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.

NitiGuard-4B

Apache-2.0 Qwen3.5-4B 8-Class F1 0% Hallucination 0.24% FPR 50 Locales

NitiBench-50 Leaderboard

NitiGuard-4B is a compact 4B-parameter open-weight multilingual safeguard model fine-tuned from Qwen/Qwen3.5-4B via Category-Balanced SFT (31,115 train-only rows) and Dual-Adapter Failure-Harvested QLoRA DPO (2,083 real model-failure pairs, 90 steps, beta=0.1, lr=5e-6). Designed for low-friction Tier-1 payment, banking, and agentic screening across 50 locales.

Key Verified Results

NitiBench-50 (n = 2,380, 50 Locales, Zero Seed Leakage)

Metric Base Qwen3.5-4B NitiGuard-4B (SFT + DPO) Delta
Binary Macro-F1 94.15% 94.14% -0.01 pts
3-Class Verdict F1 81.38% 79.20% -2.18 pts
8-Class Category Macro-F1 40.22% 68.98% (#1 Overall) +28.76 pts
Financial-Scam Recall 98.22% 95.96% -2.26 pts
Jailbreak Detection (n=60) 51.67% 93.33% (56/60) +41.66 pts
Benign False-Positive Rate (โ†“) 0.00% 0.24% +0.24 pts
JSON Validity 99.24% 99.16% (2,360/2,380) -0.08 pts
Legal Hallucination Rate (โ†“) 5.00% (119/2,380) 0.00% (0/2,380) Eliminated

Zero-Shot External OOD Generalization (Native BF16, enable_thinking=False)

External Benchmark Strict Unsafe-F1 Loose Unsafe-F1 Macro-F1 Loose Safe-FPR (โ†“) Invalid JSON
XSTest (n=450) 87.62% 88.44% (beats Llama Guard 3 87.9%) 89.64% 8.80% 0.00%
OpenAIMod (n=1,680) 70.55% 75.06% 80.39% 20.90% 0.00%
AEGIS-2.0 Test (n=1,964) 76.04% 75.23% 73.57% 26.85% 0.00%

Quickstart (transformers + peft)

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base_id = "Qwen/Qwen3.5-4B"
adapter_id = "akhilvarsh/NitiGuard-4B"

tok = AutoTokenizer.from_pretrained(base_id, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(base_id, dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(base, adapter_id).eval()

sys_prompt = (
    "You are NitiGuard, a multilingual safety and regulatory compliance judge. "
    "Analyze the user message and output strictly valid JSON with keys: "
    "verdict ('safe'|'caution'|'unsafe'), category, jurisdiction_scope, "
    "policy_reference, language_detected, risk_score, rationale."
)
text = tok.apply_chat_template(
    [{"role": "system", "content": sys_prompt}, {"role": "user", "content": "Bhai Rs 5000 cashback jeetne ke liye QR par PIN daalo"}],
    tokenize=False, add_generation_prompt=True, enable_thinking=False
)
out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=240, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))

Supported Languages & Locales (50 Locales Across 40+ Countries)

Country Languages & Canonical BCP-47 Locales
India India Bangla (bn-Beng-IN), Gujarati (gu-Gujr-IN), Hindi (hi-Deva-IN), Kannada (kn-Knda-IN), Malayalam (ml-Mlym-IN), Marathi (mr-Deva-IN), Punjabi (pa-Guru-IN), Tamil (ta-Taml-IN), Telugu (te-Telu-IN), Code-Mixed Hinglish & English (original)
Argentina Argentina / Colombia Colombia / Mexico Mexico / Spain Spain Spanish (es-Latn-AR, es-Latn-CO, es-Latn-MX, es-Latn-ES)
Egypt Egypt / Saudi Arabia Saudi Arabia / UAE UAE Arabic (ar-Arab-EG, ar-Arab-SA, ar-Arab-AE)
Brazil Brazil / Portugal Portugal Portuguese (pt-Latn-BR, pt-Latn-PT)
Canada Canada / France France French (fr-Latn-CA, fr-Latn-FR)
Nigeria Nigeria / Singapore Singapore English (en-Latn-NG, en-Latn-SG)
Bulgaria Bulgaria / Czechia Czechia / Denmark Denmark / Finland Finland Bulgarian (bg-Cyrl-BG), Czech (cs-Latn-CZ), Danish (da-Latn-DK), Finnish (fi-Latn-FI)
Germany Germany / Greece Greece / Hungary Hungary / Italy Italy German (de-Latn-DE), Greek (el-Grek-GR), Hungarian (hu-Latn-HU), Italian (it-Latn-IT)
Netherlands Netherlands / Norway Norway / Poland Poland / Romania Romania Dutch (nl-Latn-NL), Norwegian (no-Latn-NO), Polish (pl-Latn-PL), Romanian (ro-Latn-RO)
Russia Russia / Slovakia Slovakia / Sweden Sweden / Tรผrkiye Tรผrkiye / Ukraine Ukraine Russian (ru-Cyrl-RU), Slovak (sk-Latn-SK), Swedish (sv-Latn-SE), Turkish (tr-Latn-TR), Ukrainian (uk-Cyrl-UA)
China China / Japan Japan / South Korea South Korea Chinese Simplified (zh-Hans-CN), Japanese (ja-Jpan-JP), Korean (ko-Kore-KR)
Indonesia Indonesia / Malaysia Malaysia / Philippines Philippines / Thailand Thailand / Vietnam Vietnam Indonesian (id-Latn-ID), Malay (ms-Latn-MY), Filipino (fil-Latn-PH), Thai (th-Thai-TH), Vietnamese (vi-Latn-VN)
Kenya Kenya / Sri Lanka Sri Lanka Swahili (sw-Latn-KE), Sinhala (si-Sinh-LK)

Statutory Allowlist (Language != Jurisdiction)

Universal threat classification (safe / caution / unsafe), 8-class categorization, and native-language rationales operate across all 50 locales, while policy_reference is strictly gated by jurisdiction_scope:

Auditable 7-Field JSON Schema

{
  "verdict": "safe | caution | unsafe",
  "category": "benign | financial_scam_upi_otp | fake_kyc_phishing | coercion_extortion | prompt_injection_jailbreak | pii_dpdp_gdpr_violation | prohibited_ai_practice | other_harm",
  "jurisdiction_scope": "india_rbi_dpdp | eu_gdpr_ai_act | global | none",
  "policy_reference": "<Verified Allowlist Citation> | none",
  "language_detected": "<Canonical BCP-47 Locale, e.g. hi-Deva-IN>",
  "risk_score": 0.0,
  "rationale": "<Concise explanation in the user's detected language>"
}

Production Integration Note: Always enforce a fail-closed compound gate (verdict == "safe" AND category == "benign" AND risk_score < 0.25 AND all 7 keys valid) paired with grammar-constrained decoding (guided_json) in adversarial environments.

Author

Akhilvarsh Pettem (akhilvarshpettem@gmail.com) โ€” VNRVJIET, Hyderabad, India.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for akhilvarsh/NitiGuard-4B

Finetuned
Qwen/Qwen3.5-4B
Adapter
(1,329)
this model