Tamarillo/factcheck-gate-guard-small

Balanced Multilingual & INT8-Accelerated CPU Tier (141M) β€” Apache-2.0, zero-trust_remote_code, calibrated prompt fact-check & RAG verification routing gate built on standard ModernBertForSequenceClassification (0=NO_FACT_CHECK_NEEDED, 1=FACT_CHECK_NEEDED), matching the exact label schema of vllm-project/semantic-router and pairing natively with Tamarillo/groundedness-guard-base for a complete 2-stage Apache-2.0 HaluGate pipeline.

Part of the Tamarillo open-model security & observability suite (companion browser demo Space: Tamarillo/factcheck-gate-guard-demo).


Quickstart (< 30 Seconds)

pip install "transformers>=4.48" torch

Zero trust_remote_code, zero peft:

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

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

prompts = [
    "In Python 3.13, was the Global Interpreter Lock (GIL) removed by default or behind a build flag?",
    "Write a Python function to reverse a singly linked list in-place.",
    "Write a humorous dialogue between Albert Einstein and Marie Curie about pizza in Paris.",
]

inputs = tokenizer(prompts, padding=True, truncation=True, max_length=2048, return_tensors="pt")
with torch.no_grad():
    logits = model(**inputs).logits
    # Raw probabilities (T=1.0; calibrate threshold on target traffic for strict low-cost gating)
    probs = torch.softmax(logits, dim=-1)
    # Optional NLL-calibrated probabilities from calibration.json (T=1.0812)
    probs_cal = torch.softmax(logits / 1.0812, dim=-1)

for prompt, p, pc in zip(prompts, probs, probs_cal):
    p_yes = float(p[1])
    label = model.config.id2label[int(p_yes >= 0.5)]
    print(f"{label:21s} | P_raw={p_yes:.4f} | P_cal={float(pc[1]):.4f} | {prompt[:55]}...")
ONNX Runtime (CPU/Gateway), Transformers.js (Browser), & 2-Stage HaluGate Pipeline

1. ONNX Runtime (CPU / Gateway Sidecar)

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

model_id = "Tamarillo/factcheck-gate-guard-small"
tokenizer = AutoTokenizer.from_pretrained(model_id)
onnx_path = hf_hub_download(model_id, "onnx/model_int8.onnx")  # fastest on x86 CPU (1.35x vs FP32); or "onnx/model.onnx" / "onnx/model_fp16.onnx"
session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])

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

2. Transformers.js (@huggingface/transformers>=3.5.1)

Note: FP16 ONNX is 268.7 MB; for smallest client-side WASM downloads, prefer Tamarillo/factcheck-gate-guard-tiny-en (61.3 MB).

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

const modelId = "Tamarillo/factcheck-gate-guard-small";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId, { dtype: "fp16" });

const inputs = tokenizer("When was the Eiffel Tower built?", { truncation: true, max_length: 2048 });
const { logits } = await model(inputs);
const [z0, z1] = logits.data;
const mx = Math.max(z0, z1);
const pYes = Math.exp(z1 - mx) / (Math.exp(z0 - mx) + Math.exp(z1 - mx));
console.log({ label: pYes >= 0.5 ? "FACT_CHECK_NEEDED" : "NO_FACT_CHECK_NEEDED", p_factcheck: pYes });

3. 2-Stage Apache-2.0 HaluGate Pipeline (Gate β†’ Groundedness Verification)

Route only FACT_CHECK_NEEDED prompts to retrieval + token-span hallucination verification using Tamarillo/groundedness-guard-base, bypassing verification latency on pure coding, math, rewriting, and creative prompts.


Why This Family Exists

