Detect Hallucination

Identifies fabricated facts or details a model added that aren't present in the input or provided context.

Detect Hallucination checks whether a response contains facts the model made up, information that isn’t backed by the input or context it was given. Run it as a direct hallucination check on generated content.

What it does

Detect Hallucination is an LLM-as-Judge eval. It reads the context and the generated output (and optionally the input), then returns a pass/fail on whether fabricated content is present.

Input

Required InputTypeDescription
outputstringOutput generated by the model
contextstringThe context provided to the model
Optional InputTypeDescription
inputstringInput provided to the model

Output

FieldTypeDescription
ResultPass / FailPassed means no hallucination is detected, Failed means hallucination is detected
ReasonstringA plain-language explanation of the evaluation

Run it from code

Call evaluate() with the template name and the eval’s required inputs. It returns the score and the reason.

Note

Before running: install the SDK and set FI_API_KEY / FI_SECRET_KEY. The model argument in the snippets is the evaluator model Future AGI uses to run the eval; turing_flash is a fast default.

from fi.evals import evaluate

result = evaluate(
    "detect_hallucination",
    context="Honey never spoils because it has low moisture content and high acidity, creating an environment that resists bacteria and microorganisms. Archaeologists have even found pots of honey in ancient Egyptian tombs that are still perfectly edible.",
    output="Honey doesn't spoil because its low moisture and high acidity prevent the growth of bacteria and other microbes.",
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "detect_hallucination",
  {
    context: "Honey never spoils because it has low moisture content and high acidity, creating an environment that resists bacteria and microorganisms. Archaeologists have even found pots of honey in ancient Egyptian tombs that are still perfectly edible.",
    output: "Honey doesn't spoil because its low moisture and high acidity prevent the growth of bacteria and other microbes."
  },
  { modelName: "turing_flash" }
);

console.log(result);

When to use

Run Detect Hallucination wherever fabricated facts would be costly, and you want a direct signal on made-up content rather than a broader adherence score.

  • Text, audio, image, and chat outputs generated from a fixed input or context
  • RAG and retrieval pipelines, to catch fabricated details that slipped past retrieval-grounded generation
  • Hallucination checks, as a targeted complement to Context Adherence and Groundedness

What to do when Detect Hallucination fails

If the content is evaluated as containing hallucinations (Failed) and you want to improve it:

  • Ensure all claims in your output are explicitly supported by the source material
  • Avoid extrapolating or generalizing beyond what is stated in the input
  • Remove any specific details that aren’t mentioned in the source text
  • Use qualifying language (like “may,” “could,” or “suggests”) when necessary
  • Stick to paraphrasing rather than adding new information
  • Double-check numerical values, dates, and proper nouns against the source
  • Consider directly quoting from the source for critical information
Was this page helpful?

Questions & Discussion