Run this model with HF Jobs

Run Tamarillo/factcheck-gate-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/factcheck-gate-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/factcheck-gate-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.

Tamarillo/factcheck-gate-guard-small

v2 Balanced Multilingual & 21 ms INT8 CPU Fact-Check Gate (141M) — an Apache-2.0, zero-trust_remote_code, 2,048-token-context binary fact-check routing gate (id2label = {0: "NO_FACT_CHECK_NEEDED", 1: "FACT_CHECK_NEEDED"}, standard ModernBertForSequenceClassification) designed as a 1-line drop-in replacement for vllm-sr/mmbert32k-factcheck-classifier-merged and vllm-sr/halugate-sentinel to skip expensive retrieval/verification on pure math, coding, and creative prompts while catching factual queries at ~99% recall.

v2 Key Highlights

  • #1 Across ALL 9 Models on Dataset-Disjoint OOD-2 Mean ROC-AUC (0.9979 vs. v1 0.9900 & 2.2× larger vllm-sr/mmbert32k 0.9596): (OOD-2 Mean = unweighted average of ood_real_mixed and ood_multilingual_routing.) Slashes pure coding/math false triggers 17× vs. v1 (14.25% -> 0.83%), lifting ood_real_mixed Macro-F1 by +10.25pp (0.8869 -> 0.9894, 0.9994 AUC) while maintaining 99.17% recall on SimpleQA + FRAMES.
  • #1 Multilingual Routing AUC (0.9964 AUC / 0.9443 Macro-F1 across 9 non-English TyDiQA languages vs. Aya creative prompts, +11.9pp F1 over vllm-sr/mmbert32k 0.8250) plus 1.0000 Macro-F1 on 2,048-token synthetic multi-turn agent payloads (n=300, zero trust_remote_code).
  • 3/3 Parity-Verified ONNX (FP32 + 268.7 MB FP16 + 21.0 ms INT8): Ships selective INT8 ONNX (onnx/model_int8.onnx, 417.1 MB, 21.00 ms CPU @ 64 tok, 1.30× faster than FP32 27.29 ms, max Δp = 0.00615 short / 0.01530 at 2,048 tok).

Dataset-Disjoint OOD Pareto Frontier


Model Family & Recommended Tier (v2)

Model (v2) Backbone Params Langs Real Mixed OOD F1 ↑ Math/Code FPR ↓ OOD-2 Mean (F1 ↑ / AUC ↑) CPU @ 64 tok Shipped ONNX
Tamarillo/factcheck-gate-guard-tiny-en jhu-clsp/ettin-encoder-32m 32.0M English 0.9906 0.42% 0.9246 / 0.9748 7.6 ms (INT8) FP32 + FP16 + INT8
Tamarillo/factcheck-gate-guard-small (this repo) jhu-clsp/mmBERT-small 140.6M Multilingual (14+ langs) 0.9894 0.83% 0.9668 / 0.9979 21.0 ms (INT8) FP32 + FP16 + INT8
Tamarillo/factcheck-gate-guard-base jhu-clsp/mmBERT-base 307.5M Multilingual (14+ langs) 0.9906 0.83% 0.9739 / 0.9972 53.6 ms (FP32) FP32 + FP16

30-Second Quickstart (Exact 1-Line transformers Drop-In)

Requires transformers>=4.48.0 (zero trust_remote_code, zero PEFT required).

pip install "transformers>=4.48.0" torch
from transformers import pipeline

# 1-line drop-in replacement for vllm-sr/mmbert32k-factcheck-classifier-merged (zero trust_remote_code)
gate = pipeline("text-classification", model="Tamarillo/factcheck-gate-guard-small")

print(gate("Who won the 1994 Nobel Prize in Physics?"))
# [{'label': 'FACT_CHECK_NEEDED', 'score': 0.99...}]

print(gate("Write a Python function to merge two sorted linked lists in O(n) time."))
# [{'label': 'NO_FACT_CHECK_NEEDED', 'score': 0.99...}]

Direct PyTorch with Temperature Calibration (calibration.json)

import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer

