Downloads · 30 days
10
13% of all-time downloads
hugoomezz/deberta-v3-ragtruth-hallucination
deberta-v3-ragtruth-hallucination 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 microsoft/deberta-v3-base, binary sequence classifier for response-level RAG hallucination detection: given a (context, response) pair, predicts whether the response contains any hallucinated content relati…
Downloads · 30 days
10
13% of all-time downloads
All-time downloads
80
Public
Parameters
184M
740 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors738 MB · 99%
From the Hugging Face model README
Fine-tuned microsoft/deberta-v3-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.
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. Track A is
kept published for the project's 4-system comparison.
Research / portfolio demonstration of RAG hallucination detection on RAGTruth. Given a retrieved context and a generated response, scores whether the response is faithful to that context. Not validated on any domain outside RAGTruth's three task types (QA, Summary, Data2txt), and not intended for production moderation decisions without further evaluation on your own data.
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,511 val / 2,700 test response-level rows (~55/45 faithful/hallucinated split in train), class-weighted cross-entropy to counter the imbalance. Context-only truncation at 512 tokens (ADR-004): the response is always fully preserved, only the context's head is truncated when the combined length exceeds the budget (this affects 70.34% of rows at DeBERTa-v3's 512-token limit).
results/finetuned_track_a_metrics.json)| Metric | Value |
|---|---|
| Precision | 0.7367 |
| Recall | 0.6882 |
| F1 | 0.7116 |
| Accuracy | 0.8052 |
Per task_type:
| Task | F1 | Recall |
|---|---|---|
| Data2txt | 0.8476 | 0.8549 |
| QA | 0.5859 | 0.6500 |
| Summary | 0.3322 | 0.2451 |
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
MODEL_ID = "hugoomezz/deberta-v3-ragtruth-hallucination"
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=512, 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}
}