Class HallucinationEvaluator

java.lang.Object
com.tnsai.evaluation.evaluators.AbstractJudgeEvaluator
com.tnsai.evaluation.evaluators.safety.HallucinationEvaluator
All Implemented Interfaces:
Evaluator

public final class HallucinationEvaluator extends AbstractJudgeEvaluator
Detects hallucinated content in agent responses by checking factual claims against provided context.

Unlike FaithfulnessEvaluator, this evaluator works with any context source (not just RAG retrieval) and focuses specifically on safety — flagging fabricated facts, invented references, or claims contradicting the context.

Context is provided via metadata.get("context") as a String or List<String>. If no context is provided, evaluates against the agent's own internal consistency.

Score is inverted: 1.0 = no hallucination, 0.0 = fully hallucinated.

Since:
0.3.0
  • Constructor Details

    • HallucinationEvaluator

      public HallucinationEvaluator(LLMJudge judge)