repo_id = "Tamarillo/factcheck-gate-guard-small"
tok = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForSequenceClassification.from_pretrained(repo_id).eval()

prompts = [
    "What is the maximum payload size in HTTP/3 QUIC frames per RFC 9114?",
    "Janet has 16 ducks. Each duck lays 3 eggs per day. How many eggs in 5 days?",
]
enc = tok(prompts, padding=True, truncation=True, max_length=2048, return_tensors="pt")
with torch.no_grad():
    logits = model(**enc).logits
    probs = torch.softmax(logits / 0.9566, dim=-1)

for q, p in zip(prompts, probs):
    p_fc = float(p[1])
    print(f"{'FACT_CHECK' if p_fc >= 0.50 else 'SKIP_CHECK':10s} (p={p_fc:.4f}) | {q}")

ONNX Runtime (CPU / Edge / GPU)

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

repo_id = "Tamarillo/factcheck-gate-guard-small"
tok = AutoTokenizer.from_pretrained(repo_id)
onnx_path = hf_hub_download(repo_id=repo_id, filename="onnx/model_int8.onnx")  # 417.1 MB INT8 (21.00 ms CPU @ 64 tok); or "onnx/model_fp16.onnx" (268.7 MB) / "onnx/model.onnx"
sess = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])

enc = tok(["When was the Treaty of Westphalia signed?"], truncation=True, max_length=2048, return_tensors="np")
logits = sess.run(None, {"input_ids": enc["input_ids"].astype(np.int64), "attention_mask": enc["attention_mask"].astype(np.int64)})[0][0]
scaled = logits / 0.9566
probs = np.exp(scaled - scaled.max())
probs = probs / probs.sum()
print(f"P(FACT_CHECK_NEEDED)={probs[1]:.4f} | P(NO_FACT_CHECK_NEEDED)={probs[0]:.4f}")