Production LLM gateways (vllm-project/semantic-router, RAG routers, agent proxies) need a low-latency switch (down to 9.6 ms on x86 CPU with tiny-en) that decides whether an incoming prompt requires external factual verification (FACT_CHECK_NEEDED) or can be answered directly (NO_FACT_CHECK_NEEDED). Existing public routers carry four practical blockers:

  1. trust_remote_code=True supply-chain risk: vllm-sr/mmbert32k-factcheck-classifier-merged (307.5M) requires custom vllm-sr/mmbert-32k-yarn remote code, ships zero ONNX exports, and suffers poor probability calibration (0.150 ECE on its own test split).
  2. No lightweight CPU/edge tier: mmbert32k ships only a 307.5M / 1.23 GB checkpoint; vllm-sr/halugate-sentinel (150M) is English-only and ships zero ONNX exports.
  3. Multilingual & multi-turn collapse: Because vllm-sr/fact-check-classification-dataset is English-only and single-turn, mmbert32k drops to 0.611 TPR@5%FPR on multilingual OOD queries and 0.513 Macro-F1 (18.7% recall) on synthetic long multi-turn payloads.
  4. Honest context-length tradeoff: Our canonical backbones support up to 8,192 tokens native RoPE (trained at max_length=2048), NOT mmbert32k's 32K YaRN window. For >8K full-transcript routing without windowing to recent turns, mmbert32k remains required.

Tamarillo/factcheck-gate-guard-small delivers:

  • 2.2Γ— smaller than vllm-sr/mmbert32k-factcheck-classifier-merged while delivering strong multilingual routing (0.995 AUC / 0.962 TPR@5%FPR across 10+ non-English languages, +35.0pp TPR@5%FPR over vllm-sr/mmbert32k), 0.990 Public OOD-2 Mean ROC-AUC (+3.0pp vs. vllm-sr/mmbert32k 0.960), and parity-verified Selective INT8 ONNX running in 20.1 ms on x86 CPU (1.35Γ— faster than FP32).
  • 2-Model Consensus Rubric Supervision + Prefix Deconfounding: Combines prefix-stripped vllm-sr/fact-check-classification-dataset (train split, Reddit [ WP ] tags removed) with 10,831 high-confidence 2-model consensus prompts (Qwen/Qwen3-4B + mistralai/Mistral-7B-Instruct-v0.3) across OpenAssistant/oasst1 (EN + 14 non-EN langs) and nvidia/HelpSteer2, plus 6% symmetric multi-turn context augmentation β€” 100% dataset-disjoint from every OOD test suite.

Family Ladder

Model Backbone Params Langs Real Mixed OOD AUC (n=1,600) Multilingual OOD (n=468, AUC / F1) Public OOD-2 Mean AUC A100 @ 64 tok Best CPU @ 64 tok FP16 ONNX
Tamarillo/factcheck-gate-guard-tiny-en jhu-clsp/ettin-encoder-32m 32.0M English 0.992 0.936 / 0.868 0.964 13.5 ms 9.6 ms (FP32) 61.3 MB
Tamarillo/factcheck-gate-guard-small jhu-clsp/mmBERT-small 140.6M Multilingual 0.986 0.995 / 0.938 0.990 28.8 ms 20.1 ms (INT8) 268.7 MB
Tamarillo/factcheck-gate-guard-base jhu-clsp/mmBERT-base 307.5M Multilingual 0.990 0.995 / 0.970 0.993 28.2 ms 53.4 ms (FP32) 587.1 MB

Public OOD Pareto Frontier

Public OOD 2-Suite Pareto Frontier

Head-to-Head Evaluation (7 Models, Same NVIDIA A100-SXM4-40GB)

All 7 models were evaluated on the exact same GPU and exact same splits using raw softmax probabilities (T = 1.0). Zero rows from any OOD evaluation dataset (SimpleQA, FRAMES, HumanEvalPack, MBPP, GSM8K, TyDiQA, CohereLabs/aya_evaluation_suite, or internal diagnostics) appear in Tamarillo's train or validation splits.

Table 1: Public Dataset-Disjoint OOD Benchmarks (ROC-AUC / Metric)

