🚀 LettuceDetect: Hallucination Detection Model
LettuceDetect is a transformer-based model designed for hallucination detection in Retrieval-Augmented Generation (RAG) applications, leveraging the extended context support of ModernBERT.
Model Name: lettucedect-base-modernbert-en-v1
Organization: KRLabsOrg
Github: https://github.com/KRLabsOrg/LettuceDetect
🚀 Quick Start
LettuceDetect is a powerful tool for hallucination detection. It can effectively process context and answer pairs to determine if an answer is supported by the context.
✨ Features
- Transformer-based: Built on the ModernBERT architecture, which supports an extended context of up to 8192 tokens.
- Accurate Detection: Trained to identify tokens in the answer text that are not supported by the context, providing token - level predictions.
- High Performance: Achieves excellent results in both example - level and span - level evaluations, outperforming many existing models.
📦 Installation
Install the 'lettucedetect' repository:
pip install lettucedetect
💻 Usage Examples
Basic Usage
from lettucedetect.models.inference import HallucinationDetector
detector = HallucinationDetector(
method="transformer", model_path="KRLabsOrg/lettucedect-base-modernbert-en-v1"
)
contexts = ["France is a country in Europe. The capital of France is Paris. The population of France is 67 million.",]
question = "What is the capital of France? What is the population of France?"
answer = "The capital of France is Paris. The population of France is 69 million."
predictions = detector.predict(context=contexts, question=question, answer=answer, output_format="spans")
print("Predictions:", predictions)
📚 Documentation
Overview
LettuceDetect is a transformer - based model for hallucination detection on context and answer pairs, designed for Retrieval - Augmented Generation (RAG) applications. This model is built on ModernBERT, which has been specifically chosen and trained because of its extended context support (up to 8192 tokens). This long - context capability is critical for tasks where detailed and extensive documents need to be processed to accurately determine if an answer is supported by the provided context.
This is our Large model based on ModernBERT - large
Model Details
Property |
Details |
Architecture |
ModernBERT (Large) with extended context support (up to 8192 tokens) |
Task |
Token Classification / Hallucination Detection |
Training Dataset |
RagTruth |
Language |
English |
How It Works
The model is trained to identify tokens in the answer text that are not supported by the given context. During inference, the model returns token - level predictions which are then aggregated into spans. This allows users to see exactly which parts of the answer are considered hallucinated.
🔧 Technical Details
The model's performance is evaluated on the test set of the [RAGTruth](https://aclanthology.org/2024.acl - long.585/) dataset.
Example level results:
Our large model, lettucedetect - large - v1, achieves an overall F1 score of 79.22%, outperforming prompt - based methods like GPT - 4 (63.4%) and encoder - based models like [Luna](https://aclanthology.org/2025.coling - industry.34.pdf) (65.4%). It also surpasses fine - tuned LLAMA - 2 - 13B (78.7%) (presented in [RAGTruth](https://aclanthology.org/2024.acl - long.585/)) and is competitive with the SOTA fine - tuned LLAMA - 3 - 8B (83.9%) (presented in the [RAG - HAT paper](https://aclanthology.org/2024.emnlp - industry.113.pdf)). Overall, lettucedetect - large - v1 and lettucedect - base - v1 are very performant models, while being very effective in inference settings.
The results on the example - level can be seen in the table below.
Span - level results:
At the span level, our model achieves the best scores across all data types, significantly outperforming previous models. The results can be seen in the table below. Note that here we don't compare to models, like [RAG - HAT](https://aclanthology.org/2024.emnlp - industry.113.pdf), since they have no span - level evaluation presented.
📄 License
This project is licensed under the MIT license.
📖 Citing
If you use the model or the tool, please cite the following paper:
@misc{Kovacs:2025,
title={LettuceDetect: A Hallucination Detection Framework for RAG Applications},
author={Ádám Kovács and Gábor Recski},
year={2025},
eprint={2502.17125},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2502.17125},
}