flintglass commited on
Commit
3300666
·
verified ·
1 Parent(s): 48f4150

Release Flintglass PrismVerify-Small v1 (mmBERT-small 140M, 1800+ langs, 8K ctx, 16ms CPU ONNX INT8)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - multilingual
5
+ - en
6
+ - es
7
+ - fr
8
+ - de
9
+ - zh
10
+ - ja
11
+ - ko
12
+ - ar
13
+ - ru
14
+ - pt
15
+ - hi
16
+ base_model: jhu-clsp/mmBERT-small
17
+ datasets:
18
+ - flintglass/PrismVerify-Corpus
19
+ library_name: transformers
20
+ pipeline_tag: text-classification
21
+ tags:
22
+ - hallucination-detection
23
+ - groundedness
24
+ - faithfulness
25
+ - rag
26
+ - rag-evaluation
27
+ - fact-checking
28
+ - nli
29
+ - modernbert
30
+ - onnx
31
+ - flintglass
32
+ ---
33
+
34
+ # PrismVerify-Small
35
+
36
+ **8,192-Token RAG Hallucination & Groundedness Verifier · 3-Class (`FAITHFUL` / `CONTRADICTION` / `UNSUPPORTED`) · Apache 2.0 · PyTorch + ONNX INT8**
37
+
38
+ > Built by **[Flintglass Labs](https://huggingface.co/flintglass)** — an ultra-fast 140M multilingual 8K-context hallucination verifier built for low-latency CPU/edge RAG pipelines.
39
+
40
+ - **Interactive Demo:** [flintglass/PrismVerify-Demo](https://huggingface.co/spaces/flintglass/PrismVerify-Demo)
41
+ - **Model Family:** [`PrismVerify-Large`](https://huggingface.co/flintglass/PrismVerify-Large) (395M) · [`PrismVerify-Multilingual`](https://huggingface.co/flintglass/PrismVerify-Multilingual) (307M, 1,800+ langs) · [`PrismVerify-Small`](https://huggingface.co/flintglass/PrismVerify-Small) (140M, 1,800+ langs)
42
+ - **Training Dataset & Benchmark:** [`flintglass/PrismVerify-Corpus`](https://huggingface.co/datasets/flintglass/PrismVerify-Corpus) (Apache 2.0)
43
+
44
+ ---
45
+
46
+ ## Why PrismVerify?
47
+
48
+ Production RAG pipelines and AI agents routinely stuff **2,000–8,000 tokens** of retrieved documents into context. Legacy hallucination detectors (`vectara/HHEM-2.1-Open`, `DeBERTa-v3-NLI`) either truncate at 512 tokens or OOM on multi-chunk contexts, while RAGTruth-only detectors overfit to one dataset and drop sharply on HaluEval, DocNLI, and long multi-document RAG.
49
+
50
+ **`PrismVerify-Small`** brings precision optical clarity to groundedness verification:
51
+
52
+ | Property | Specification |
53
+ |---|---|
54
+ | **Backbone** | `jhu-clsp/mmBERT-small` (140M parameters) |
55
+ | **Native Context Window** | **8,192 tokens** (claim placed first so `[CLAIM]` is never truncated!) |
56
+ | **Languages** | Multilingual (1,800+ languages via mmBERT) |
57
+ | **Classes (`id2label`)** | `0: FAITHFUL`, `1: CONTRADICTION`, `2: UNSUPPORTED` |
58
+ | **Calibration** | Post-hoc temperature scaling (`T = 1.0461`) baked directly into the linear head |
59
+ | **Formats Included** | Safetensors (`model.safetensors`), ONNX FP32 (`onnx/model.onnx`, 563.08 MB), ONNX INT8 (`onnx/model_int8.onnx`, 436.44 MB) |
60
+ | **License** | **Apache 2.0** (ungated, commercial-friendly) |
61
+
62
+ ---
63
+
64
+ ## Quickstart
65
+
66
+ ### 1. Drop-in PyTorch / `transformers`
67
+
68
+ ```python
69
+ import torch
70
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
71
+
72
+ model_id = "flintglass/PrismVerify-Small"
73
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
74
+ model = AutoModelForSequenceClassification.from_pretrained(model_id).eval()
75
+
76
+ context = "In Q3 2026, Meridian Robotics reported revenue of $142.8M, up 18.4% YoY, with gross margin of 59.8%."
77
+ claim = "Meridian Robotics grew Q3 revenue by 18.4% to $142.8M and expanded gross margin to 65%."
78
+ text = f"[CLAIM]\n{claim}\n\n[CONTEXT]\n{context}"
79
+
80
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=8192)
81
+ with torch.no_grad():
82
+ probs = torch.softmax(model(**inputs).logits, dim=-1)[0]
83
+
84
+ print({
85
+ "faithful": probs[0].item(),
86
+ "contradiction": probs[1].item(),
87
+ "unsupported": probs[2].item(),
88
+ "hallucination_score": 1.0 - probs[0].item(),
89
+ "is_hallucinated": (1.0 - probs[0].item()) >= 0.5,
90
+ })
91
+ ```
92
+
93
+ ### 2. Ultra-Fast CPU Inference with ONNX Runtime (INT8)
94
+
95
+ ```python
96
+ import numpy as np
97
+ import onnxruntime as ort
98
+ from huggingface_hub import hf_hub_download
99
+ from transformers import AutoTokenizer
100
+
101
+ model_id = "flintglass/PrismVerify-Small"
102
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
103
+ onnx_path = hf_hub_download(repo_id=model_id, filename="onnx/model_int8.onnx")
104
+ session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
105
+
106
+ text = "[CLAIM]\nThe solar plant includes 20 MWh battery storage.\n\n[CONTEXT]\nThe 50 MW solar plant does not yet include battery storage."
107
+ enc = tokenizer(text, return_tensors="np", truncation=True, max_length=8192)
108
+ logits = session.run(None, {
109
+ "input_ids": enc["input_ids"].astype(np.int64),
110
+ "attention_mask": enc["attention_mask"].astype(np.int64),
111
+ })[0][0]
112
+ probs = np.exp(logits - logits.max()) / np.exp(logits - logits.max()).sum()
113
+ print({"FAITHFUL": float(probs[0]), "CONTRADICTION": float(probs[1]), "UNSUPPORTED": float(probs[2])})
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Zero-Leakage Benchmark Evaluation
119
+
120
+ All models below were evaluated identically at `threshold = 0.50` (`hallucination_score = 1 - P(FAITHFUL)`). Training data was strictly filtered via exact pair hash + 10-word response shingle matching against all evaluation splits (blocking **3,646** overlapping items).
121
+
122
+ | Model | Max Ctx | Output | RAGTruth F1↑ (AUROC) | HaluEval F1↑ | DocNLI F1↑ | LongRAG-8K F1↑ (FPR↓) | Avg 4-Bench F1↑ |
123
+ |---|---:|:---:|---:|---:|---:|---:|---:|
124
+ | **Flintglass PrismVerify-Large (395M)** | 8,192 | 3-class | 0.741 (0.878) | 0.906 | 0.676 | 0.896 (9.2%) | **0.805** |
125
+ | **Flintglass PrismVerify-Multilingual (307M)** | 8,192 | 3-class | 0.729 (0.866) | 0.906 | 0.549 | 0.857 (12.8%) | **0.760** |
126
+ | **Flintglass PrismVerify-Small (140M)** | 8,192 | 3-class | 0.722 (0.866) | 0.911 | 0.541 | 0.860 (10.0%) | **0.759** |
127
+ | KRLabsOrg/lettucedect-large-modernbert | 8,192 | Token | 0.776 (0.901) | 0.633 | 0.579 | 0.798 (7.8%) | **0.697** |
128
+ | KRLabsOrg/lettucedect-base-modernbert | 8,192 | Token | 0.718 (0.857) | 0.647 | 0.603 | 0.756 (15.6%) | **0.681** |
129
+ | vectara/HHEM-2.1-Open | 512* | Binary | 0.613 (0.826) | 0.628 | 0.492 | OOM (>178 GB) | — |
130
+ | MoritzLaurer/DeBERTa-v3-large-NLI | 512 | NLI | 0.213 (0.679) | 0.673 | 0.681 | 0.641 (55.0%) | **0.552** |
131
+
132
+ *Note: `vectara/HHEM-2.1-Open` uses custom untrimmed T5 attention and ran out of memory (>178 GB VRAM on NVIDIA B200) on 4K–6.5K token multi-chunk RAG contexts in `LongRAG-8K`.*
133
+
134
+ ### Long-Context Multi-Chunk RAG Breakdown (`LongRAG-Verify-Bench`, 512 → 6,500 tokens)
135
+
136
+ | Model | 512 tok F1 (FPR↓) | 1K tok F1 (FPR↓) | 2K tok F1 (FPR↓) | 4K tok F1 (FPR↓) | 6.5K tok F1 (FPR↓) |
137
+ |---|---:|---:|---:|---:|---:|
138
+ | **PrismVerify-Large (395M)** | 0.915 (9%) | 0.860 (10%) | 0.901 (11%) | 0.893 (9%) | 0.908 (7%) |
139
+ | **PrismVerify-Multilingual (307M)** | 0.861 (15%) | 0.856 (11%) | 0.859 (17%) | 0.844 (11%) | 0.866 (10%) |
140
+ | **PrismVerify-Small (140M)** | 0.845 (12%) | 0.856 (11%) | 0.883 (10%) | 0.836 (10%) | 0.880 (7%) |
141
+ | lettucedect-large | 0.804 (7%) | 0.822 (6%) | 0.822 (6%) | 0.780 (11%) | 0.761 (9%) |
142
+ | lettucedect-base | 0.769 (28%) | 0.804 (10%) | 0.782 (6%) | 0.725 (16%) | 0.696 (18%) |
143
+ | DeBERTa-v3-large-NLI | 0.670 (17%) | 0.638 (45%) | 0.650 (62%) | 0.648 (73%) | 0.609 (78%) |
144
+
145
+ ---
146
+
147
+ ## CPU ONNX Latency & Parity
148
+
149
+ | Sequence Length | ONNX FP32 (563.08 MB) | ONNX INT8 (436.44 MB) |
150
+ |---|---:|---:|
151
+ | 64 tokens | 23.6 ms | 15.97 ms |
152
+ | 256 tokens | 63.23 ms | 28.9 ms |
153
+ | 1,024 tokens | 318.15 ms | 213.39 ms |
154
+
155
+ - FP32 ONNX vs PyTorch max logit delta: `1e-05`
156
+
157
+ ## Limitations
158
+
159
+ - Encoder-based verifiers excel at lexical, factual, entity, negation, temporal, and span-groundedness verification, but do not perform multi-step arithmetic derivations (for numerical/mathematical RAG calculations, pair with a reasoning verifier LLM or code interpreter).
160
+ - Always place the claim/response first (`[CLAIM] ... [CONTEXT] ...`) when formatting inputs so long contexts never truncate the claim.
161
+
162
+ ## Citation
163
+
164
+ ```bibtex
165
+ @misc{flintglass2026prismverify,
166
+ title={PrismVerify: 8K-Context Open-Source RAG Hallucination and Groundedness Verification},
167
+ author={Flintglass Labs},
168
+ year={2026},
169
+ url={https://huggingface.co/flintglass/PrismVerify-Small}
170
+ }
171
+ ```
config.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ModernBertForSequenceClassification"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 2,
8
+ "calibration_baked_into_head": true,
9
+ "calibration_temperature": 1.0,
10
+ "calibration_temperature_fitted": 1.04609,
11
+ "classifier_activation": "gelu",
12
+ "classifier_bias": false,
13
+ "classifier_dropout": 0.1,
14
+ "classifier_pooling": "mean",
15
+ "cls_token_id": 1,
16
+ "decoder_bias": true,
17
+ "deterministic_flash_attn": false,
18
+ "dtype": "bfloat16",
19
+ "embedding_dropout": 0.0,
20
+ "eos_token_id": 1,
21
+ "global_attn_every_n_layers": 3,
22
+ "gradient_checkpointing": false,
23
+ "hidden_activation": "gelu",
24
+ "hidden_size": 384,
25
+ "id2label": {
26
+ "0": "FAITHFUL",
27
+ "1": "CONTRADICTION",
28
+ "2": "UNSUPPORTED"
29
+ },
30
+ "initializer_cutoff_factor": 2.0,
31
+ "initializer_range": 0.02,
32
+ "intermediate_size": 1152,
33
+ "label2id": {
34
+ "CONTRADICTION": 1,
35
+ "FAITHFUL": 0,
36
+ "UNSUPPORTED": 2
37
+ },
38
+ "layer_norm_eps": 1e-05,
39
+ "layer_types": [
40
+ "full_attention",
41
+ "sliding_attention",
42
+ "sliding_attention",
43
+ "full_attention",
44
+ "sliding_attention",
45
+ "sliding_attention",
46
+ "full_attention",
47
+ "sliding_attention",
48
+ "sliding_attention",
49
+ "full_attention",
50
+ "sliding_attention",
51
+ "sliding_attention",
52
+ "full_attention",
53
+ "sliding_attention",
54
+ "sliding_attention",
55
+ "full_attention",
56
+ "sliding_attention",
57
+ "sliding_attention",
58
+ "full_attention",
59
+ "sliding_attention",
60
+ "sliding_attention",
61
+ "full_attention"
62
+ ],
63
+ "local_attention": 128,
64
+ "mask_token_id": 4,
65
+ "max_position_embeddings": 8192,
66
+ "mlp_bias": false,
67
+ "mlp_dropout": 0.0,
68
+ "model_type": "modernbert",
69
+ "norm_bias": false,
70
+ "norm_eps": 1e-05,
71
+ "num_attention_heads": 6,
72
+ "num_hidden_layers": 22,
73
+ "pad_token_id": 0,
74
+ "position_embedding_type": "sans_pos",
75
+ "rope_parameters": {
76
+ "full_attention": {
77
+ "rope_theta": 160000,
78
+ "rope_type": "default"
79
+ },
80
+ "sliding_attention": {
81
+ "rope_theta": 160000,
82
+ "rope_type": "default"
83
+ }
84
+ },
85
+ "sep_token_id": 1,
86
+ "sparse_pred_ignore_index": -100,
87
+ "sparse_prediction": false,
88
+ "tie_word_embeddings": true,
89
+ "transformers_version": "5.17.0",
90
+ "vocab_size": 256000
91
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d0ceaabdc4dfbaba1936f65cdd519d9b2f9cb39ea218c131f923246fe7342ef
3
+ size 281299686
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1562dfca1a7deaa8e3055e9c25c93a54936c0721e16601e8b2d7fdd9a973f59
3
+ size 563083642
onnx/model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4efa4d6270ffa79b924b16586be50b156509df4b0fb7b8a2e9a5ecfd0b83200a
3
+ size 436436744
onnx/onnx_report.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fp32_size_mb": 563.08,
3
+ "int8_size_mb": 436.44,
4
+ "fp32_max_abs_diff": 1e-05,
5
+ "int8_max_abs_diff": 1.2807,
6
+ "int8_top1_agreement": 1.0,
7
+ "cpu_latency": {
8
+ "seq_64": {
9
+ "fp32_cpu_ms": 23.6,
10
+ "int8_cpu_ms": 15.97
11
+ },
12
+ "seq_256": {
13
+ "fp32_cpu_ms": 63.23,
14
+ "int8_cpu_ms": 28.9
15
+ },
16
+ "seq_1024": {
17
+ "fp32_cpu_ms": 318.15,
18
+ "int8_cpu_ms": 213.39
19
+ }
20
+ }
21
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a086e6a7efb90bbab8e379a63f3463fb13e6256ebec3343c1f1612cab693935b
3
+ size 34363287
tokenizer_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<bos>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "cls_token": "<bos>",
6
+ "eos_token": "<eos>",
7
+ "extra_special_tokens": [
8
+ "<start_of_turn>",
9
+ "<end_of_turn>"
10
+ ],
11
+ "is_local": false,
12
+ "local_files_only": false,
13
+ "mask_token": "<mask>",
14
+ "model_input_names": [
15
+ "input_ids",
16
+ "attention_mask"
17
+ ],
18
+ "model_max_length": 8192,
19
+ "pad_token": "<pad>",
20
+ "padding_side": "right",
21
+ "sep_token": "<eos>",
22
+ "spaces_between_special_tokens": false,
23
+ "tokenizer_class": "TokenizersBackend",
24
+ "unk_token": "<unk>"
25
+ }
training_summary.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model": "jhu-clsp/mmBERT-small",
3
+ "args": {
4
+ "base_model": "jhu-clsp/mmBERT-small",
5
+ "corpus_dir": "/outputs/8a14cc74-b2bc-427c-a58e-c74393fffafb/data/corpus_hf",
6
+ "out_dir": "/outputs/b21243d4-e1cf-424d-b106-7614094cb2f1/PrismVerify-Small",
7
+ "max_length": 8192,
8
+ "epochs": 5,
9
+ "lr": 6e-05,
10
+ "max_tokens": 20480,
11
+ "grad_accum": 2,
12
+ "label_smoothing": 0.02,
13
+ "seed": 42,
14
+ "grad_checkpointing": false
15
+ },
16
+ "history": [
17
+ {
18
+ "epoch": 1,
19
+ "train_loss": 1.8348,
20
+ "val": {
21
+ "fine_macro_f1": 0.5672,
22
+ "binary_f1": 0.7613,
23
+ "binary_bacc": 0.7133,
24
+ "binary_auroc": 0.8477,
25
+ "nll": 0.6133
26
+ },
27
+ "score": 0.6476
28
+ },
29
+ {
30
+ "epoch": 2,
31
+ "train_loss": 1.1187,
32
+ "val": {
33
+ "fine_macro_f1": 0.7681,
34
+ "binary_f1": 0.8452,
35
+ "binary_bacc": 0.849,
36
+ "binary_auroc": 0.9194,
37
+ "nll": 0.4248
38
+ },
39
+ "score": 0.8126
40
+ },
41
+ {
42
+ "epoch": 3,
43
+ "train_loss": 0.8123,
44
+ "val": {
45
+ "fine_macro_f1": 0.7874,
46
+ "binary_f1": 0.859,
47
+ "binary_bacc": 0.861,
48
+ "binary_auroc": 0.9355,
49
+ "nll": 0.3792
50
+ },
51
+ "score": 0.8279
52
+ },
53
+ {
54
+ "epoch": 4,
55
+ "train_loss": 0.6243,
56
+ "val": {
57
+ "fine_macro_f1": 0.7902,
58
+ "binary_f1": 0.8642,
59
+ "binary_bacc": 0.8656,
60
+ "binary_auroc": 0.937,
61
+ "nll": 0.3751
62
+ },
63
+ "score": 0.8317
64
+ },
65
+ {
66
+ "epoch": 5,
67
+ "train_loss": 0.5692,
68
+ "val": {
69
+ "fine_macro_f1": 0.7895,
70
+ "binary_f1": 0.8628,
71
+ "binary_bacc": 0.8643,
72
+ "binary_auroc": 0.9372,
73
+ "nll": 0.3758
74
+ },
75
+ "score": 0.8306
76
+ }
77
+ ],
78
+ "best_score": 0.8317,
79
+ "calibration_T": 1.04609,
80
+ "calibration_baked": true,
81
+ "cal_before": {
82
+ "fine_macro_f1": 0.7665,
83
+ "binary_f1": 0.8594,
84
+ "binary_bacc": 0.8597,
85
+ "binary_auroc": 0.9416,
86
+ "nll": 0.3681
87
+ },
88
+ "cal_after": {
89
+ "fine_macro_f1": 0.7665,
90
+ "binary_f1": 0.8581,
91
+ "binary_bacc": 0.858,
92
+ "binary_auroc": 0.9417,
93
+ "nll": 0.3677
94
+ }
95
+ }