(Headline Public OOD-2 Mean ROC-AUC averages only the two public dataset-disjoint suites below (n=1,600 + n=468); author-curated diagnostics and ID splits are reported separately in Table 2 and excluded from the Pareto chart.)

Model Params Langs Compatibility Real Mixed OOD (n=1,600, AUC / TPR@5%FPR) Multilingual OOD (n=468, AUC / F1) Public OOD-2 Mean AUC A100 @ 64 / 2,048 tok
Tamarillo tiny-en 32.0M EN Standard AutoModel (Zero TRC) 0.992 / 0.969 0.936 / 0.868 0.964 13.5 / 26.9 ms
Tamarillo small 140.6M Multi Standard AutoModel (Zero TRC) 0.986 / 0.934 0.995 / 0.938 0.990 28.8 / 32.8 ms
Tamarillo base 307.5M Multi Standard AutoModel (Zero TRC) 0.990 / 0.974 0.995 / 0.970 0.993 28.2 / 32.2 ms
vllm-sr/mmbert32k-factcheck-classifier-merged 307.5M Multi trust_remote_code=True (32K YaRN) 0.984 / 0.948 0.935 / 0.827 0.960 28.5 / 32.5 ms
vllm-sr/halugate-sentinel 149.6M EN Standard AutoModel (No ONNX) 0.946 / 0.728 0.746 / 0.605 0.846 29.1 / 33.1 ms
MoritzLaurer/deberta-v3-base-zeroshot-v2.0 184.4M EN Zero-Shot NLI (512 cap) 0.783 / 0.110 0.762 / 0.536 0.773 25.6 / 25.3 ms
Tamarillo/zeroshot-policy-guard-small 140.6M Multi Zero-Shot NLI 0.826 / 0.356 0.831 / 0.374 0.829 28.9 / 33.0 ms

Public OOD suite composition & preprocessing:

  • Real Mixed OOD (n=1,600, 50/50): Positives (FACT_CHECK_NEEDED) = basicv8vc/SimpleQA (MIT, 400 rows, problem field) + google/frames-benchmark (Apache-2.0, 400 rows, Prompt field); Negatives (NO_FACT_CHECK_NEEDED) = bigcode/humanevalpack (MIT, 400 rows across 6 coding languages, prompt docstring/signature field) + openai/gsm8k test (MIT, 400 rows, question field).
  • Multilingual OOD (n=468, 50/50): Positives = google-research-datasets/tydiqa (Apache-2.0, 234 non-EN rows, question_text field across 10 languages); Negatives = CohereLabs/aya_evaluation_suite (Apache-2.0, 234 non-EN creative/writing/translation prompts, inputs field). (Reported as an aggregate across non-English languages; per-language slice breakdowns are not yet reported.)
  • Zero-Shot NLI Baseline Protocol: Both MoritzLaurer/deberta-v3-base-zeroshot-v2.0 and Tamarillo/zeroshot-policy-guard-small were evaluated as (premise=prompt, hypothesis="This user request requires checking external real-world facts or knowledge to answer accurately."), scoring P(entailment).
  • Source-Confounding Caveat: Because both public OOD suites draw positive and negative examples from distinct public corpora (e.g., interrogative QA datasets vs. code signatures / math word problems / creative prompts), surface style and format cues likely contribute to high ROC-AUC (~0.98–0.995) alongside factual-verification intent.

Table 2: Gateway Cost/Recall Audits, Internal Diagnostics & vllm-sr Official Test (ID)

(Reported separately from Table 1 and never mixed into the Public OOD-2 Pareto frontier.)

