Domain-Specific Hallucination Detection in Large Language Models
Paper • 2609.11878 • Published
How to use varunchundru/hallucination-detector-deberta with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="varunchundru/hallucination-detector-deberta") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("varunchundru/hallucination-detector-deberta")
model = AutoModelForSequenceClassification.from_pretrained("varunchundru/hallucination-detector-deberta", device_map="auto")Paper: Domain-Specific Hallucination Detection in Large Language Models
Code: GitHub Repository
A fine-tuned DeBERTa-v3-base model for detecting hallucinations in LLM-generated text.
This model classifies whether an LLM-generated response is factual or hallucinated given a knowledge context. It was fine-tuned on the HaluEval benchmark.
| Metric | Score |
|---|---|
| Accuracy | 0.9127 |
| Precision | 0.8819 |
| Recall | 0.9505 |
| F1 Score | 0.9149 |
| AUROC | 0.9771 |
| Task | F1 Score |
|---|---|
| QA | 0.97 |
| Summarization | 0.96 |
| Dialogue | 0.82 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model
tokenizer = AutoTokenizer.from_pretrained("varunteja99/hallucination-detector-deberta")
model = AutoModelForSequenceClassification.from_pretrained("varunteja99/hallucination-detector-deberta")
# Prepare input
text = """Knowledge: The Eiffel Tower is located in Paris, France.
Question: Where is the Eiffel Tower?
Answer: The Eiffel Tower is in London."""
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
# Predict
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=-1).item()
print("Hallucinated" if prediction == 1 else "Factual")
# Output: Hallucinated
The model expects input in the following format:
Knowledge: [relevant context/facts]
Question: [the query or prompt]
Answer: [the LLM-generated response to verify]
| ID | Label | Description |
|---|---|---|
| 0 | Factual | Response is supported by knowledge |
| 1 | Hallucinated | Response contradicts or is unsupported |
@misc{chundru2026hallucination,
author = {Chundru, Varun and Biswas, Debasmita},
title = {Domain-Specific Hallucination Detection in Large Language Models},
year = {2026},
publisher = {GitHub},
url = {https://github.com/varunteja99/hallucination-detection-nlp}
}