Skip to main content

Overview

The Faithfulness evaluator is a specialized hallucination-detection metric that determines whether an LLM’s response is grounded in and faithful to the provided context. It detects when responses contain information that is not supported by or contradicts the reference context.

When to Use

Use the Faithfulness evaluator when you need to:
  • Validate RAG (Retrieval-Augmented Generation) outputs - Ensure answers are based on retrieved documents or search results
  • Detect hallucinations in grounded responses - Identify when the LLM makes up information not present in the context
  • Evaluate Q&A systems over private data - Verify responses only contain information from your knowledge base
This evaluator is specifically designed for grounded responses where context is provided. It is not designed to validate general world knowledge or facts the LLM learned during training.

Supported Levels

The level of an evaluator determines the scope of the evaluation in OpenTelemetry terms. Some evaluations are applicable to individual spans, some to full traces or sessions, and some are applicable at multiple levels. Relevant span kinds: LLM spans, particularly those in RAG pipelines where documents are retrieved and used as context.

Input Requirements

The Faithfulness evaluator requires three inputs:

Formatting Tips

For best results:
  • Use human-readable strings rather than raw JSON for all inputs
  • For multi-turn conversations, format the input as a readable conversation:
  • For multiple retrieved documents, concatenate them with clear separators (see Input Mapping example below):

Output Interpretation

The evaluator returns a Score object with the following properties: Interpretation:
  • Faithful (1.0): The response is fully supported by the context and does not contain made-up information
  • Unfaithful (0.0): The response contains information not present in the context or contradicts it

Usage Examples

Using Input Mapping

When your data has different field names or requires transformation, use input mapping. This is especially useful when you need to combine multiple documents into a single context string.
For more details on input mapping options, see Input Mapping.

Configuration

For LLM client configuration options, see Configuring the LLM.

Viewing and Modifying the Prompt

You can view the latest versions of our prompt templates on GitHub. The evaluators are designed to work well in a variety of contexts, but we highly recommend modifying the prompt to be more specific to your use case. Feel free to adapt them.

Using with Phoenix

Evaluating Traces

Run evaluations on traces collected in Phoenix and log results as annotations:

Running Experiments

Use the Faithfulness evaluator in Phoenix experiments:

API Reference