Model Hard Factual Recall@0.50 ↑ (n=1,200) Coding/Math False-Trigger@0.50 ↓ (n=1,200) Real Mixed F1@0.50 Hybrid Boundary (curated, n=60) (AUC / F1) Long Multi-Turn (synthetic, n=300) (AUC / F1) vllm-sr Test (ID, n=3,349) (AUC / F1) vllm-sr ECE ↓
Tamarillo tiny-en 99.3% 13.0% 0.898 1.000 / 0.983 1.000 / 0.990 0.986 / 0.940 0.0183
Tamarillo small 99.2% 14.3% 0.887 1.000 / 1.000 1.000 / 1.000 0.989 / 0.946 0.0131
Tamarillo base 99.5% 10.8% 0.916 1.000 / 1.000 1.000 / 1.000 0.988 / 0.950 0.0124
vllm-sr/mmbert32k-factcheck-classifier-merged 93.2% 2.0% 0.951 0.929 / 0.899 1.000 / 0.513 0.912 / 0.805 0.1497
vllm-sr/halugate-sentinel 97.2% 24.8% 0.795 0.984 / 0.916 1.000 / 0.333 0.985 / 0.947 0.0184
MoritzLaurer/deberta-v3-base-zeroshot-v2.0 88.8% 28.0% 0.729 0.949 / 0.832 0.500 / 0.333 0.783 / 0.685 0.1711
Tamarillo/zeroshot-policy-guard-small 31.2% 2.8% 0.605 0.974 / 0.436 0.653 / 0.332 0.828 / 0.388 0.4631

Table 2 split compositions:

  • Hard Factual Recall@0.50 (n=1,200, all positive): basicv8vc/SimpleQA (600, problem) + google/frames-benchmark (600, Prompt).
  • Coding/Math False-Trigger@0.50 (n=1,200, all negative): bigcode/humanevalpack (400, prompt) + google-research-datasets/mbpp test (400, text) + openai/gsm8k test (400, question).
  • Hybrid Boundary (n=60, author-curated, unpublished): 30 version/CVE/API-specific coding & live-data math prompts (FACT_CHECK_NEEDED) vs. 30 entity-rich creative/rewriting & pure algorithmic coding prompts (NO_FACT_CHECK_NEEDED).
  • Long Multi-Turn (n=300, synthetic stress test, unpublished): ~1,400-token neutral conversation prefix prepended symmetrically before 150 factual vs. 150 coding/creative tail queries to isolate truncation/dilution sensitivity.
  • vllm-sr Official Test (n=3,349, ID): Official test split of vllm-sr/fact-check-classification-dataset (evaluated both raw and with Reddit [ WP ] prefixes stripped: stripped F1 = 0.947 for small).

