Skip to main content

SelfConsistency

Detects hallucinations by checking whether stochastic samples of the same prompt agree with each other. If a model truly knows something, its outputs converge. If it hallucinated, the samples contradict. Based on SelfCheckGPT (Manakul et al., EMNLP 2023) with production improvements: adaptive sample count, free-sample reuse, and a local NLI backend. When to use: Any generation task where you have no reference document to check against — knowledge QA, open-ended explanation, conversational responses. Pair with Faithfulness when a reference is available. Key limitation: Consistency is not factuality. A model that consistently hallucinates the same popular misconception will score as consistent. This evaluator catches inconsistent hallucinations — fabrications that vary across samples.

Backends

Adaptive N

With adaptive=True (default), the evaluator starts at n samples. If the score is borderline (0.3–0.7), it escalates up to max_n samples automatically. Most clear cases resolve at n=5. Ambiguous cases get up to n=20.

Free-sample integration

Pass samples= to reuse outputs you’ve already generated — no extra API calls:
This is the recommended approach when running multiple evaluators on the same cases.

Parameters

Example

With the NLI backend, no API calls are made for consistency scoring. With backend="llm", each evaluation makes up to 30 judge calls (6 sentences × 5 samples).

Score interpretation