Quick Start¶
Detect Hallucinations¶
from lettucedetect.models.inference import HallucinationDetector
# Load a pre-trained model
detector = HallucinationDetector(
method="transformer",
model_path="KRLabsOrg/lettucedetect-base-modernbert-en-v1"
)
# Provide context, question, and answer
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?"
answer = "The capital of France is Paris. The population of France is 69 million."
# Get span-level predictions
predictions = detector.predict(
context=contexts,
question=question,
answer=answer,
output_format="spans"
)
print(predictions)
# [{'start': 31, 'end': 71, 'confidence': 0.99,
# 'text': ' The population of France is 69 million.'}]
Available Models¶
| Model | Language | Context | Size |
|---|---|---|---|
KRLabsOrg/lettucedetect-base-modernbert-en-v1 |
English | 4K | 149M |
KRLabsOrg/lettucedetect-large-modernbert-en-v1 |
English | 4K | 395M |
KRLabsOrg/lettucedetect-base-eurobert-multilingual-v1 |
7 languages | 8K | 210M |
See Models for the full list.
Detection Methods¶
# Transformer-based (recommended for production)
detector = HallucinationDetector(method="transformer", model_path="...")
# LLM-based (uses OpenAI API)
detector = HallucinationDetector(method="llm", model_path="gpt-4o-mini")
# RAG Fact Checker (triplet-based)
detector = HallucinationDetector(method="rag_fact_checker", model_path="gpt-4o-mini")