Text Classification
Transformers
ONNX
Safetensors
modernbert
hallucination-detection
groundedness
faithfulness
rag
rag-evaluation
fact-checking
nli
flintglass
text-embeddings-inference
Instructions to use flintglass/PrismVerify-Small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use flintglass/PrismVerify-Small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="flintglass/PrismVerify-Small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("flintglass/PrismVerify-Small") model = AutoModelForSequenceClassification.from_pretrained("flintglass/PrismVerify-Small", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Release Flintglass PrismVerify-Small v1 (mmBERT-small 140M, 1800+ langs, 8K ctx, 16ms CPU ONNX INT8)
Browse filesFiles changed (10)
- .gitattributes+1
- README.mdAdded+171
- config.jsonAdded+91
- model.safetensorsAdded+3
- onnx/model.onnxAdded+3
- onnx/model_int8.onnxAdded+3
- onnx/onnx_report.jsonAdded+21
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+25
- training_summary.jsonAdded+95
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171---license: apache-2.0language: - multilingual - en - es - fr - de - zh - ja - ko - ar - ru - pt - hibase_model: jhu-clsp/mmBERT-smalldatasets: - flintglass/PrismVerify-Corpuslibrary_name: transformerspipeline_tag: text-classificationtags: - hallucination-detection - groundedness - faithfulness - rag - rag-evaluation - fact-checking - nli - modernbert - onnx - flintglass---
# PrismVerify-Small
**8,192-Token RAG Hallucination & Groundedness Verifier · 3-Class (`FAITHFUL` / `CONTRADICTION` / `UNSUPPORTED`) · Apache 2.0 · PyTorch + ONNX INT8**
> 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.
- **Interactive Demo:** [flintglass/PrismVerify-Demo](https://huggingface.co/spaces/flintglass/PrismVerify-Demo)- **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)- **Training Dataset & Benchmark:** [`flintglass/PrismVerify-Corpus`](https://huggingface.co/datasets/flintglass/PrismVerify-Corpus) (Apache 2.0)
---
## Why PrismVerify?
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.
**`PrismVerify-Small`** brings precision optical clarity to groundedness verification:
| Property | Specification ||---|---|| **Backbone** | `jhu-clsp/mmBERT-small` (140M parameters) || **Native Context Window** | **8,192 tokens** (claim placed first so `[CLAIM]` is never truncated!) || **Languages** | Multilingual (1,800+ languages via mmBERT) || **Classes (`id2label`)** | `0: FAITHFUL`, `1: CONTRADICTION`, `2: UNSUPPORTED` || **Calibration** | Post-hoc temperature scaling (`T = 1.0461`) baked directly into the linear head || **Formats Included** | Safetensors (`model.safetensors`), ONNX FP32 (`onnx/model.onnx`, 563.08 MB), ONNX INT8 (`onnx/model_int8.onnx`, 436.44 MB) || **License** | **Apache 2.0** (ungated, commercial-friendly) |
---
## Quickstart
### 1. Drop-in PyTorch / `transformers`
```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForSequenceClassification
model_id = "flintglass/PrismVerify-Small"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForSequenceClassification.from_pretrained(model_id).eval()
context = "In Q3 2026, Meridian Robotics reported revenue of $142.8M, up 18.4% YoY, with gross margin of 59.8%."claim = "Meridian Robotics grew Q3 revenue by 18.4% to $142.8M and expanded gross margin to 65%."text = f"[CLAIM]\n{claim}\n\n[CONTEXT]\n{context}"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=8192)with torch.no_grad(): probs = torch.softmax(model(**inputs).logits, dim=-1)[0]
print({ "faithful": probs[0].item(), "contradiction": probs[1].item(), "unsupported": probs[2].item(), "hallucination_score": 1.0 - probs[0].item(), "is_hallucinated": (1.0 - probs[0].item()) >= 0.5,})```
### 2. Ultra-Fast CPU Inference with ONNX Runtime (INT8)
```pythonimport numpy as npimport onnxruntime as ortfrom huggingface_hub import hf_hub_downloadfrom transformers import AutoTokenizer
model_id = "flintglass/PrismVerify-Small"tokenizer = AutoTokenizer.from_pretrained(model_id)onnx_path = hf_hub_download(repo_id=model_id, filename="onnx/model_int8.onnx")session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
text = "[CLAIM]\nThe solar plant includes 20 MWh battery storage.\n\n[CONTEXT]\nThe 50 MW solar plant does not yet include battery storage."enc = tokenizer(text, return_tensors="np", truncation=True, max_length=8192)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()) / np.exp(logits - logits.max()).sum()print({"FAITHFUL": float(probs[0]), "CONTRADICTION": float(probs[1]), "UNSUPPORTED": float(probs[2])})```
---
## Zero-Leakage Benchmark Evaluation
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).
| Model | Max Ctx | Output | RAGTruth F1↑ (AUROC) | HaluEval F1↑ | DocNLI F1↑ | LongRAG-8K F1↑ (FPR↓) | Avg 4-Bench F1↑ ||---|---:|:---:|---:|---:|---:|---:|---:|| **Flintglass PrismVerify-Large (395M)** | 8,192 | 3-class | 0.741 (0.878) | 0.906 | 0.676 | 0.896 (9.2%) | **0.805** || **Flintglass PrismVerify-Multilingual (307M)** | 8,192 | 3-class | 0.729 (0.866) | 0.906 | 0.549 | 0.857 (12.8%) | **0.760** || **Flintglass PrismVerify-Small (140M)** | 8,192 | 3-class | 0.722 (0.866) | 0.911 | 0.541 | 0.860 (10.0%) | **0.759** || KRLabsOrg/lettucedect-large-modernbert | 8,192 | Token | 0.776 (0.901) | 0.633 | 0.579 | 0.798 (7.8%) | **0.697** || KRLabsOrg/lettucedect-base-modernbert | 8,192 | Token | 0.718 (0.857) | 0.647 | 0.603 | 0.756 (15.6%) | **0.681** || vectara/HHEM-2.1-Open | 512* | Binary | 0.613 (0.826) | 0.628 | 0.492 | OOM (>178 GB) | — || MoritzLaurer/DeBERTa-v3-large-NLI | 512 | NLI | 0.213 (0.679) | 0.673 | 0.681 | 0.641 (55.0%) | **0.552** |
*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`.*
### Long-Context Multi-Chunk RAG Breakdown (`LongRAG-Verify-Bench`, 512 → 6,500 tokens)
| Model | 512 tok F1 (FPR↓) | 1K tok F1 (FPR↓) | 2K tok F1 (FPR↓) | 4K tok F1 (FPR↓) | 6.5K tok F1 (FPR↓) ||---|---:|---:|---:|---:|---:|| **PrismVerify-Large (395M)** | 0.915 (9%) | 0.860 (10%) | 0.901 (11%) | 0.893 (9%) | 0.908 (7%) || **PrismVerify-Multilingual (307M)** | 0.861 (15%) | 0.856 (11%) | 0.859 (17%) | 0.844 (11%) | 0.866 (10%) || **PrismVerify-Small (140M)** | 0.845 (12%) | 0.856 (11%) | 0.883 (10%) | 0.836 (10%) | 0.880 (7%) || lettucedect-large | 0.804 (7%) | 0.822 (6%) | 0.822 (6%) | 0.780 (11%) | 0.761 (9%) || lettucedect-base | 0.769 (28%) | 0.804 (10%) | 0.782 (6%) | 0.725 (16%) | 0.696 (18%) || DeBERTa-v3-large-NLI | 0.670 (17%) | 0.638 (45%) | 0.650 (62%) | 0.648 (73%) | 0.609 (78%) |
---
## CPU ONNX Latency & Parity
| Sequence Length | ONNX FP32 (563.08 MB) | ONNX INT8 (436.44 MB) ||---|---:|---:|| 64 tokens | 23.6 ms | 15.97 ms || 256 tokens | 63.23 ms | 28.9 ms || 1,024 tokens | 318.15 ms | 213.39 ms |
- FP32 ONNX vs PyTorch max logit delta: `1e-05`
## Limitations
- 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).- Always place the claim/response first (`[CLAIM] ... [CONTEXT] ...`) when formatting inputs so long contexts never truncate the claim.
## Citation
```bibtex@misc{flintglass2026prismverify, title={PrismVerify: 8K-Context Open-Source RAG Hallucination and Groundedness Verification}, author={Flintglass Labs}, year={2026}, url={https://huggingface.co/flintglass/PrismVerify-Small}}```12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091{ "architectures": [ "ModernBertForSequenceClassification" ], "attention_bias": false, "attention_dropout": 0.0, "bos_token_id": 2, "calibration_baked_into_head": true, "calibration_temperature": 1.0, "calibration_temperature_fitted": 1.04609, "classifier_activation": "gelu", "classifier_bias": false, "classifier_dropout": 0.1, "classifier_pooling": "mean", "cls_token_id": 1, "decoder_bias": true, "deterministic_flash_attn": false, "dtype": "bfloat16", "embedding_dropout": 0.0, "eos_token_id": 1, "global_attn_every_n_layers": 3, "gradient_checkpointing": false, "hidden_activation": "gelu", "hidden_size": 384, "id2label": { "0": "FAITHFUL", "1": "CONTRADICTION", "2": "UNSUPPORTED" }, "initializer_cutoff_factor": 2.0, "initializer_range": 0.02, "intermediate_size": 1152, "label2id": { "CONTRADICTION": 1, "FAITHFUL": 0, "UNSUPPORTED": 2 }, "layer_norm_eps": 1e-05, "layer_types": [ "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "full_attention" ], "local_attention": 128, "mask_token_id": 4, "max_position_embeddings": 8192, "mlp_bias": false, "mlp_dropout": 0.0, "model_type": "modernbert", "norm_bias": false, "norm_eps": 1e-05, "num_attention_heads": 6, "num_hidden_layers": 22, "pad_token_id": 0, "position_embedding_type": "sans_pos", "rope_parameters": { "full_attention": { "rope_theta": 160000, "rope_type": "default" }, "sliding_attention": { "rope_theta": 160000, "rope_type": "default" } }, "sep_token_id": 1, "sparse_pred_ignore_index": -100, "sparse_prediction": false, "tie_word_embeddings": true, "transformers_version": "5.17.0", "vocab_size": 256000}123version https://git-lfs.github.com/spec/v1oid sha256:2d0ceaabdc4dfbaba1936f65cdd519d9b2f9cb39ea218c131f923246fe7342efsize 281299686123version https://git-lfs.github.com/spec/v1oid sha256:a1562dfca1a7deaa8e3055e9c25c93a54936c0721e16601e8b2d7fdd9a973f59size 563083642123version https://git-lfs.github.com/spec/v1oid sha256:4efa4d6270ffa79b924b16586be50b156509df4b0fb7b8a2e9a5ecfd0b83200asize 436436744123456789101112131415161718192021{ "fp32_size_mb": 563.08, "int8_size_mb": 436.44, "fp32_max_abs_diff": 1e-05, "int8_max_abs_diff": 1.2807, "int8_top1_agreement": 1.0, "cpu_latency": { "seq_64": { "fp32_cpu_ms": 23.6, "int8_cpu_ms": 15.97 }, "seq_256": { "fp32_cpu_ms": 63.23, "int8_cpu_ms": 28.9 }, "seq_1024": { "fp32_cpu_ms": 318.15, "int8_cpu_ms": 213.39 } }}123version https://git-lfs.github.com/spec/v1oid sha256:a086e6a7efb90bbab8e379a63f3463fb13e6256ebec3343c1f1612cab693935bsize 3436328712345678910111213141516171819202122232425{ "backend": "tokenizers", "bos_token": "<bos>", "clean_up_tokenization_spaces": false, "cls_token": "<bos>", "eos_token": "<eos>", "extra_special_tokens": [ "<start_of_turn>", "<end_of_turn>" ], "is_local": false, "local_files_only": false, "mask_token": "<mask>", "model_input_names": [ "input_ids", "attention_mask" ], "model_max_length": 8192, "pad_token": "<pad>", "padding_side": "right", "sep_token": "<eos>", "spaces_between_special_tokens": false, "tokenizer_class": "TokenizersBackend", "unk_token": "<unk>"}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495{ "base_model": "jhu-clsp/mmBERT-small", "args": { "base_model": "jhu-clsp/mmBERT-small", "corpus_dir": "/outputs/8a14cc74-b2bc-427c-a58e-c74393fffafb/data/corpus_hf", "out_dir": "/outputs/b21243d4-e1cf-424d-b106-7614094cb2f1/PrismVerify-Small", "max_length": 8192, "epochs": 5, "lr": 6e-05, "max_tokens": 20480, "grad_accum": 2, "label_smoothing": 0.02, "seed": 42, "grad_checkpointing": false }, "history": [ { "epoch": 1, "train_loss": 1.8348, "val": { "fine_macro_f1": 0.5672, "binary_f1": 0.7613, "binary_bacc": 0.7133, "binary_auroc": 0.8477, "nll": 0.6133 }, "score": 0.6476 }, { "epoch": 2, "train_loss": 1.1187, "val": { "fine_macro_f1": 0.7681, "binary_f1": 0.8452, "binary_bacc": 0.849, "binary_auroc": 0.9194, "nll": 0.4248 }, "score": 0.8126 }, { "epoch": 3, "train_loss": 0.8123, "val": { "fine_macro_f1": 0.7874, "binary_f1": 0.859, "binary_bacc": 0.861, "binary_auroc": 0.9355, "nll": 0.3792 }, "score": 0.8279 }, { "epoch": 4, "train_loss": 0.6243, "val": { "fine_macro_f1": 0.7902, "binary_f1": 0.8642, "binary_bacc": 0.8656, "binary_auroc": 0.937, "nll": 0.3751 }, "score": 0.8317 }, { "epoch": 5, "train_loss": 0.5692, "val": { "fine_macro_f1": 0.7895, "binary_f1": 0.8628, "binary_bacc": 0.8643, "binary_auroc": 0.9372, "nll": 0.3758 }, "score": 0.8306 } ], "best_score": 0.8317, "calibration_T": 1.04609, "calibration_baked": true, "cal_before": { "fine_macro_f1": 0.7665, "binary_f1": 0.8594, "binary_bacc": 0.8597, "binary_auroc": 0.9416, "nll": 0.3681 }, "cal_after": { "fine_macro_f1": 0.7665, "binary_f1": 0.8581, "binary_bacc": 0.858, "binary_auroc": 0.9417, "nll": 0.3677 }}.gitattributes+1
README.mdAdded+171
config.jsonAdded+91
model.safetensorsAdded+3
onnx/model.onnxAdded+3
onnx/model_int8.onnxAdded+3
onnx/onnx_report.jsonAdded+21
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+25
training_summary.jsonAdded+95