Tamarillo/refusal-guard-tiny-en

32.0M-parameter, Apache-2.0, 8K-context English refusal vs. compliance classifier โ€” 4.7ร— smaller than garak-llm/garak-refusal-detector (149M) and 2.6ร— smaller than archived ProtectAI/distilroberta-base-rejection-v1 (82M), running in 9.6 ms CPU ONNX @ 64 tok (67.2 MB q8). Built as a 1-line zero-code drop-in for NVIDIA/garak mitigation.ModernBERTRefusal (id2label={0: "non-refusal", 1: "refusal"}) and as a fast local sidecar for red-teaming and over-refusal fallback routing. Distilled from an internal mmBERT-base (307.5M) teacher trained on commercially clean multi-LLM responses + paired same-topic disclaimer-compliance hard negatives (NVIDIA/garak#2197), achieving 0.858 Macro-F1 (0.947 AUC) on Held-Out WildGuardTest-EN (beating 4.7ร— larger garak-refusal-detector 0.798), 0.896 Macro-F1 (0.000 FPR) on independent Phi-4-mini Disclaimer-Compliance, and 0.908 Macro-F1 (0.982 AUC) on ~1.6K-token agent traces (where garak & ProtectAI drop to 0.000 recall). (Honest caveat: trails garak-refusal-detector & ProtectAI on 2023-era OOD Do-Not-Answer 0.791 ROC-AUC / 0.440 Macro-F1 and OOD JBB 0.620 ROC-AUC / 0.543 Macro-F1 โ€” see Table 1.)

Tamarillo/refusal-guard Pareto Frontier


Model Overview

Property Value
Architecture ModernBertForSequenceClassification (0: non-refusal, 1: refusal, zero trust_remote_code)
Base Backbone jhu-clsp/ettin-encoder-32m
Parameters 32.0M (distilled from internal mmBERT-base 307.5M teacher)
Context Window 7,999 arch max ยท trained up to 2,560 tok ยท evaluated up to 2,048 tok ยท ONNX verified to 2,048 tok
Languages English-primary (ettin-encoder-32m)
License Apache-2.0
Sibling Model Tamarillo/refusal-guard-small (140.6M, 17+ languages)
Open Contrastive Corpus Tamarillo/refusal-compliance-corpus-2026 (Apache-2.0)
Live Browser Demo Tamarillo/refusal-guard-demo
Open-Source Adapters 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 (this model) 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 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 (this model) 2048 0.896 0.794 0.000 0.908 0.833 0.017
Tamarillo/refusal-guard-small 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) 122.4 MB 1.0000 (ฮ”โ‰ค0.0000) 1.0000 (ฮ”โ‰ค0.0000) 9.9 ms 77.1 ms 238.8 ms 783.3 ms
FP16 (onnx/model_fp16.onnx) 61.3 MB 1.0000 (ฮ”โ‰ค0.0006) 1.0000 (ฮ”โ‰ค0.0001) 11.8 ms 90.5 ms 299.2 ms 1063.3 ms
Gather-INT8 (onnx/model_quantized.onnx) 67.2 MB 1.0000 (ฮ”โ‰ค0.0090) 1.0000 (ฮ”โ‰ค0.0016) 9.6 ms 78.5 ms 242.6 ms 781.3 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"):

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-tiny-en"}}'

2. PyTorch (transformers>=4.48.0)

pip install "transformers>=4.48.0" torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline

model_id = "Tamarillo/refusal-guard-tiny-en"
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)

pip install "transformers>=4.48.0" onnxruntime huggingface_hub numpy
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer

model_id = "Tamarillo/refusal-guard-tiny-en"
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)

npm install @huggingface/transformers
import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers";

const modelId = "Tamarillo/refusal-guard-tiny-en";
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 1568, raw, val_macro_f1=0.9113, val_disclaimer_fpr=0.0089 โ€” 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 (60,171 examples)
ToxicityPrompts/PolyGuardMix CC-BY-4.0 Multi-LLM assistant responses with native response_refusal_label (English-only)
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 (train) Apache-2.0 Real natural helpful assistant replies (prioritizing benign trigger-word responses)

Limitations & Responsible Use

  • English-only (tiny-en, 32.0M): Trained exclusively on English data (WildGuardTest-JP Macro-F1 is 0.402). For Japanese, Chinese, German, French, Spanish, Arabic, Korean, or other non-English responses, use sibling model Tamarillo/refusal-guard-small (140.6M, WildGuardTest-JP Macro-F1 0.865).
  • Response-only scope (no user prompt): Because Tamarillo/refusal-guard-tiny-en 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.
  • 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 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 (32.0M 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 (122.4 MB, opset 17)
onnx/model_fp16.onnx Parity-verified FP16 ONNX export (61.3 MB)
onnx/model_quantized.onnx Parity-verified Gather-INT8 ONNX export (67.2 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

@misc{tamarillo_refusal_guard_2026,
  title = {Tamarillo/refusal-guard-tiny-en: 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-tiny-en}}
}
Downloads last month
14
Safetensors
Model size
32M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Tamarillo/refusal-guard-tiny-en

Quantized
(34)
this model

Collections including Tamarillo/refusal-guard-tiny-en

Evaluation results

  • OOD Do-Not-Answer ROC-AUC on OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP
    self-reported
    0.791
  • OOD JBB-JudgeComparison Macro-F1 (@0.50) on OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP
    self-reported
    0.543
  • Held-Out WildGuardTest-EN Macro-F1 (@0.50) on OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP
    self-reported
    0.858
  • Held-Out WildGuardTest-JP Macro-F1 (@0.50) on OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP
    self-reported
    0.402
  • Independent Phi-4-mini Disclaimer-Compliance FPR (@0.50) on OOD Do-Not-Answer + OOD JBB + Held-Out WildGuardTest EN/JP
    self-reported
    0.000