Downloads · 30 days
10
12% of all-time downloads
hugoomezz/modernbert-ragtruth-response-level
modernbert-ragtruth-response-level is a text classification model from hugoomezz. Use it when you need a label for a piece of text. The card lists the license as mit.
Fine-tuned answerdotai/ModernBERT-base, binary sequence classifier for response-level RAG hallucination detection: given a (context, response) pair, predicts whether the response contains any hallucinated content rela…
Downloads · 30 days
10
12% of all-time downloads
All-time downloads
83
Public
Parameters
150M
598 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors598 MB · 99%
From the Hugging Face model README
Fine-tuned answerdotai/ModernBERT-base, binary sequence classifier for
response-level RAG hallucination detection: given a (context, response) pair,
predicts whether the response contains any hallucinated content relative to the
context. Label 0 = faithful, label 1 = hallucinated. Same task as Track A
(hugoomezz/deberta-v3-ragtruth-hallucination), on a truncation-free backbone.
This is not the best-performing system in this project — see
hugoomezz/modernbert-ragtruth-token-level-binary
(Track B), which supersedes it and is the model deployed in the live demo.
Research / portfolio demonstration of RAG hallucination detection on RAGTruth, and a long-context (ModernBERT, 4096 tokens) comparison point against Track A's DeBERTa-v3-base (512 tokens). Not validated outside RAGTruth's three task types (QA, Summary, Data2txt), and not intended for production moderation decisions without further evaluation.
RAGTruth (Niu et al., 2024, ACL,
arXiv:2401.00396) — MIT-licensed, reproduced in
this project's docs/THIRD_PARTY_LICENSES.md.
13,578 train / 1,512 val / 2,700 test response-level rows, class-weighted cross-entropy.
Tokenized at max_length=4096, which eliminates truncation entirely on RAGTruth (0.00%
of rows truncated, vs. 70.34% at DeBERTa-v3's 512-token limit).
results/finetuned_approach1_modernbert_metrics.json)| Metric | Value |
|---|---|
| Precision | 0.6839 |
| Recall | 0.7731 |
| F1 | 0.7257 |
| Accuracy | 0.7959 |
Per task_type:
| Task | F1 | Recall |
|---|---|---|
| Data2txt | 0.8506 | 0.8705 |
| QA | 0.5924 | 0.6813 |
| Summary | 0.5088 | 0.5686 |
Note: this project's unified cross-system comparison table (README.md) reports F1
0.7254 for this model, a ~0.0004 discrepancy from the 0.7257 above traced to exactly
one borderline test example flipping prediction between the original Kaggle training
run and a later re-inference pass — consistent with ordinary GPU inference
nondeterminism (batch composition / kernel selection), not a data or pipeline bug (see
docs/notes.md).
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
MODEL_ID = "hugoomezz/modernbert-ragtruth-response-level"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID).eval()
context = "The Eiffel Tower was completed in 1889 for the World's Fair in Paris."
response = "The Eiffel Tower was completed in 1889 and stands in Paris, France."
inputs = tokenizer(context, response, truncation="only_first", max_length=4096, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0]
print({"faithful": probs[0].item(), "hallucinated": probs[1].item()})
@inproceedings{niu2024ragtruth,
title = {RAGTruth: A Hallucination Corpus for Developing and Evaluating RAG Systems},
author = {Niu, Cheng and Wu, Yuanhao and Zhu, Juno and Xu, Siliang and Shum, Kashun and Zhong, Randy and Song, Juntong and Zhang, Tong},
booktitle = {Proceedings of ACL 2024},
year = {2024},
eprint = {2401.00396}
}