Deployment note: small v2 (140.6M, 21.0 ms INT8 CPU @ 64 tok) is our recommended default multilingual routing tier (#1 overall OOD-2 Mean AUC 0.9979). For <65 MB browser WASM, use Tamarillo/factcheck-gate-guard-tiny-en (61.3 MB FP16).


Label Schema & Calibration (calibration.json)

Class ID Label Routing Action
0 NO_FACT_CHECK_NEEDED Bypass retrieval / fact-checking (pure math, pure coding, creative writing, translation, summarization).
1 FACT_CHECK_NEEDED Trigger RAG / search / hallucination verification (external real-world facts, CVEs, API versions, dates, statistics).
  • Validation Calibration (n=4,868 multi-domain val): Temperature T = 0.9566, calibrated ECE = 0.01383, Brier = 0.03866, val_tpr_at_5fpr = 94.74%, val_fpr_at_95tpr = 5.17%. Default τ = 0.50 works out-of-the-box without retuning (<1% coding/math FPR with ~99% hard factual recall).

Benchmarks (Identical NVIDIA A100-SXM4-40GB 9-Model Evaluation)

All 9 models (3 Tamarillo v2 tiers, 3 Tamarillo v1 tiers, and 3 external baselines) were evaluated head-to-head on identical frozen test splits (seed=42) using a fixed 0.50 threshold (no test-set threshold tuning). Full reproducible v2 scripts are bundled in this repository: scripts/schema.py, scripts/data_builder_v2.py, scripts/train.py, scripts/export_onnx.py, and scripts/eval_suite.py. Bold marks the best value in each column.

1. Dataset-Disjoint OOD Benchmarks (Zero Train/Val Row Overlap with Any Evaluation Corpus!)

  • Metric Definitions: All F1 columns report Macro-F1 at fixed τ = 0.50 (zero test-set threshold tuning). OOD-2 Mean is the unweighted average of ood_real_mixed and ood_multilingual_routing (excluding the 100%-single-class FPR/Recall splits and small/synthetic diagnostic suites). Note: v2 trains on dataset-disjoint MIT math/coding corpora (Orca-Math, Magicoder) from the same general task domains as GSM8K/HumanEvalPack/MBPP, so these suites are dataset-disjoint OOD rather than domain-unseen.
  • ood_real_mixed (n=1,600, balanced): SimpleQA (400) + FRAMES (400) vs. HumanEvalPack 6 coding langs (400) + GSM8K test (400).
  • ood_coding_math_false_trigger (n=1,200, 100% negative): HumanEvalPack (400) + MBPP test (400) + GSM8K test (400) — measures wasted verification cost.
  • ood_hard_factual_recall (n=1,200, 100% positive): SimpleQA (600) + FRAMES (600) — measures missed fact-check risk.
  • ood_multilingual_routing (n=468, balanced non-English): TyDiQA 9 non-EN langs (positives) vs. CohereLabs/aya_evaluation_suite non-EN creative/writing prompts (negatives; note cross-dataset source pairing between TyDiQA and Aya).
  • ood_hybrid_boundary_audit (n=60, author-constructed small diagnostic): Anti-topic-shortcut audit (API/CVE coding & stats-math vs. entity-rich creative/pure-code).
  • ood_long_multiturn_truncation (n=300, synthetic multi-turn diagnostic): 1,400–1,900 token benign agent history prefix + final user query. (Note on context truncation: MoritzLaurer/deberta-v3-base-zeroshot-v2.0 truncates at 512 tokens; vllm-sr/halugate-sentinel and vllm-sr/mmbert32k support ≥2,048 tokens natively, yet degrade under mean-pooled long benign prefixes (0.3333 and 0.5015 Macro-F1); vllm-sr/mmbert32k also scores 0.8043 on vllm-sr's official test split because it was trained on an updated multi-source corpus rather than exclusively that split.)
Model Params Compatibility Real Mixed OOD (Macro-F1 ↑ / AUC ↑) Coding/Math FPR ↓ Hard Factual Recall ↑ Multilingual OOD (Macro-F1 ↑ / AUC ↑) Hybrid Diagnostic F1 ↑ (n=60) 2K Multi-Turn F1 ↑ (n=300) OOD-2 Mean (Macro-F1 ↑ / AUC ↑)
Tamarillo v2 tiny-en (32M) 32.0M Zero TRC 0.9906 (0.9997) 0.42% 98.92% 0.8587 (0.9498) 0.9833 0.9900 0.9246 / 0.9748
Tamarillo v2 small (141M) 140.6M Zero TRC 0.9894 (0.9994) 0.83% 99.17% 0.9443 (0.9964) 0.9833 1.0000 0.9668 / 0.9979
Tamarillo v2 base (308M) 307.5M Zero TRC 0.9906 (0.9990) 0.83% 99.42% 0.9572 (0.9955) 1.0000 1.0000 0.9739 / 0.9972
Tamarillo v1 tiny-en 32.0M Zero TRC 0.8991 (0.9923) 12.92% 99.33% 0.8661 (0.9360) 0.9833 0.9900 0.8826 / 0.9642
Tamarillo v1 small 140.6M Zero TRC 0.8869 (0.9855) 14.25% 99.25% 0.9379 (0.9945) 1.0000 1.0000 0.9124 / 0.9900
Tamarillo v1 base 307.5M Zero TRC 0.9157 (0.9903) 10.83% 99.42% 0.9701 (0.9951) 1.0000 1.0000 0.9429 / 0.9927
vllm-sr/mmbert32k-factcheck-classifier-merged 307.5M trust_remote_code=True 0.9519 (0.9839) 1.83% 93.17% 0.8250 (0.9353) 0.8990 0.5015 0.8884 / 0.9596
vllm-sr/halugate-sentinel 149.6M PEFT LoRA (No ONNX) 0.7939 (0.9454) 24.83% 97.17% 0.6046 (0.7477) 0.9161 0.3333 0.6993 / 0.8466
MoritzLaurer/deberta-v3-base-zeroshot-v2.0 184.4M Zero-Shot NLI (512 cap) 0.7285 (0.7833) 28.00% 88.83% 0.5357 (0.7619) 0.8316 0.3333 0.6321 / 0.7726

2. In-Distribution vllm-sr Official Test (n=3,349, Raw & [ WP ]-Stripped) & A100 Latency

GPU latency protocol: GCP a2-highgpu-1g NVIDIA A100-SXM4-40GB, bs=1, PyTorch eager/BF16 (FP32 for DeBERTa), median p50 ms over 20 runs after 6 warmups. At bs=1 and 64 tokens, PyTorch eager GPU kernel-launch overhead (~14–30 ms) can exceed 4-thread AVX-512 ORT INT8 CPU latency (7.6–21.0 ms); GPUs dominate at larger batch sizes or 512–2,048 tokens.

Model Params vllm-sr Official Test ID (Macro-F1 / AUC) vllm-sr [ WP ]-Stripped ID (Macro-F1 / AUC) A100 GPU @ 64 tok (bs=1 p50) A100 GPU @ 512 tok (bs=1 p50)
Tamarillo v2 tiny-en (32M) 32.0M 0.9440 (0.9869) 0.9436 (0.9870) 14.08 ms 14.48 ms
Tamarillo v2 small (141M) 140.6M 0.9425 (0.9880) 0.9428 (0.9882) 29.82 ms 29.90 ms
Tamarillo v2 base (308M) 307.5M 0.9437 (0.9885) 0.9437 (0.9885) 29.92 ms 30.04 ms
Tamarillo v1 tiny-en 32.0M 0.9397 (0.9864) 0.9393 (0.9866) 14.08 ms 14.68 ms
Tamarillo v1 small 140.6M 0.9456 (0.9886) 0.9462 (0.9886) 30.43 ms 30.28 ms
Tamarillo v1 base 307.5M 0.9503 (0.9881) 0.9510 (0.9882) 29.83 ms 29.91 ms
vllm-sr/mmbert32k-factcheck-classifier-merged 307.5M 0.8043 (0.9120) 0.8035 (0.9070) 30.98 ms 30.24 ms
vllm-sr/halugate-sentinel 149.6M 0.9482 (0.9853) 0.9464 (0.9845) 29.12 ms 29.75 ms
MoritzLaurer/deberta-v3-base-zeroshot-v2.0 184.4M 0.6850 (0.7833) 0.6797 (0.7782) 20.90 ms 20.72 ms

ONNX Parity & 4-Thread x86 CPU Latency (bs=1)

Hardware: GCP a2-highgpu-1g (Intel Xeon Cascade Lake @ 2.20 GHz, AVX-512, 4 ORT intra-op threads, bs=1, median p50 ms). Parity verified against PyTorch FP32 on both short prompts and 2,048-token multi-turn inputs (full Table 1 benchmarks ran on PyTorch eager/BF16).

Artifact File Size Parity Short / 2,048-tok (Argmax & Max Δp) CPU @ 64 tok CPU @ 256 tok CPU @ 512 tok CPU @ 1,024 tok
onnx/model.onnx (FP32) 537.0 MB 100.0% (0.00000) / 100.0% (0.00000) 27.29 ms 88.18 ms 199.21 ms 558.56 ms
onnx/model_fp16.onnx (FP16) 268.7 MB 100.0% (0.00002) / 100.0% (0.00001) 32.43 ms 106.72 ms 232.05 ms 678.12 ms
onnx/model_int8.onnx (Selective INT8) 417.1 MB 100.0% (0.00615) / 100.0% (0.01530) 21.00 ms 71.12 ms 163.23 ms 491.27 ms
  • Quantization Hygiene: All 3 ONNX variants (FP32, FP16, Selective INT8) passed our parity gates (100.0% argmax agreement; max Δp <= 0.03 — actual Selective INT8 drift: 0.00615 short / 0.01530 at 2,048 tok). Note: Selective INT8 leaves token embedding tables in FP32 and quantizes only Transformer MatMuls to preserve long-context accuracy, so onnx/model_int8.onnx (417.1 MB) is larger on disk than onnx/model_fp16.onnx (268.7 MB) while running faster on x86 CPU.

v2 Training Recipe & Commercially Permissive Provenance

  • Hyperparameters (small): Fine-tuned canonical jhu-clsp/mmBERT-small (140.6M, attn_implementation="eager") for 3.0 epochs, LR 4e-5, effective batch size 64 (bs=8, grad_accum=8, gradient checkpointing), max_length=2048, fn_weight=1.0, EMA 0.996.
  • What Changed in v2 (Root-Cause Fix): v1 already beat vllm-sr/mmbert32k on ood_real_mixed ROC-AUC (0.986–0.992 vs. 0.984) but suffered 10.8%–14.3% false triggers on pure math word problems & coding specs (caused by zero math/coding hard-negatives in training + asymmetric fn_weight=1.15). v2 adds 100% dataset-disjoint MIT hard negatives — 3,140 microsoft/orca-math-word-problems-200k (MIT, zero GSM8K overlap) and 2,518 ise-uiuc/Magicoder-OSS-Instruct-75K (MIT, zero HumanEvalPack/MBPP overlap) — alongside vllm-sr/fact-check-classification-dataset (Apache-2.0, [ WP ]-stripped) and 2-model consensus rubric-labeled (Qwen/Qwen3-4B + mistralai/Mistral-7B-Instruct-v0.3, both Apache-2.0, binary factual-verification rubric keeping only consensus-agreed examples) OpenAssistant/oasst1 (Apache-2.0) + nvidia/HelpSteer2 (CC-BY-4.0), trained with symmetric --fn-weight 1.0 (30,006 train / 4,868 val published in Tamarillo/factcheck-gate-boundary-2026).

Honest Limitations & Where v1 / Baselines Edge Out v2

  1. Slight In-Distribution & Multilingual-F1 Tradeoffs vs. v1: Rebalancing with 5,658 English math/coding hard-negatives and symmetric fn_weight=1.0 slashed code_math_FPR 13×–30× (10.8%–14.3% -> 0.42%–0.83%) and lifted ood_real_mixed Macro-F1 by +7.5pp to +10.25pp, while slightly lowering id_vllmsr_official_test Macro-F1 on small/base (0.9456 -> 0.9425 and 0.9503 -> 0.9437; vllm-sr/halugate-sentinel leads external baselines on that ID split at 0.9482, while Tamarillo v1 base leads overall at 0.9503) and base's fixed-0.50 ood_multilingual_routing Macro-F1 (0.9701 -> 0.9572, though base v2 achieves higher multilingual ROC-AUC 0.9955 vs. 0.9951).
  2. Non-English Threshold Sensitivity & Language Variance (small): Although small v2 achieves #1 multilingual ROC-AUC (0.9964), its fixed-0.50 Macro-F1 (0.9443) trails its near-perfect ranking AUC (threshold calibration on target non-English traffic can tighten operating points). Furthermore, the 5,658 added math/coding hard negatives are English-only, and per-language performance outside the 9 evaluated TyDiQA languages is not separately benchmarked.
  3. Context Window (2,048 Trained / 8,192 RoPE Native): Inputs longer than 2,048 tokens should extract the latest user turn or last 1,500–2,048 tokens before routing.
  4. Routing Gate Scope: This model decides whether a query requires external verification — it does not verify answers itself (pair with Tamarillo/groundedness-guard-small for post-generation faithfulness checks).

License & Citation

Released under the Apache-2.0 License by Tamarillo. All base backbones and training corpora carry commercially permissive licenses (Apache-2.0, MIT, CC-BY-4.0).

@misc{tamarillo_factcheck_gate_guard_v2_2026,
  title        = {Tamarillo Fact-Check Gate Guard v2: Zero-TRC Boundary-Hardened Multilingual Routing Gates},
  author       = {Tamarillo Open-Model Lab},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/Tamarillo/factcheck-gate-guard-small}},
  license      = {Apache-2.0}
}
Downloads last month
61
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Tamarillo/factcheck-gate-guard-small

Quantized
(355)
this model

Datasets used to train Tamarillo/factcheck-gate-guard-small

Space using Tamarillo/factcheck-gate-guard-small 1

Collection including Tamarillo/factcheck-gate-guard-small