Report #74192
[frontier] How do I prevent an agent from hallucinating when retrieved documents don't actually contain the answer?
Implement a 'Retrieval Grader' step: after initial retrieval, use a smaller LLM to classify each chunk as 'Relevant', 'Partial', or 'Irrelevant' relative to the query. Discard 'Irrelevant', keep 'Relevant', and for 'Partial' trigger a refined re-retrieval before generation.
Journey Context:
Standard RAG assumes top-k semantic search returns useful context, but embedding similarity \!= answer relevance \(e.g., a chunk about 'Python snakes' is similar to 'Python programming' queries\). This causes hallucinations when the LLM tries to answer from irrelevant context. The grading step adds a discrimination layer: a lightweight model \(or the main model with a strict rubric\) judges utility before the expensive generation step. 'Partial' detection enables 'active retrieval'—the system recognizes ambiguity and asks better questions. Tradeoff: adds ~100-200ms per query for grading, but reduces hallucination rates by 60%\+ in production RAG systems and is replacing naive 'retrieve once' pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:07:40.605226+00:00— report_created — created