Text Classification
Transformers
ONNX
Safetensors
Transformers.js
modernbert
refusal-detection
over-refusal
llm-safety
red-teaming
garak
guardrails
ai-security
tamarillo
Eval Results (legacy)
text-embeddings-inference
Run this model with HF Jobs
Run Tamarillo/refusal-guard-small 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/Tamarillo/refusal-guard-small. 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/Tamarillo/refusal-guard-small 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.
Instructions to use Tamarillo/refusal-guard-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Tamarillo/refusal-guard-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Tamarillo/refusal-guard-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Tamarillo/refusal-guard-small") model = AutoModelForSequenceClassification.from_pretrained("Tamarillo/refusal-guard-small", device_map="auto") - Transformers.js
How to use Tamarillo/refusal-guard-small with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'Tamarillo/refusal-guard-small'); - Notebooks
- Google Colab
- Kaggle
|
Download README.md from Tamarillo/refusal-guard-small: direct link, hf CLI and curl.
- Browser
- Download file 20.1 kB
-
https://huggingface.co/Tamarillo/refusal-guard-small/resolve/main/README.md
- Command line
-
hf download hf://Tamarillo/refusal-guard-small/README.md
-
curl -L -o README.md https://huggingface.co/Tamarillo/refusal-guard-small/resolve/main/README.md
20.1 kB
| language: | |
| - en | |
| - de | |
| - fr | |
| - es | |
| - pt | |
| - it | |
| - ja | |
| - zh | |
| - ko | |
| - ar | |
| - multilingual | |
| license: apache-2.0 | |
| base_model: jhu-clsp/mmBERT-small | |
| pipeline_tag: text-classification | |
| library_name: transformers | |
| datasets: | |
| - Tamarillo/refusal-compliance-corpus-2026 | |
| - ToxicityPrompts/PolyGuardMix | |
| tags: | |
| - refusal-detection | |
| - over-refusal | |
| - llm-safety | |
| - red-teaming | |
| - garak | |
| - guardrails | |
| - ai-security | |
| - modernbert | |
| - onnx | |
| - transformers.js | |
| - tamarillo | |
| model-index: | |
| - name: Tamarillo/refusal-guard-small | |
| results: | |
| - task: | |
| type: text-classification | |
| name: LLM Refusal vs. Compliance Detection | |
| dataset: | |
| type: multi-tier-refusal-eval | |
| name: OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP | |
| metrics: | |
| - type: ood_do_not_answer_roc_auc | |
| value: 0.7285 | |
| name: OOD Do-Not-Answer ROC-AUC | |
| - type: ood_jbb_macro_f1 | |
| value: 0.5366 | |
| name: OOD JBB-JudgeComparison Macro-F1 (@0.50) | |
| - type: heldout_wildguard_en_macro_f1 | |
| value: 0.8731 | |
| name: Held-Out WildGuardTest-EN Macro-F1 (@0.50) | |
| - type: heldout_wildguard_jp_macro_f1 | |
| value: 0.8648 | |
| name: Held-Out WildGuardTest-JP Macro-F1 (@0.50) | |
| - type: diag_phi4_disclaimer_fpr | |
| value: 0.0056 | |
| name: Independent Phi-4-mini Disclaimer-Compliance FPR (@0.50) | |
| # Tamarillo/refusal-guard-small | |
| **140.6M-parameter, Apache-2.0, multilingual, 8K-context refusal vs. compliance classifier** — **smaller than English-only `garak-llm/garak-refusal-detector` (`149M`, custom NVIDIA license, zero ONNX)** while supporting **17+ languages** and shipping 100%-parity **`256.0 MB` Gather-INT8 ONNX** (`27.4 ms` CPU @ 64 tok). Built as a **1-line zero-code drop-in for `NVIDIA/garak` `mitigation.ModernBERTRefusal`** (`id2label={0: "non-refusal", 1: "refusal"}`). Achieves **`0.873` Macro-F1 (`0.943` AUC) on `Held-Out WildGuardTest-EN`**, **`0.865` Macro-F1 (`0.962` AUC) on Japanese `WildGuardTest-JP`** (`+26.5` F1 pts over EN-only `garak-refusal-detector` `0.600`), **`0.967` Macro-F1 (`0.006` FPR) on independent `Phi-4-mini` Disclaimer-Compliance**, and **`0.967` Macro-F1 (`0.994` AUC) on `~1.6K`-token agent traces** (vs. `0.000` recall for `garak` & `ProtectAI`). *(Honest caveat: trails `garak-refusal-detector` & `ProtectAI` on 2023-era `OOD Do-Not-Answer` `0.729` ROC-AUC / `0.377` Macro-F1 and `OOD JBB` `0.576` ROC-AUC / `0.537` Macro-F1 — see Table 1.)* | |
|  | |
| --- | |
| ## Model Overview | |
| | Property | Value | | |
| |---|---| | |
| | **Architecture** | `ModernBertForSequenceClassification` (`0: non-refusal`, `1: refusal`, zero `trust_remote_code`) | | |
| | **Base Backbone** | [`jhu-clsp/mmBERT-small`](https://huggingface.co/jhu-clsp/mmBERT-small) | | |
| | **Parameters** | `140.6M` (distilled from internal `mmBERT-base` `307.5M` teacher) | | |
| | **Context Window** | `8,192` arch max · trained up to `2,560` tok · evaluated up to `2,048` tok · ONNX verified to `2,048` tok | | |
| | **Languages** | 17+ languages (`mmBERT-small`: trained on 17-language `PolyGuardMix` + 10-language contrastive pairs) | | |
| | **License** | `Apache-2.0` | | |
| | **Sibling Model** | `Tamarillo/refusal-guard-tiny-en` (32.0M, EN, fastest CPU/WASM) | | |
| | **Open Contrastive Corpus** | [`Tamarillo/refusal-compliance-corpus-2026`](https://huggingface.co/datasets/Tamarillo/refusal-compliance-corpus-2026) (`Apache-2.0`) | | |
| | **Live Browser Demo** | [`Tamarillo/refusal-guard-demo`](https://huggingface.co/spaces/Tamarillo/refusal-guard-demo) | | |
| | **Open-Source Adapters** | [`duoi-bt/tamarillo-guardrails`](https://github.com/duoi-bt/tamarillo-guardrails) | | |
| --- | |
| ## Benchmarks (3-Tier Evaluation vs. Live Incumbents) | |
| All models are evaluated identically on MD5-deduplicated test suites with zero train/val overlap (`eval_results.json`). Every thresholded metric (`Macro-F1`, `Recall`, `FPR`) uses the **default `0.50` probability threshold**. GPU latency is measured on an **NVIDIA A100-SXM4-40GB** (`bf16`, `attn_implementation="eager"`, `bs=1`, `p50` ms). | |
| ### Table 1: Tier A (Strictly Zero-Shot OOD) & Tier B (Same-Taxonomy Held-Out Test) | |
| - **Tier A — Strictly Zero-Shot External OOD (different taxonomy & provenance):** | |
| - `OOD Do-Not-Answer` (`LibrAI/do-not-answer`, `CC-BY-NC-SA-4.0`, strictly eval-only, `n=1800`, `pos=1681`, 6 real 2023 LLMs; unambiguous human action codes `0,4 -> refusal`, `5 -> compliance`, excluding ambiguous educational/discussion actions `1,2,3`). Note: heavily refusal-skewed (`93.4%` positive), so read `ROC-AUC` and `Macro-F1` jointly. | |
| - `OOD JBB-JudgeComparison` (`JailbreakBench/JBB-Behaviors`, `MIT`, `n=300`, `pos=190`, 3-human majority vote; note that non-jailbreak includes occasional benign off-topic responses alongside refusals). | |
| - **Tier B — Same-Taxonomy Held-Out Test (honestly labeled):** | |
| - `Held-Out WildGuardTest-EN` & `Held-Out WildGuardTest-JP` (`sbintuitions/WildGuardTestJP`, `ODC-BY`, `n=1719` each, `pos=562`). Because `ToxicityPrompts/PolyGuardMix` derives from the WildGuard training taxonomy/pipeline, we honestly classify these as **Same-Taxonomy Held-Out** rather than strictly OOD (despite strict MD5 deduplication). | |
| | Model | Params | Scope / License | OOD Do-Not-Answer (AUC / Macro-F1) | OOD JBB-Judge (AUC / Macro-F1) | Held-Out WildGuard-EN (AUC / F1 / FPR@0.50 ↓) | Held-Out WildGuard-JP (AUC / F1 / FPR@0.50 ↓) | A100 p50 (64 / 2048 tok) | | |
| |---|---:|---|---|---|---|---|---| | |
| | **`Tamarillo/refusal-guard-tiny-en`** | 32.0M | EN (8K, Apache-2.0) | 0.791 / 0.440 | 0.620 / 0.543 | 0.947 / 0.858 / 0.168 | 0.438 / 0.402 / 0.002 | 14.8 ms / 24.6 ms | | |
| | **`Tamarillo/refusal-guard-small`** *(this model)* | 140.6M | 17+ Langs (8K, Apache-2.0) | 0.729 / 0.377 | 0.576 / 0.537 | 0.943 / 0.873 / 0.105 | 0.962 / 0.865 / 0.160 | 31.2 ms / 36.6 ms | | |
| | `garak-llm/garak-refusal-detector` | 149.6M | EN (8K, NVIDIA Open Model) | 0.940 / 0.575 | 0.706 / 0.581 | 0.927 / 0.798 / 0.016 | 0.896 / 0.600 / 0.003 | 29.9 ms / 51.7 ms | | |
| | `ProtectAI/distilroberta-base-rejection-v1` (archived) | 82.1M | EN (512, Apache-2.0) | 0.950 / 0.858 | 0.678 / 0.597 | 0.911 / 0.820 / 0.106 | 0.837 / 0.402 / 0.000 | 6.7 ms / 6.5 ms | | |
| | `NVIDIA/garak` keyword baseline (`MitigationBypass`) | 0M | EN substring rules | 0.849 / 0.701 | 0.646 / 0.569 | 0.837 / 0.792 / 0.271 | 0.500 / 0.402 / 0.000 | — / — | | |
| *Note: `VINAY-UMRETHE/tiny-refusal-classifier` (`1.6M`) uses a `transformers>=5.0` `TokenizersBackend` format incompatible with `transformers==4.51.3` and collapsed to `~1.0` FPR under fallback loading, so it is omitted from Table 1/2 to avoid an unfair tokenizer-mismatched comparison (raw output remains in `eval_results.json`).* | |
| ### Table 2: Tier C — Independent-Generator (`microsoft/Phi-4-mini-instruct`) Diagnostic Stress Suites | |
| Generated by an **independent MIT-licensed model (`microsoft/Phi-4-mini-instruct`)** on 30 completely disjoint topics (industrial SCADA, aviation, healthcare, banking, telecom, etc. — **zero overlap with `Qwen/Qwen3-8B` training prompts**, preventing model self-benchmarking). Note that while the generator and topics are independent, Tier C remains a **synthetic diagnostic suite** aligned with our disclaimer-compliance and agent-trace style family (read alongside real human-labeled Tier A & Tier B results in Table 1). Tests `NVIDIA/garak#2197` failure modes (`fulfillment_with_disclaimer`, `apology_then_compliance`, `meta_safety_discussion`) vs. direct/redirection/agent-tool refusals (`n=360`), plus `~1,400–1,800`-token agent traces (`n=240`, 3× past 512-tok truncation yet cleanly inside the `2,048`-tok evaluation limit). | |
| | Model | Eval Max Tok | Disclaimer Stress Macro-F1 | Disclaimer Recall@0.50 | Disclaimer FPR@0.50 ↓ | LC ~1.6K Trace Macro-F1 | LC ~1.6K Recall@0.50 | LC ~1.6K FPR@0.50 ↓ | | |
| |---|---:|---:|---:|---:|---:|---:|---:| | |
| | **`Tamarillo/refusal-guard-tiny-en`** | 2048 | 0.896 | 0.794 | 0.000 | 0.908 | 0.833 | 0.017 | | |
| | **`Tamarillo/refusal-guard-small`** *(this model)* | 2048 | 0.967 | 0.939 | 0.006 | 0.967 | 0.942 | 0.008 | | |
| | `garak-llm/garak-refusal-detector` | 2048 | 0.501 | 0.172 | 0.000 | 0.333 | 0.000 | 0.000 | | |
| | `ProtectAI/distilroberta-base-rejection-v1` (archived) | 512 | 0.536 | 0.228 | 0.028 | 0.333 | 0.000 | 0.000 | | |
| | `NVIDIA/garak` keyword baseline (`MitigationBypass`) | 0 | 0.621 | 0.733 | 0.483 | 0.646 | 0.750 | 0.450 | | |
| > **Honest comparison — where incumbents win & where Tamarillo wins:** | |
| > - **Where incumbents win (`OOD Do-Not-Answer` & `OOD JBB-JudgeComparison`):** On 2023-era verbose/moralizing refusals (`LibrAI/do-not-answer`, `action in {0,4} vs 5`) and `JailbreakBench/JBB-Behaviors`, `garak-llm/garak-refusal-detector` (`0.940` / `0.706` AUC; `0.575` / `0.581` Macro-F1) and archived `ProtectAI/distilroberta-base-rejection-v1` (`0.950` / `0.678` AUC; `0.858` / `0.597` Macro-F1, though at `0.370` FPR on `Do-Not-Answer`) outperform both `Tamarillo/refusal-guard-tiny-en` (`0.791` / `0.620` AUC) and `Tamarillo/refusal-guard-small` (`0.729` / `0.576` AUC). Training with `1.4×`-weighted disclaimer-compliance hard negatives makes Tamarillo conservative on verbose hedged 2023 replies; if your workload primarily scores short 2023-style English completions and you accept the NVIDIA license, `garak-llm/garak-refusal-detector` remains stronger on `Do-Not-Answer` and `JBB`. | |
| > - **Where `Tamarillo/refusal-guard` wins decisively:** (1) **Long-context agent traces (`~1.6K` tok):** `small` hits **`0.967` Macro-F1 (`0.994` AUC, `0.942` Recall, `0.008` FPR)** and `tiny-en` hits **`0.908` F1 (`0.982` AUC)** while BOTH `garak-refusal-detector` (`0.000` Recall!) and 512-tok `ProtectAI` (`0.000` Recall!) collapse completely; (2) **Multilingual (`WildGuardTest-JP`, `n=1,719`):** `small` hits **`0.865` Macro-F1 (`0.962` AUC)** vs. `garak` `0.600` F1 (`+26.5` pts) and `ProtectAI` `0.402` F1 (`+46.3` pts); (3) **Independent `Phi-4-mini` Disclaimer-Compliance stress (`garak#2197`):** `small` hits **`0.967` F1 (`0.006` FPR)** and `tiny-en` **`0.896` F1 (`0.000` FPR)** vs. `garak` `0.501` F1 (`0.172` Recall), `ProtectAI` `0.536` F1, and keyword rules (`0.483` FPR); and (4) **`Held-Out WildGuardTest-EN`:** `small` (`0.873` F1 / `0.943` AUC) and 4.7× smaller `tiny-en` (`0.858` F1 / `0.947` AUC) beat `garak` (`0.798` F1) and `ProtectAI` (`0.820` F1) — noting honestly that `PolyGuardMix` shares the WildGuard taxonomy. | |
| --- | |
| ## Table 3: ONNX Exports, Parity Gates & 4-Thread x86-64 CPU Latency | |
| Measured on a GCP `a2-highgpu-1g` host VM (`Intel Xeon Cascade Lake @ 2.20 GHz`, x86-64, `onnxruntime` `CPUExecutionProvider`, `intra_op_num_threads=4`, `ORT_ENABLE_ALL`, `bs=1`, `p50` ms). | |
| | Export Artifact | Size | Short Parity (Agree / Δmax) | 2,048-Tok Parity (Agree / Δmax) | CPU @ 64 tok | CPU @ 512 tok | CPU @ 1,024 tok | CPU @ 2,048 tok | | |
| |---|---:|---|---|---:|---:|---:|---:| | |
| | FP32 (`onnx/model.onnx`) | 537.0 MB | 1.0000 (Δ≤0.0000) | 1.0000 (Δ≤0.0000) | 28.6 ms | 210.3 ms | 596.8 ms | 1897.2 ms | | |
| | FP16 (`onnx/model_fp16.onnx`) | 268.7 MB | 1.0000 (Δ≤0.0003) | 1.0000 (Δ≤0.0001) | 33.7 ms | 240.3 ms | 736.2 ms | 2476.9 ms | | |
| | Gather-INT8 (`onnx/model_quantized.onnx`) | 256.0 MB | 1.0000 (Δ≤0.0114) | 1.0000 (Δ≤0.0004) | 27.4 ms | 210.5 ms | 600.7 ms | 1895.1 ms | | |
| *Note: Full-INT8 (`Gather+MatMul`) dynamic quantization is withheld because dynamic `MatMul` quantization degrades ModernBERT RoPE/GeGLU attention logits.* | |
| --- | |
| ## Quickstarts | |
| ### 1. 1-Line Drop-In for `NVIDIA/garak` (`mitigation.ModernBERTRefusal`) | |
| Matches `garak`'s exact `ModernBertForSequenceClassification` architecture and target class name (`"refusal"`): | |
| ```bash | |
| pip install garak | |
| export OPENAI_API_KEY="your-key" # or substitute any garak --model_type (ollama, huggingface, litellm, etc.) | |
| garak --model_type openai --model_name gpt-4o-mini --probes dan --detectors mitigation.ModernBERTRefusal --detector_option '{"mitigation.ModernBERTRefusal": {"detector_model_path": "Tamarillo/refusal-guard-small"}}' | |
| ``` | |
| ### 2. PyTorch (`transformers>=4.48.0`) | |
| ```bash | |
| pip install "transformers>=4.48.0" torch | |
| ``` | |
| ```python | |
| from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline | |
| model_id = "Tamarillo/refusal-guard-small" | |
| tok = AutoTokenizer.from_pretrained(model_id, use_fast=True) | |
| mod = AutoModelForSequenceClassification.from_pretrained( | |
| model_id, | |
| attn_implementation="eager", # avoids ModernBERT SDPA padding numerical drift | |
| ).eval() | |
| clf = pipeline("text-classification", model=mod, tokenizer=tok, truncation=True, max_length=2048) | |
| print(clf("Sure, here is how parameterized SQL prevents injection. Note that attacking systems without permission is illegal.")) | |
| print(clf("I can't execute destructive DROP TABLE statements on production, though I can generate a safe dry-run migration.")) | |
| ``` | |
| ### 3. Zero-PyTorch ONNX Runtime (CPU Sidecar / Gateway Fallback Routing) | |
| ```bash | |
| pip install "transformers>=4.48.0" onnxruntime huggingface_hub numpy | |
| ``` | |
| ```python | |
| import numpy as np | |
| import onnxruntime as ort | |
| from huggingface_hub import hf_hub_download | |
| from transformers import AutoTokenizer | |
| model_id = "Tamarillo/refusal-guard-small" | |
| tok = AutoTokenizer.from_pretrained(model_id, use_fast=True) | |
| onnx_path = hf_hub_download(model_id, "onnx/model_quantized.onnx") | |
| opts = ort.SessionOptions() | |
| opts.intra_op_num_threads = 4 | |
| sess = ort.InferenceSession(onnx_path, sess_options=opts, providers=["CPUExecutionProvider"]) | |
| text = "Sorry for the earlier delay! Here is the complete Argon2id password hashing script." | |
| enc = tok(text, truncation=True, max_length=2048, return_token_type_ids=False, return_tensors="np") | |
| logits = sess.run(["logits"], {"input_ids": enc["input_ids"].astype(np.int64), "attention_mask": enc["attention_mask"].astype(np.int64)})[0][0] | |
| probs = np.exp(logits - logits.max()) / np.exp(logits - logits.max()).sum() | |
| print({"non-refusal": round(float(probs[0]), 4), "refusal": round(float(probs[1]), 4)}) | |
| ``` | |
| ### 4. Browser / Node.js (`@huggingface/transformers`) | |
| ```bash | |
| npm install @huggingface/transformers | |
| ``` | |
| ```javascript | |
| import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers"; | |
| const modelId = "Tamarillo/refusal-guard-small"; | |
| const tokenizer = await AutoTokenizer.from_pretrained(modelId); | |
| const model = await AutoModelForSequenceClassification.from_pretrained(modelId, { dtype: "q8" }); | |
| const inputs = await tokenizer("I cannot export raw private keys, but I can show redacted audit logs.", { truncation: true, max_length: 2048 }); | |
| const { logits } = await model(inputs); | |
| const [l0, l1] = Array.from(logits.data); | |
| const m = Math.max(l0, l1); | |
| const pRefusal = Math.exp(l1 - m) / (Math.exp(l0 - m) + Math.exp(l1 - m)); | |
| console.log({ label: pRefusal >= 0.5 ? "refusal" : "non-refusal", pRefusal: Number(pRefusal.toFixed(4)) }); | |
| ``` | |
| --- | |
| ## Training Recipe & Verified Data Provenance | |
| Distilled from our internal `jhu-clsp/mmBERT-base` (`307.5M`) teacher using **Logit-Standardized Knowledge Distillation (`T=2.5` KL + centered-logit MSE) + Label-Smoothed CE (`1.4×` hard-negative disclaimer weight) + Paired Same-Topic Contrastive Margin + EMA (`decay=0.996`)**. Checkpoint selected strictly on unseen validation metrics (`step 2100`, `ema`, `val_macro_f1=0.9559`, `val_disclaimer_fpr=0.0000` — zero test peeking). | |
| Every training source is verified commercially permissive (`CC-BY-4.0` / `Apache-2.0` — zero `CC-BY-NC`, zero `CC-BY-SA`). `LibrAI/do-not-answer` (`CC-BY-NC-SA-4.0`) is strictly eval-only. | |
| | Source | License | Role in Training (`67,303` examples) | | |
| |---|---|---| | |
| | [`ToxicityPrompts/PolyGuardMix`](https://huggingface.co/datasets/ToxicityPrompts/PolyGuardMix) | `CC-BY-4.0` | Multi-LLM assistant responses with native `response_refusal_label` (17 languages) | | |
| | [`Tamarillo/refusal-compliance-corpus-2026`](https://huggingface.co/datasets/Tamarillo/refusal-compliance-corpus-2026) (`Qwen/Qwen3-8B`) | `Apache-2.0` | Paired same-topic 6-style contrastive refusal vs. disclaimer-compliance / apology-compliance / meta-safety replies | | |
| | [`OpenAssistant/oasst2`](https://huggingface.co/datasets/OpenAssistant/oasst2) (`train`) | `Apache-2.0` | Real natural helpful assistant replies (prioritizing benign trigger-word responses) | | |
| --- | |
| ## Limitations & Responsible Use | |
| - **Unbenchmarked non-EN/JP languages (`small`, 140.6M):** While trained on 17-language `PolyGuardMix` and 10-language contrastive pairs, empirical human-labeled evaluation is currently reported only for English and Japanese (`WildGuardTest-EN/JP`); per-language performance across the remaining 15+ languages has not been independently benchmarked. | |
| - **CPU / mobile browser footprint (`small`, 140.6M):** The `q8` ONNX export is `256.0 MB` (`1895.1 ms` @ 2,048 tok CPU). For ultra-fast English-only CPU/browser deployment, prefer sibling model `Tamarillo/refusal-guard-tiny-en` (`32.0M`). | |
| - **Response-only scope (no user prompt):** Because `Tamarillo/refusal-guard-small` classifies the assistant's reply text alone (matching `NVIDIA/garak` `ModernBERTRefusal`), it cannot judge whether a refusal was *justified* (safe vs. false over-refusal) or whether a compliant answer was *harmful*. For joint `(prompt, response)` safety + refusal + harmfulness classification, pair with [`Tamarillo/response-safety-guard-small`](https://huggingface.co/Tamarillo/response-safety-guard-small). | |
| - **Thin adapter required for legacy `llm-guard`:** Archived `llm-guard` `NoRefusal` expects the uppercase label `"REJECTION"` and may pin older `transformers<4.48` without ModernBERT support; use our `RefusalGuard` adapter in [`duoi-bt/tamarillo-guardrails`](https://github.com/duoi-bt/tamarillo-guardrails) rather than assuming a zero-code `llm-guard` swap. | |
| - **Ambiguous partial compliance:** Borderline "hedge-then-partially-answer" responses can fall near the `0.50` boundary; tune the decision threshold for your recall vs. precision requirements. | |
| --- | |
| ## Repository Files | |
| | File | Description | | |
| |---|---| | |
| | `README.md` | Model card, 3-tier benchmarks, provenance, and quickstarts | | |
| | `config.json` | Model architecture configuration (`ModernBertForSequenceClassification`, `0: non-refusal`, `1: refusal`) | | |
| | `model.safetensors` | PyTorch weights (`140.6M` parameters, FP32 safetensors) | | |
| | `tokenizer.json` | Fast Hugging Face tokenizer | | |
| | `tokenizer_config.json` | Tokenizer configuration | | |
| | `special_tokens_map.json` | Special tokens mapping | | |
| | `onnx/model.onnx` | Parity-verified FP32 ONNX export (`537.0 MB`, opset 17) | | |
| | `onnx/model_fp16.onnx` | Parity-verified FP16 ONNX export (`268.7 MB`) | | |
| | `onnx/model_quantized.onnx` | Parity-verified Gather-INT8 ONNX export (`256.0 MB`) | | |
| | `eval_results.json` | Full 3-tier 6-suite benchmark results vs. all 4 live incumbents | | |
| | `onnx_benchmark.json` | Short & 2,048-token ONNX parity verification and 4-length x86-64 CPU latency | | |
| | `training_summary.json` | Validation trajectory and checkpoint selection record | | |
| | `assets/pareto.svg` | 2-panel size, multilingual & disclaimer-resistance Pareto chart | | |
| | `scripts/schema.py` | Drop-in label schema, MD5 deduplication, and garak keyword baseline | | |
| | `scripts/synth_refusal.py` | Qwen/Qwen3-8B 10-language paired contrastive refusal/disclaimer synthesizer | | |
| | `scripts/synth_phi4_stress.py` | Independent microsoft/Phi-4-mini-instruct Tier-C diagnostic suite generator | | |
| | `scripts/data_builder.py` | Commercially clean dataset builder & 3-tier 6-suite benchmark constructor | | |
| | `scripts/train.py` | Teacher trainer & Logit-Standardized KD student distiller | | |
| | `scripts/export_onnx.py` | Parity-gated FP32 / FP16 / Gather-INT8 ONNX exporter & CPU benchmarker | | |
| | `scripts/eval_suite.py` | Unified 6-suite evaluator vs. live incumbents | | |
| --- | |
| ## Citation | |
| ```bibtex | |
| @misc{tamarillo_refusal_guard_2026, | |
| title = {Tamarillo/refusal-guard-small: Apache-2.0 8K-Context Refusal vs. Compliance Classifier}, | |
| author = {Tamarillo Open-Model Lab}, | |
| year = {2026}, | |
| publisher = {Hugging Face}, | |
| howpublished = {\url{https://huggingface.co/Tamarillo/refusal-guard-small}} | |
| } | |
| ``` | |