Candid summary of wins & losses:

  • Where Tamarillo wins:
    • Public OOD-2 Pareto Frontier (n=2,068): All three Tamarillo tiers (base 0.993, small 0.990, tiny-en 0.964) outperform all 4 baselines (vllm-sr/mmbert32k 0.960, halugate-sentinel 0.846, Tamarillo zero-shot 0.829, DeBERTa-v3 zero-shot 0.773). On English Real Mixed OOD (n=1,600), 32M tiny-en (0.992 AUC / 0.969 TPR@5%FPR) outperforms 307.5M vllm-sr/mmbert32k (0.984 / 0.948) at 9.6Γ— smaller size.
    • Multilingual OOD Routing (n=468, 10+ non-EN languages): base (0.995 AUC / 0.970 F1 / 0.987 TPR@5%FPR) and small (0.995 AUC / 0.938 F1 / 0.962 TPR@5%FPR) strongly outperform vllm-sr/mmbert32k (0.935 AUC / 0.827 F1 / 0.611 TPR@5%FPR) and English-only halugate-sentinel (0.746 AUC / 0.605 F1).
    • Hard Factual Recall (SimpleQA+FRAMES, n=1,200) & Calibration: Tamarillo hits 99.2%–99.5% recall (vs. vllm-sr/mmbert32k 93.2%) and 0.0124–0.0183 ECE on vllm-sr test (8–12Γ— cleaner than vllm-sr/mmbert32k's 0.1497 ECE).
    • Zero trust_remote_code & Parity-Verified ONNX: Clean drop-in AutoModelForSequenceClassification with FP32, FP16, and (on small) selective INT8 ONNX exports.
  • Where baselines win (reported candidly):
    • Default-threshold (0.50) Coding/Math False-Trigger Rate: Because Tamarillo trains with mild missed-fact-check weighting (fn_weight=1.15) to prioritize factual recall (99.2%–99.5%), at the default 0.50 threshold vllm-sr/mmbert32k achieves a much lower Coding/Math false-trigger FPR (2.0% vs. Tamarillo 10.8%–14.3%) and higher threshold-0.50 Macro-F1 on Real Mixed OOD (0.951 vs. 0.887–0.916). At matched 5% FPR on Real Mixed OOD, base (0.974 TPR@5%FPR) and tiny-en (0.969) beat vllm-sr/mmbert32k (0.948), while small (0.934) trails slightly β€” cost-sensitive gateways should raise the operating threshold above 0.50 and calibrate on target traffic.
    • Ultra-Long >8K Context: vllm-sr/mmbert32k supports 32K YaRN context, whereas Tamarillo supports up to 8,192 native RoPE tokens (2,048 trained).

Calibration & Operating Thresholds (calibration.json)

Fit strictly on the held-out validation split (n=4,268, zero test-set leakage) and shipped in calibration.json:

Policy / Metric Raw Logits (T = 1.0, default) NLL-Calibrated (logits / 1.0812)
Validation Temperature T 1.0000 1.0812
Validation ECE / Brier 0.01759 / 0.04688 0.01773 / 0.04643
Validation 5% FPR Threshold 0.83004 (thr_5fpr_val) 0.81258 (calibrated_thr_5fpr)
Validation 95% TPR Threshold 0.66888 (thr_95tpr_val) 0.65709 (calibrated_thr_95tpr)

OOD Operating-Point Caveat: Benchmark Tables 1–2 evaluate raw-logit (T = 1.0) predictions at threshold 0.50 plus oracle TPR@5%FPR on each suite. On Real Mixed OOD, achieving 5% FPR empirically required a higher threshold (0.9730) than validation thr_5fpr_val (0.83004), and OOD recall/FPR were not directly re-evaluated at thr_5fpr_val. For production cost-control gateways, calibrate your decision threshold on a small labeled sample of your own traffic distribution.


Parity-Verified ONNX Exports & CPU/GPU Latency

Exported and probability-parity verified on both short prompts (256 tok) and long multi-turn payloads (2,048 tok). Selective MatMul-only dynamic INT8 (onnx/model_int8.onnx, excluding head/classifier/norm/embedding projections) passed our strict 1.0000 agreement parity gate at both short and 2,048-token lengths and delivers a 1.35Γ— x86 CPU speedup over FP32 (20.1 ms vs. 27.2 ms @ 64 tok).

Artifact File Size Short Parity (Agree / Max Ξ”p) 2,048-Tok Parity (Agree / Max Ξ”p) CPU 64 tok (p50) CPU 256 tok (p50) CPU 512 tok (p50) CPU 1,024 tok (p50)
FP32 ONNX onnx/model.onnx 537.0 MB 1.0000 / 0.00000 1.0000 / 0.00000 27.2 ms 87.1 ms 196.1 ms 555.5 ms
FP16 ONNX onnx/model_fp16.onnx 268.7 MB 1.0000 / 0.00002 1.0000 / 0.00005 32.2 ms 104.9 ms 221.9 ms 645.2 ms
Selective INT8 ONNX onnx/model_int8.onnx 417.1 MB 1.0000 / 0.01136 1.0000 / 0.04033 20.1 ms 68.6 ms 146.7 ms 473.1 ms

Hardware disclosure: CPU latency measured with onnxruntime (4 intra-op threads, batch size 1) on GCP g2-standard-8 (Intel Xeon Cascade Lake @ 2.20 GHz, AVX-512, 4 ORT threads). GPU latency measured on NVIDIA A100-SXM4-40GB (bf16, batch size 1): 28.8 ms @ 64 tok, 29.4 ms @ 512 tok, 32.8 ms @ 2,048 tok.


Training Summary & Data Provenance

  • Canonical Backbone: jhu-clsp/mmBERT-small (140.6M parameters, Apache-2.0).
  • Training Corpus (24,848 prompts, 100% commercially permissive licenses, 100% dataset-disjoint from all OOD suites):
    • vllm-sr/fact-check-classification-dataset (Apache-2.0, train split only, Reddit [ WP ]/[ EU ] prefixes stripped).
    • OpenAssistant/oasst1 (Apache-2.0, EN + 14 non-EN languages) & nvidia/HelpSteer2 (CC-BY-4.0): 10,831 (43.6% of training data) high-confidence 2-model consensus prompts labeled by Qwen/Qwen3-4B (Apache-2.0) + mistralai/Mistral-7B-Instruct-v0.3 (Apache-2.0) using a binary factual-verification rubric (FACT_CHECK_NEEDED for verifiable world facts/dates/APIs/CVEs/stats; NO_FACT_CHECK_NEEDED for pure coding, math, creative writing, rewriting, translation, opinions), retaining only prompts where both models agreed (>= 0.65 or <= 0.35).
    • 1,500 symmetric multi-turn context-prefix augmented training examples (balanced across both labels).
  • Objective & Selection: Asymmetric BCE (fn_weight=1.15, 0.03 label smoothing) + 0.25 soft-teacher mixing on consensus chat prompts + EMA (0.996), trained at max_length=2048. Checkpoints selected strictly by validation composite (0.40 * ROC-AUC + 0.35 * Macro-F1 + 0.25 * TPR@5%FPR).

Limitations & Responsible Use

  • Gating signal, not a fact-checker: This model predicts whether a prompt requires external factual verification β€” it does not verify factual truth itself. Pair it with retrieval/search and a groundedness verifier (such as Tamarillo/groundedness-guard-base).
  • Default-threshold coding/math false triggers & threshold shift: At threshold 0.50, 14.3% of pure coding/math prompts trigger verification (99.2% hard factual recall). Empirically, Real Mixed OOD required 0.9730 for 5% FPR vs. validation thr_5fpr_val = 0.83004; calibrate on target traffic for strict cost budgets.
  • Unmeasured synthetic-label noise: 43.6% (10,831 / 24,848) of training prompts carry 2-model LLM consensus pseudo-labels (Qwen3-4B + Mistral-7B-Instruct-v0.3) without a formal human inter-annotator agreement audit; systematic agreement biases shared by both teacher LLMs can transfer to the student.
  • Benchmark source-confounding & unpublished diagnostics: Both public OOD suites draw positives and negatives from separate public datasets (which may inflate ROC-AUC via style/format cues), Multilingual OOD (n=468) is reported only as an aggregate without per-language breakdowns, and our internal n=60 Hybrid Boundary and n=300 Multi-Turn evaluation scripts are not yet published in an external repository.
  • Context limit vs. 32K YaRN: Trained up to 2,048 tokens (8,192 native RoPE). For >8K multi-turn logs, window to the latest user turns before routing.
  • Language scope: Multilingual (14+ languages). tiny-en is trained primarily for English gateways; use small or base for production non-English traffic.
Downloads last month
2
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
(336)
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

Evaluation results

  • ROC-AUC on Public Real Mixed OOD (SimpleQA + FRAMES vs HumanEvalPack + GSM8K, n=1,600)
    self-reported
    0.986
  • TPR@5%FPR on Public Real Mixed OOD (SimpleQA + FRAMES vs HumanEvalPack + GSM8K, n=1,600)
    self-reported
    0.934
  • ROC-AUC on TyDiQA non-EN vs CohereLabs/aya_evaluation_suite non-EN (n=468)
    self-reported
    0.995
  • Macro-F1 on TyDiQA non-EN vs CohereLabs/aya_evaluation_suite non-EN (n=468)
    self-reported
    0.938