KRLabsOrg/LettuceDetect

Span-level grounding verification for RAG, code, and tool-grounded AI outputs.

What it solves

LettuceDetect is a span-level grounding verifier designed to identify hallucinations in AI-generated outputs. Unlike traditional verifiers that provide a simple pass/fail verdict for an entire answer, this tool localizes the exact character spans that are unsupported, contradictory, or fabricated based on provided source evidence.

How it works

The system uses token-level classification to predict whether specific parts of an answer are hallucinated given a context and a question. It offers two primary model types:

  • Encoder models (e.g., based on ModernBERT or EuroBERT): Fast, local models that provide binary hallucination flags for spans.
  • Generative models (e.g., based on Qwen-2B): Models that can identify and "type" (categorize) hallucinated spans into categories like "contradiction" or "numerical" in a single pass.

Who it’s for

It is built for developers implementing RAG (Retrieval-Augmented Generation) systems, coding agents, and tool-grounded AI workflows who need high-precision hallucination detection to ensure the factual accuracy of their AI's responses.

Highlights

  • Span-level precision: Identifies exact character offsets of hallucinated text rather than just flagging the whole response.
  • Linguistic versatility: Supports English and multiple other languages (including German, French, Spanish, Italian, Polish, and Chinese).
  • Broad application: Works across prose, multilingual QA, code-agent answers (detecting invented APIs or wrong values), and developer-tool output.
  • Flexible deployment: Provides a Python API, a Web API, and a Streamlit demo for easy integration.

Related

  • Project
  • Project
  • Project
  • Project
  • Project