hallucination_check
Lexical hallucination check: verifies an LLM answer's words, numbers and polarity against the provided source/context. Fast, deterministic, no API key needed. Each answer sentence is aligned to its best-matching source sentence, so a number only counts as support when it sits on the SAME statement ("founded in 1998" is not grounded by "sold 1998 units"), and a negation or antonym flip against that sentence returns verdict "contradicted" — the corrupted-fact hallucination that reuses source vocabulary. Limitations: still lexical — it cannot follow a paraphrase, a synonym, or multi-sentence reasoning, so a "well_grounded" verdict means "nothing lexical found", never "verified true". For entailment use run_semantic_tests (NLI/embedding) or a calibrated judge.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| answer | Yes | The LLM-generated answer to verify | |
| strict | No | If true, every sentence in the answer must be supported (default: false) | |
| context | Yes | The source/reference text that should ground the answer |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | No | ||
| message | No | ||
| numbers | No | ||
| overlap | No | ||
| verdict | No | ||
| analysis | No | ||
| entities | No | ||
| grounded | No | ||
| sentence | No | ||
| total_words | No | ||
| matched_words | No | ||
| contradictions | No | ||
| grounded_count | No | ||
| unbound_claims | No | ||
| grounding_score | No | ||
| total_sentences | No | ||
| ungrounded_count | No | ||
| unsupported_claims | No |