greendesk1631's picture
Document parity-verified Gather-INT8 ONNX (onnx/model_quantized.onnx) and { dtype: 'q8' } usage
1c0fb0f verified
|
Raw History Blame Contribute Delete
23.7 kB
---
license: apache-2.0
language:
- en
base_model: jhu-clsp/ettin-encoder-32m
pipeline_tag: token-classification
library_name: transformers
datasets:
- MoritzLaurer/synthetic_zeroshot_mixtral_v0.1
- alisawuffles/WANLI
- nyu-mll/multi_nli
- McGill-NLP/FaithDial
- lytang/C2D-and-D2C-MiniCheck
- Salesforce/summedits
- s-nlp/PsiloQA
tags:
- hallucination-detection
- groundedness
- faithfulness
- token-classification
- span-detection
- rag
- guardrails
- agent-forensics
- observability
- onnx
- tamarillo
- transformers.js
- hallucination
- rag-evaluation
- llm-observability
widget:
- text: 'Context: Acme Corp reported $42M in Q3 revenue with 180 employees.
Answer: Acme Corp reported $42M in Q3 revenue and recently acquired BetaAI for
$120M.'
example_title: Unsupported Claim Span
- text: 'Context: The refund policy covers unopened items within 30 days.
Answer: Unopened items can be returned for a refund within 30 days.'
example_title: Fully Grounded
---
# Tamarillo/groundedness-guard-tiny-en
**Zero-`trust_remote_code`, Apache-2.0 token-span RAG & AI-agent groundedness / hallucination detector** built on `jhu-clsp/ettin-encoder-32m` (`32.0M` parameters, trained up to 3,584 tokens and evaluated up to 4,096 tokens on an 8K backbone, parity-verified ONNX).
Outputs **both** exact token/span-level hallucination localization (`0: supported`, `1: hallucinated` — 1-line drop-in compatible with `KRLabsOrg/lettucedect-v2-mmbert-base`) **and** calibrated document/claim-level groundedness scores (`1 - sigmoid(Top-6 LME)` or `1 - max P(hallucinated)`).
- **Model Family:** `Tamarillo/groundedness-guard-tiny-en` (32.0M, EN) · `Tamarillo/groundedness-guard-small` (140.6M, 14 langs) · `Tamarillo/groundedness-guard-base` (307.5M, 14 langs)
- **Interactive Demo Space:** `Tamarillo/groundedness-guard-demo` (in-browser ONNX token-span highlighter)
![RAG & Agent Groundedness Pareto Frontier](assets/pareto.svg)
## Why This Model Exists
Production RAG observability stacks (`RAGAS`, `DeepEval`, `LangChain`, `LlamaIndex`, `Arize Phoenix`, `TruLens`) and agent tool-output verifiers face three recurring friction points:
1. **`vectara/hallucination_evaluation_model` (HHEM-2.1-Open)** requires `trust_remote_code=True`, ships no ONNX exports, is English-only, and cannot localize which span in a multi-sentence response is hallucinated.
2. **`KRLabsOrg/lettucedect-v2-mmbert-base`** ships no ONNX exports and no smaller 32M/141M tiers for CPU/edge deployments.
3. **Standard `[CLS]` sequence classifiers dilute single-span hallucinations** inside multi-sentence RAG responses and JSON tool-output summaries.
**`Tamarillo/groundedness-guard-tiny-en`** solves all three via standard Hugging Face `ModernBertForTokenClassification` (`trust_remote_code=False`):
- **Backbone:** `jhu-clsp/ettin-encoder-32m` (`32.0M` params, `id2label = {0: "supported", 1: "hallucinated"}`)
- **Language Coverage:** English-only (3.4× smaller than `vectara/hallucination_evaluation_model` & 9.6× smaller than 308M encoders; distilled from `Tamarillo/groundedness-guard-base` via 2-Stage NLI + cross-tokenizer char-aligned span & bag MarginMSE KD)
- **Headline Highlights (Top-6 LME):** 3-Suite Strictly OOD EN Mean **`0.626` AUC** (`RAGTruth` **`0.715`**, `SummEval` **`0.512`**, `FRANK` **`0.649`**); `PsiloQA` EN *(ID)* **`0.964`** (EN Char Span F1 **`0.559`**); 250→3,200-tok depth retention **`-0.034` AUC**; CPU ONNX FP32 **`9.0 ms`** @ 64 tok / **`70.5 ms`** @ 512 tok / **`719.6 ms`** @ 2,048 tok (`122.4 MB`).
---
## Quickstart
### 1. PyTorch / Transformers — Groundedness Score + Exact Hallucinated Spans (Zero `trust_remote_code`)
*Note: Hugging Face's default `pipeline("token-classification")` accepts single strings only; use the `(context, response)` pair helper below.*
```bash
pip install "transformers>=4.48.0" torch
```
```python
import math
import torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
repo = "Tamarillo/groundedness-guard-tiny-en"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForTokenClassification.from_pretrained(repo).eval() # trust_remote_code=False!
def verify_groundedness(context: str, response: str, threshold: float = 0.5, max_length: int = 3584):
"""Returns calibrated P(consistent) via Top-6 LME + exact hallucinated character spans."""
try:
enc = tokenizer(
context, response,
truncation="only_first", max_length=max_length,
return_token_type_ids=False, return_offsets_mapping=True, return_tensors="pt",
)
except Exception:
enc = tokenizer(
context, response,
truncation="longest_first", max_length=max_length,
return_token_type_ids=False, return_offsets_mapping=True, return_tensors="pt",
)
offsets = enc.pop("offset_mapping")[0].tolist()
seq_ids = enc.sequence_ids(0)
with torch.no_grad():
logits = model(**enc).logits[0].float() # [seq_len, 2]: 0=supported, 1=hallucinated
z_hal = logits[:, 1] - logits[:, 0]
p_hal = torch.sigmoid(z_hal)
hyp_idxs = [i for i, sid in enumerate(seq_ids) if sid == 1 and offsets[i][1] > offsets[i][0]]
if not hyp_idxs:
return {"consistent_score": 1.0, "hallucinated_spans": []}
# Top-6 Log-Mean-Exp (beta=2.0) bag score — robust against single-token noise
top_z = torch.topk(z_hal[hyp_idxs], k=min(6, len(hyp_idxs))).values
lme = (torch.logsumexp(2.0 * top_z, dim=0) - math.log(len(top_z))) / 2.0
p_consistent = float(1.0 - torch.sigmoid(lme))
# Merge contiguous hallucinated tokens into character spans
spans = []
for i in hyp_idxs:
prob = float(p_hal[i])
if prob >= threshold:
s, e = offsets[i]
if spans and s <= spans[-1]["end"] + 1:
spans[-1]["end"] = e
spans[-1]["text"] = response[spans[-1]["start"]:e]
spans[-1]["max_prob"] = round(max(spans[-1]["max_prob"], prob), 4)
else:
spans.append({"start": s, "end": e, "text": response[s:e], "max_prob": round(prob, 4)})
return {"consistent_score": round(p_consistent, 4), "hallucinated_spans": spans}
ctx = "Q3 Financial Summary: Operating revenue rose 8% YoY to $4.2 million. The policy explicitly excludes flood damage."
resp = "Q3 operating revenue reached $4.8 million and the policy covers flood damage automatically."
print(verify_groundedness(ctx, resp))
# Example output:
# {'consistent_score': 0.0412, 'hallucinated_spans': [{'start': 29, 'end': 41, 'text': '$4.8 million', 'max_prob': 0.9614}, {'start': 57, 'end': 90, 'text': 'covers flood damage automatically', 'max_prob': 0.9528}]}
```
### 2. CPU-Only ONNX Runtime (`onnxruntime`, Zero PyTorch Required)
```bash
pip install onnxruntime transformers huggingface_hub numpy
```
```python
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
repo = "Tamarillo/groundedness-guard-tiny-en"
tokenizer = AutoTokenizer.from_pretrained(repo)
# Tip: `onnx/model.onnx` (FP32) is fastest on CPU; `onnx/model_fp16.onnx` cuts download size by 50% for GPU/WASM.
onnx_path = hf_hub_download(repo, "onnx/model.onnx")
sess = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
try:
enc = tokenizer(
["Q3 revenue rose 8% YoY to $4.2 million."],
["Q3 revenue reached $6.5 million."],
padding=True, truncation="only_first", max_length=3584,
return_token_type_ids=False, return_tensors="np",
)
except Exception:
enc = tokenizer(
["Q3 revenue rose 8% YoY to $4.2 million."],
["Q3 revenue reached $6.5 million."],
padding=True, truncation="longest_first", max_length=3584,
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].astype(np.float32)
hyp_idxs = [i for i, sid in enumerate(enc.sequence_ids(0)) if sid == 1]
if not hyp_idxs:
print({"consistent_score": 1.0, "peak_token_hal_prob": 0.0})
else:
z_hal = logits[hyp_idxs, 1] - logits[hyp_idxs, 0]
top_z = np.sort(z_hal)[::-1][:6]
mx = float(np.max(2.0 * top_z))
lme = (mx + float(np.log(np.mean(np.exp(2.0 * top_z - mx))))) / 2.0
p_consistent = 1.0 - float(1.0 / (1.0 + np.exp(-lme)))
print({"consistent_score": round(p_consistent, 4), "peak_token_hal_prob": round(float(1.0 / (1.0 + np.exp(-z_hal.max()))), 4)})
# Example output: {'consistent_score': 0.0485, 'peak_token_hal_prob': 0.9712}
```
---
## Benchmark Comparisons
All 8 models were evaluated on the **same NVIDIA A100-80GB GPU** (`BF16` for ModernBERT/mmBERT/Ettin encoders, `FP32` for DeBERTa-v3 which truncates at its native 512-token cap, `bs=1` p50 latency, fixed **`0.50` probability threshold** for F1) with bit-for-bit identical deterministic test splits (`eval_results.json` bundled in this repository). Each model is evaluated with its **native pooling method**: Top-6 LME for Tamarillo Token-Span MIL models and native `max_pool` (`1 - max_t P(hal_t)`) for `KRLabsOrg/lettucedect-v2-mmbert-base` (both pooling modes for all token classifiers are bundled side-by-side in [`eval_results.json`](eval_results.json)).
`Tamarillo/groundedness-guard-tiny-en` (`32.0M`, English-only) targets ultra-low CPU/edge latency (`8.97 ms` @ 64 tok, `70.5 ms` @ 512 tok, `61.3 MB` FP16 ONNX), achieving `0.626` 3-suite OOD EN mean ROC-AUC (`0.715` RAGTruth, `0.649` FRANK, `0.512` SummEval) and minimal long-context decay (`-0.034` AUC from 250→3,200 tok).
### 1. Out-of-Distribution (OOD) English Suites *(RAGTruth, SummEval, FRANK)*
None of `RAGTruth_test`, `SummEval`, `FRANK`, or `FinQA-hallucination-detection` appeared in Tamarillo's training or validation splits (enforced via normalized MD5 deduplication on both pairs and claims). `KRLabsOrg/lettucedect-v2-mmbert-base` was trained on `RAGTruth` train and is explicitly tagged `*(ID)*` on `RAGTruth`. *Note on GPU `bs=1` latency: `mmBERT-small` and `mmBERT-base` share the same 22-layer depth (`384` vs `768` hidden width), so single-item A100 kernel-launch latency is nearly identical (`~30–34 ms`), whereas `small` is ~2× faster on CPU/ONNX (`28.2 ms` vs `53.7 ms` @ 64 tok) and 2.2× smaller. All tested encoders score near-random (`0.40–0.49` AUC) on `FinQA`; full `FinQA` and per-split `RAGTruth` (`qa / summarization / data2txt`) metrics are bundled in [`eval_results.json`](eval_results.json).*
| Model | Params | Pooling / Arch | `RAGTruth` Test (AUC / Hal F1) | `SummEval` (AUC / Hal F1) | `FRANK` (AUC / Hal F1) | **3-Suite EN OOD Mean AUC** | A100 Latency `bs=1` (512 / 2,048 tok) |
|---|---:|---|---:|---:|---:|---:|---:|
| **Tamarillo/groundedness-guard-tiny-en** | 32.0M | Token-Span MIL (Top-6 LME) | 0.715 / 0.592 | 0.512 / 0.292 | 0.649 / 0.657 | **0.626** | 14.2 ms / 28.2 ms |
| **Tamarillo/groundedness-guard-small** | 140.6M | Token-Span MIL (Top-6 LME) | 0.746 / 0.608 | 0.684 / 0.363 | 0.814 / 0.777 | **0.748** | 30.7 ms / 34.5 ms |
| **Tamarillo/groundedness-guard-base** | 307.5M | Token-Span MIL (Top-6 LME) | 0.781 / 0.640 | 0.798 / 0.530 | 0.916 / 0.862 | **0.832** | 29.2 ms / 33.6 ms |
| `vectara/hallucination_evaluation_model` | 109.6M | T5 SeqCls (TRC=True) | 0.832 / 0.578 | 0.773 / 0.386 | 0.911 / 0.835 | **0.839** | 19.1 ms / 64.3 ms |
| `Horizon-Labs/hallucination-guard-base` | 307.5M | SeqCls (8K) | 0.876 / 0.728 | 0.696 / 0.370 | 0.940 / 0.870 | **0.838** | 29.4 ms / 33.6 ms |
| `MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli` | 184.4M | 3-Class NLI (512 cap) | 0.569 / 0.312 | 0.668 / 0.372 | 0.863 / 0.787 | **0.700** | 25.8 ms / 25.8 ms |
| `KRLabsOrg/lettucedect-v2-mmbert-base` | 307.5M | Token-Span (native max-pool) | 0.825 / 0.681 *(ID)* | 0.792 / 0.426 | 0.906 / 0.797 | **0.841** *(1 ID)* | 28.4 ms / 32.7 ms |
| `Tamarillo/zeroshot-policy-guard-base` | 307.5M | General NLI (4K) | 0.625 / 0.411 | 0.743 / 0.346 | 0.959 / 0.882 | **0.776** | 30.0 ms / 38.7 ms |
### 2. 14-Language `PsiloQA` Test *(ID for Tamarillo; OOD for Baselines)* & 4-Depth Long-Context Stability
- **ID / OOD Symmetry:** `s-nlp/PsiloQA` (train split) is part of Tamarillo's Stage 2 training data, so `PsiloQA` test is **in-distribution (`ID`)** for Tamarillo (`small`/`base` across all 14 languages; `tiny-en` on EN only) and **OOD** for all 5 public baselines. Do not compare ID `PsiloQA` scores against OOD baselines as an OOD generalization claim.
- **Class Prevalence & Metric Choice:** `PsiloQA` test is heavily skewed toward hallucinated spans (`~95.5%` hallucinated in EN, `~86.5%` in 13-lang Non-EN), where fixed-threshold `Hal F1` alone looks artificially high even at near-random AUC (`0.908` Hal F1 at `0.562` AUC). Table 2 therefore reports **ROC-AUC / Macro-F1** (`0.5 * (hal_f1 + cons_f1)`), with full per-class F1 & FPR in [`eval_results.json`](eval_results.json).
- **4-Depth LC Needle Seed Provenance & Depth Retention:** The 120 balanced English claims (`60` consistent + `60` hallucinated) embedded inside multi-chunk distractor RAG haystacks (`~250` to `~3,200` tokens) are drawn from **`41` consistent + `60` hallucinated `s-nlp/PsiloQA` EN test rows** supplemented by **`19` strictly OOD consistent `flowaicom/RAGTruth_test` rows** (exact same 120 claims across all 4 depths). Because `19/60` consistent claims come from `RAGTruth_test` while `60/60` hallucinated claims come from `PsiloQA`, source-domain cues can partially lift absolute AUC; the primary metric below is therefore **Depth Retention (`LC 3.2K − LC 250`)**, measuring degradation as distractor context grows 13×.
| Model | Params | `PsiloQA` Status | `PsiloQA` EN (AUC / Macro-F1) | `PsiloQA` Non-EN (AUC / Macro-F1) | LC 250 | LC 800 | LC 1.6K | LC 3.2K | Depth Δ (`3.2K−250`) |
|---|---:|---|---:|---:|---:|---:|---:|---:|---:|
| **Tamarillo/groundedness-guard-tiny-en** | 32.0M | EN-ID / Non-EN OOD | 0.964 / 0.748 | 0.698 / 0.613 | 0.934 | 0.923 | 0.911 | 0.900 | **-0.034** |
| **Tamarillo/groundedness-guard-small** | 140.6M | ID (14-lang) | 0.974 / 0.758 | 0.845 / 0.673 | 0.937 | 0.939 | 0.934 | 0.929 | **-0.008** |
| **Tamarillo/groundedness-guard-base** | 307.5M | ID (14-lang) | 0.976 / 0.758 | 0.842 / 0.692 | 0.957 | 0.955 | 0.952 | 0.959 | **+0.002** |
| `vectara/hallucination_evaluation_model` | 109.6M | OOD | 0.949 / 0.731 | 0.562 / 0.580 | 0.888 | 0.893 | 0.885 | 0.883 | **-0.005** |
| `Horizon-Labs/hallucination-guard-base` | 307.5M | OOD | 0.927 / 0.789 | 0.713 / 0.624 | 0.911 | 0.922 | 0.922 | 0.934 | **+0.023** |
| `MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli` | 184.4M | OOD | 0.910 / 0.602 | 0.698 / 0.609 | 0.880 | 0.814 | 0.561 | 0.524 | **-0.356** |
| `KRLabsOrg/lettucedect-v2-mmbert-base` | 307.5M | OOD | 0.829 / 0.785 | 0.801 / 0.576 | 0.928 | 0.923 | 0.907 | 0.876 | **-0.052** |
| `Tamarillo/zeroshot-policy-guard-base` | 307.5M | OOD | 0.952 / 0.712 | 0.695 / 0.630 | 0.908 | 0.862 | 0.816 | 0.829 | **-0.079** |
### 3. Character/Span-Level Hallucination Localization (`s-nlp/PsiloQA` Gold Character Spans)
Exact character-level span localization at fixed token probability threshold `0.50` across all 1,795 `PsiloQA` test examples (up to 200/lang across 14 languages; **note that `PsiloQA` is `ID` for Tamarillo `small`/`base`, `EN-ID` for `tiny-en`, and `OOD` for `LettuceDetect v2`**). *Note on `tiny-en` Non-EN F1 (`0.461` vs `0.315/0.331` for `small`/`base`): because `PsiloQA` Non-EN is 86.5% hallucinated, English-only `tiny-en` over-predicts hallucination on unfamiliar non-English scripts (`45.7%` char recall at low `46.6%` char precision and `78.1%` doc FPR), inflating raw F1 compared to the much higher-precision (`62–63%`) 14-language `small`/`base` models.*
| Token-Span Model | `PsiloQA` Status | EN Char (Prec / Rec) | EN Span (Char F1 / IoU) | 13-Lang Non-EN Span (Char F1 / IoU) | Overall Char (Prec / Rec) | Overall Char F1 |
|---|---|---:|---:|---:|---:|---:|
| **Tamarillo/groundedness-guard-tiny-en** (32.0M) | EN-ID / Non-EN OOD | 0.685 / 0.472 | 0.559 / 0.388 | 0.461 / 0.300 | 0.506 / 0.461 | **0.482** |
| **Tamarillo/groundedness-guard-small** (140.6M) | ID (14-lang) | 0.685 / 0.456 | 0.547 / 0.377 | 0.315 / 0.187 | 0.652 / 0.269 | **0.381** |
| **Tamarillo/groundedness-guard-base** (307.5M) | ID (14-lang) | 0.723 / 0.428 | 0.538 / 0.368 | 0.331 / 0.198 | 0.655 / 0.274 | **0.387** |
| `KRLabsOrg/lettucedect-v2-mmbert-base` (307.5M) | OOD | 0.760 / 0.726 | 0.742 / 0.590 | 0.415 / 0.262 | 0.727 / 0.398 | **0.514** |
---
## ONNX Exports, Parity Gates & Multi-Length CPU Latency
Every ONNX export is gated against PyTorch FP32 on **both short (≤256 tok) and long (2,048 tok)** pairs across **both token-level and bag-level predictions** (`agreement >= 0.995` and strict max delta thresholds: `<= 0.001` FP32, `<= 0.02` FP16, `<= 0.05` INT8). CPU timings use `onnxruntime` `CPUExecutionProvider` (`bs=1`, 4 intra-op threads) on a GCP `a2-highgpu-1g` Intel Xeon Cascade Lake vCPU (`2.20 GHz`, AVX-512).
| Exported Artifact | File Size | Short Parity (Agree / Δmax) | 2,048-Tok Parity (Agree / Δmax) | CPU 4-Th @ 64 tok | CPU 4-Th @ 512 tok | CPU 4-Th @ 1,024 tok | CPU 4-Th @ 2,048 tok |
|---|---:|---:|---:|---:|---:|---:|---:|
| FP32 (`onnx/model.onnx`) | 122.4 MB | 1.0000 (Δ≤0.0000) | 1.0000 (Δ≤0.0000) | 9.0 ms | 70.5 ms | 214.2 ms | 719.6 ms |
| FP16 (`onnx/model_fp16.onnx`) | 61.3 MB | 1.0000 (Δ≤0.0012) | 1.0000 (Δ≤0.0026) | 10.9 ms | 82.6 ms | 261.6 ms | 917.1 ms |
**Excluded precision exports (parity gate):**
- **INT8 dynamic quantization: withheld** — failed our strict token + bag parity gate (`agreement >= 0.995` and max delta limit on short & 2,048-token inputs; observed short bag agree=`0.75`, Δmax=`0.61581`; 2,048-tok bag agree=`0.875`, Δmax=`0.47163`).
---
## Training Recipe, Data Provenance & Reproducibility
- **Base Model:** `jhu-clsp/ettin-encoder-32m` (canonical foundation checkpoint)
- **Architecture & Training Pipeline:** Standard `ModernBertForTokenClassification` (`0: supported`, `1: hallucinated`) trained via a **2-Stage Distillation Pipeline**: **Stage 1** warms up `jhu-clsp/ettin-encoder-32m` on 112K clean English semantic NLI pairs (`MoritzLaurer/synthetic_zeroshot_mixtral_v0.1` [Apache-2.0], `alisawuffles/WANLI` [CC-BY-4.0], permissive OANC genres of `nyu-mll/multi_nli`) to preserve entailment reasoning; **Stage 2** performs **Cross-Tokenizer Character-Aligned Token-Span + Bag-Level MarginMSE & KL Knowledge Distillation** from our Apache-2.0 307.5M teacher (`Tamarillo/groundedness-guard-base`) combined with hard-label Hybrid Exact-Span BCE + Top-6 Log-Mean-Exp MIL + Max-Pool Calibration + Same-Document Bag Ranking across English groundedness corpora (`McGill-NLP/FaithDial` [MIT], `lytang/C2D-and-D2C-MiniCheck` [MIT], `Salesforce/summedits` [CC-BY-4.0], `s-nlp/PsiloQA` EN [CC-BY-4.0], minimal-edit counterfactuals, multi-passage paragraphs, and same-haystack LC pairs up to 3,584 tokens). Both raw and EMA (`decay=0.996`) checkpoints were evaluated strictly on validation (`raw` edged out `ema` at `0.8212` vs `0.8182` composite selection score, so `raw` was selected automatically).
- **Upstream Synthetic Provenance Note:** While `Mixtral-NLI`, `MiniCheck`, and `Salesforce/summedits` are published under permissive repository licenses (`Apache-2.0` / `MIT` / `CC-BY-4.0`), they include synthetic pairs originally generated or edited using LLMs; users with strict model-lineage compliance requirements should verify upstream terms for their jurisdiction.
- **Validation Selection:** Best checkpoint selected strictly on validation composite (`selection_score = 0.8212`, val ROC-AUC `max=0.8607` / `LME=0.8618`, weights=`raw`; test sets were never used for checkpoint selection).
Bundled reproducible scripts in this repository:
- [`scripts/schema.py`](scripts/schema.py)
- [`scripts/data_builder_tok.py`](scripts/data_builder_tok.py)
- [`scripts/train_tok.py`](scripts/train_tok.py)
- [`scripts/train_distill_tok.py`](scripts/train_distill_tok.py)
- [`scripts/export_onnx_tok.py`](scripts/export_onnx_tok.py)
- [`scripts/eval_suite.py`](scripts/eval_suite.py)
- [`scripts/eval_span_f1.py`](scripts/eval_span_f1.py)
- [`eval_results.json`](eval_results.json)
- [`onnx_benchmark.json`](onnx_benchmark.json)
- [`training_summary.json`](training_summary.json)
---
### Gather-INT8 Quantized ONNX (`onnx/model_quantized.onnx` — `67.16 MB`, `1.82x` smaller)
- **Verified Parity (`onnx/quantization_check.json`):** `100.0%` prediction agreement vs. FP32 ONNX (mean abs probability diff `0.00119`, max `0.01946`; `26.84 ms` 4-thread CPU p50 @ 256 tokens).
- **Browser WASM / Node.js (`@huggingface/transformers` v3):** pass `{ dtype: "q8" }` to load `onnx/model_quantized.onnx` automatically.
## Limitations & Candid Comparison
1. **Multi-step numerical & tabular arithmetic (`FinQA`):** Compact bi-directional encoders do not execute symbolic arithmetic; subtle multi-step calculation errors in dense financial tables (`0.40–0.49` AUC across all tested encoders) require tool/code verification rather than an encoder alone.
2. **Where public baselines win:** On the strictly English 3-suite OOD mean (Table 1), `Tamarillo/groundedness-guard-tiny-en` scores `0.626` compared to English-specialized `vectara/hallucination_evaluation_model` (`0.839`, requires `trust_remote_code=True`, no ONNX, 2.28× slower @ 2K), `Horizon-Labs/hallucination-guard-base` (`0.838`, leads on `RAGTruth` `0.876` and `FRANK` `0.940`), and RAGTruth-trained `KRLabsOrg/lettucedect-v2-mmbert-base` (`0.841` *(1 ID)*, `0.825` on `RAGTruth` *(ID)*). Inspect `eval_results.json` per-split (`qa / summarization / data2txt`) to choose the best model for your traffic.
3. **Capacity & language scope of `tiny-en` (32.0M):** This model is English-only and tuned for low-latency extractive/long-context RAG (`PsiloQA` EN and `LC 3.2K` needle at `9.0 ms` CPU @ 64 tok), but lags 141M–308M encoders on subtle abstractive summarization (`SummEval`: `0.512` AUC) and non-English traffic. Use `Tamarillo/groundedness-guard-small` or `base` for multilingual or abstractive workloads.
4. **Multilingual OOD evaluation gap:** All 13 non-English languages are evaluated only in-distribution on `s-nlp/PsiloQA` test (with aggregate Non-EN metrics reported in Table 2 rather than per-language breakdowns or an external OOD multilingual groundedness benchmark).
5. **Span recall trade-off vs. `KRLabsOrg/lettucedect-v2-mmbert-base`:** Because Tamarillo combines exact-span BCE with Top-6 LME MIL and max-pool bag calibration, it concentrates token probability tightly on core offending tokens (high EN precision `0.69–0.72`, lower full-span recall `0.43–0.47` at `threshold=0.50`). Consequently, `KRLabsOrg/lettucedect-v2-mmbert-base` achieves higher full-span character F1 (`0.514` overall / `0.742` EN vs. `0.387` / `0.538` for `base`, `0.381` / `0.547` for `small`, and `0.482` / `0.559` for `tiny-en` on `PsiloQA` gold spans, even though `PsiloQA` is ID for Tamarillo and OOD for `LettuceDetect v2`). Prefer `Tamarillo` for document/claim groundedness scoring, long-context stability, ONNX/edge deployment, and concise core-error highlighting; prefer `LettuceDetect v2` (or lower Tamarillo's span threshold to `0.25–0.35`) when exhaustive full-span character recall is the primary objective. Note also that `flowaicom/RAGTruth_test` provides only document-level labels, so Table 3 evaluates gold spans on `s-nlp/PsiloQA` test.
## License
Weights, ONNX exports, and training/evaluation scripts are released under the **Apache-2.0** license.