Prerequisites
- Fiddler account with API access
- LLM credential configured in Settings > LLM Gateway
pip install fiddler-evals fiddler-client pandas
The Two-Layer Approach
Hallucination detection works best as a two-layer pipeline:Layer 1: Pre-Deployment Evaluation
1
Set Up and Connect
Use the RAG Health Metrics triad to distinguish hallucinations from other failure modes:
Replace
URL, TOKEN, and credential names with your Fiddler account details. Find your credentials in Settings > Access Tokens and Settings > LLM Gateway.2
Create Hallucination-Focused Test Cases
Design test cases that specifically probe for hallucination patterns:
3
Run the Diagnostic Evaluation
4
Interpret Results
Use the diagnostic workflow to classify failures:Expected output:
Reading the diagnosis: The triad distinguishes why a response failed:
- HALLUCINATION = Faithfulness fails (response fabricates information)
- BAD RETRIEVAL = Context Relevance fails (wrong documents retrieved)
- OFF-TOPIC = Answer Relevance fails (response doesn’t address the question)
Layer 2: Production Monitoring
- Option A: Evaluator Rules (Agentic)
- Option B: LLM Observability Enrichments
For applications using Agentic Monitoring, configure Evaluator Rules to continuously evaluate production spans:
- Navigate to your application’s Evaluator Rules tab
- Add a rule for RAG Faithfulness
- Map evaluator inputs to your span attributes:
user_query→ your query span attributerag_response→ your response span attributeretrieved_documents→ your context span attribute
- Set alert thresholds (e.g., alert when faithfulness drops below 80%)
Combining Both Layers
The most effective hallucination detection pipeline uses both layers:Next Steps
- RAG Health Diagnostics — Conceptual guide to failure mode diagnosis
- RAG Evaluation Fundamentals — Direct evaluation with
.score()API - Evaluator Rules — Configure production monitoring rules
Source notebooks: