Detecting Fabrications and Diagnosing Retrieval or Generation Failures
This lesson explains how to detect fabrications, content presented as fact but not supported by the sources, at evaluation time and at runtime, and how to diagnose quality problems by separating retrieval failures from generation failures.
Learning outcomes
After completing this lesson, you will be able to:
- Detect fabrications with the groundedness evaluator and runtime checks.
- Decide whether retrieval or generation failed from evaluator scores.
- Group failures by root cause with error analysis.
- Choose a runtime response to ungrounded content.
Detecting fabrications
At evaluation time, the groundedness evaluator checks each claim in a response against the supplied context and returns a score with the unsupported parts in its reason. At runtime, the groundedness risk in guardrails (preview) and the Azure Content Safety groundedness detection API check responses against their grounding sources and can flag ungrounded segments. For tasks with known answers, comparison with ground truth also reveals fabricated values, such as invented dates or amounts.
Prevention complements detection: instructions to answer only from the sources and to say when information is missing, low temperature, citations that the application can verify against retrieved IDs, and structured outputs that separate facts from explanations.
Retrieval or generation?
A RAG answer can be wrong for two quite different reasons, and the fixes do not overlap. In a retrieval failure, the passage that contains the answer never reached the model, so the model either says that it does not know or answers faithfully from the wrong passages. In a generation failure, the right passage was retrieved, but the model added information that the passage does not contain, ignored it, or answered a different question. Changing the prompt cannot repair a retrieval failure, and re-indexing cannot repair a generation failure, so diagnosis must decide which part failed before anything is changed.
Three evaluator scores, read together, make that decision. Retrieval quality shows whether the retrieved chunks were relevant to the query. Groundedness shows whether the response stayed within those chunks. Relevance shows whether the response addressed the question. The key insight is that groundedness measures faithfulness to the context, not correctness: a response that faithfully repeats the wrong context scores high on groundedness and low on relevance, which points to retrieval. A low groundedness score with good retrieval points to the prompt, the temperature or the model. The following table shows how these combinations point to a cause.
| Retrieval quality | Groundedness | Relevance | Likely cause |
|---|---|---|---|
| Low | High | Low | Right behaviour on wrong context: fix retrieval |
| High | Low | Any | Model adds unsupported content: fix prompt, temperature or model |
| High | High | Low | Model answers a different question: fix query rewriting or instructions |
| Low | Low | Low | Both stages need work; start with retrieval |
The following decision tree turns the table into a diagnosis sequence.

Diagnose from the scores
Error analysis
Error analysis groups failing rows by root cause, such as missing document, wrong chunk, outdated content, ambiguous question, prompt allows outside knowledge, or tool failure, and addresses the largest group first. Traces show what was retrieved and what the model received. After each fix, the same evaluation is repeated to confirm the improvement and check for regressions elsewhere.
Responding to ungrounded content at runtime
Detection at runtime is useful only if the application does something with the result. The response depends on the risk of the use case. In a low-risk assistant, the application can show the answer with its citations and a notice that some statements could not be verified. In a higher-risk setting, such as policy or medical information, the application can block the response, regenerate it with stricter instructions, or reply that the information is not available in the sources and offer escalation to a person.
Every flagged response is logged with its trace, so that the cases feed error analysis and the evaluation dataset. A rising rate of flagged responses after a change to the index, the prompt or the model is an early signal of a regression, and it can be monitored with an alert in the same way as error rates or latency.
Handle ungrounded answers
Confident but wrong
A product assistant gives detailed but incorrect specifications for a new product. Traces show that retrieval returned chunks about an older product with a similar name, and the response accurately reflects those chunks.
Groundedness is high (the answer matches its context) and retrieval is the problem. Adding a filterable product model field, including the model name in the query, or using hybrid search so that the exact product name matches would fix it. Lowering temperature would not, because the model faithfully used the wrong context.
Does a high groundedness score prove an answer is factually true?
Show answer
No. Groundedness measures whether the answer is supported by the context provided. If retrieval returned the wrong content, a grounded answer can still be wrong.
Exam Tips
Remember for the exam
- Groundedness detects fabrication relative to the provided context, not factual truth in general.
- High groundedness with wrong answers means retrieval returned the wrong content.
- Group failures by root cause and fix the largest group first.