"AGI" team at SHROOM-CAP: Data-Centric Approach to Multilingual Hallucination Detection using XLM-RoBERTa
Paper
•
2511.18301
•
Published
The model is an XLM-RoBERTa-Large based fine-tuned model for scientific hallucination detection across 9 languages using the Huggingface transformers library.
xlm-roberta-largeThe model can be directly used for detecting hallucinations in scientific text across 9 languages:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "Haxxsh/XLMRHallucinationDetectorSHROOMCAP"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
def detect_hallucination(text):
"""Detect if text contains scientific hallucinations."""
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
label = "HALLUCINATED" if predictions[0][1] > 0.5 else "CORRECT"
confidence = predictions[0][1].item() if label == "HALLUCINATED" else predictions[0][0].item()
return {"label": label, "confidence": confidence}
# Example usage
test_texts = [
"The protein folding mechanism involves quantum tunneling effects at room temperature.",
"Water boils at 100°C at standard atmospheric pressure.",
"Einstein discovered the theory of relativity in 1905 with his paper on special relativity."
]
for text in test_texts:
result = detect_hallucination(text)
print(f"Text: {text}")
print(f"Prediction: {result['label']} (confidence: {result['confidence']:.4f})\n")
0: CORRECT (factually accurate scientific text)1: HALLUCINATED (contains factual errors or fabrications)Can be integrated into:
{
"per_device_train_batch_size": 16,
"gradient_accumulation_steps": 2,
"learning_rate": 2e-5,
"num_train_epochs": 3,
"max_seq_length": 256,
"warmup_ratio": 0.1,
"weight_decay": 0.01
}
| Language | Rank | Factuality F1 | Fluency F1 |
|---|---|---|---|
| Gujarati (gu) | 🥈 2nd | 0.5107 | 0.1579 |
| Bengali (bn) | 4th | 0.4449 | 0.2542 |
| Hindi (hi) | 4th | 0.4906 | 0.4353 |
| Spanish (es) | 5th | 0.4938 | 0.4607 |
| French (fr) | 5th | 0.4771 | 0.2899 |
| Telugu (te) | 5th | 0.4738 | 0.1474 |
| Malayalam (ml) | 5th | 0.4704 | 0.3593 |
| English (en) | 6th | 0.4246 | 0.4495 |
| Italian (it) | 5th | 0.3149 | 0.4582 |
Base model
FacebookAI/xlm-roberta-large