CertBrain
CoursesBlog
Sign in
← Back to decks
Sign in to save your progress, vote, and build your own decks.Sign in

Detecting Hallucinations and Grounding

A hallucination is a confident answer that isn't true or isn't supported by any source. In a live application, hallucinations are a security and trust problem as well as a quality one: a wrong policy answer can mislead a customer, and an invented fact stored by one agent can mislead every agent…

9 cards
Study this deck

Detecting Hallucinations and Grounding

A hallucination is a confident answer that isn't true or isn't supported by any source. In a live application, hallucinations are a security and trust problem as well as a quality one: a wrong policy answer can mislead a customer, and an invented fact stored by one agent can mislead every agent that reads it later. This lesson covers how teams ground answers in real sources, score how well an answer is supported, validate outputs before they're used, and decide when a person must check.

Grounding the answer

Grounding means tying the model's answer to trusted information instead of letting it rely on what it absorbed in training. Retrieval Augmented Generation (RAG) is the main technique: the application retrieves relevant passages and the model answers from them. RAG only helps when the right, correct information exists in the knowledge base and can be found.

Amazon Bedrock Knowledge Bases returns citations with each generated answer, linking parts of the response to the source chunks they came from. Citations don't stop a hallucination by themselves, but they make every claim checkable, by a user or by an automated check.

Confidence scoring and thresholds

A confidence score is a number that says how well an output is supported. Bedrock Guardrails' contextual grounding check gives each response a grounding score and a relevance score against the source and the user's question. A team sets a threshold between 0 and 0.99, and responses scoring below it are treated as hallucinations and blocked.

The threshold is a trade-off:

  • Higher blocks more unsupported answers, but also more correct ones.
  • Lower lets more answers through, including some weak ones.

AWS's agentic AI guidance suggests higher thresholds for safety-critical uses and lower ones for creative tasks, with thresholds tuned over time from logged results. The same guidance warns against one tempting shortcut: asking the model to rate its own confidence. A model sounds just as sure about invented facts as about real ones, so the score must come from an independent check.

Validating outputs

Several checks can sit between the model and the user:

  • Automated Reasoning checks in Bedrock Guardrails translate a response into formal logic and test it against rules built from your policy documents. An INVALID result lists the policy rules the claim breaks. These checks only report findings; they never block, so the application must decide whether to serve, rewrite or withhold the answer.
  • LLM-as-a-judge. A second model receives the source and the answer and assesses whether the answer is supported.
  • Business checks. Facts such as prices, dates or account balances can be compared with the system of record before a reply is sent.

When a check fails, the application needs a fallback, such as adding a caveat, asking the user to clarify, or refusing to show the answer.

Human review

Human review gives the greatest confidence that an answer is correct, but it's slow and costly. AWS's generative AI guidance reserves it for the most critical responses and stresses that reviewers must be well trained. Automated checks handle the bulk of the traffic, and people handle the cases where a mistake could cause real harm.

On the exam

"Too many correct answers blocked" means lower the grounding threshold and retest. "Findings show INVALID but the answer still went out" means the application isn't acting on Automated Reasoning findings. "The model rates its own confidence" is the wrong answer; use an independent check. "Errors could harm people" points to trained human review.

Quiz me on this
An insurer's question-answering tool checks every answer with an Amazon Bedrock Guardrails contextual grounding check set to a threshold of 0.95. Reviewers find that many correct answers, fully supported by the policy documents, are being blocked, and the logs show they scored just under 0.95. What should the team do?
  1. Raise the grounding threshold to 0.99 so that only the best answers pass
  2. ✓ Lower the grounding threshold, then retest on a set of real questions
  3. Turn off the relevance check and leave the grounding threshold unchanged
  4. Increase the model's temperature so that its answers vary more widely
A mortgage lender adds an Automated Reasoning policy, built from its eligibility rules, to an Amazon Bedrock guardrail. Logs show several answers about loan eligibility returned INVALID findings, yet those answers still reached customers. What explains this?
  1. The policy is too large, and it must be split across smaller guardrails to block
  2. Automated Reasoning checks only work on streaming responses, so the app must stream
  3. ✓ The checks only report findings; the app must withhold or rewrite flagged answers
  4. INVALID means the answer was unclear, so passing it through is the expected result
In a multi-agent research system, one agent asks its model to rate its own confidence from 1 to 10, then saves any answer rated 8 or higher to shared memory. Invented facts still get saved and reused by other agents. Which change addresses this BEST?
  1. ✓ Score each output against its sources with a separate grounding check
  2. Ask the model to rate its own confidence on a finer 1-100 scale instead
  3. Store every output and let downstream agents decide which facts to trust
  4. Raise the required self-rating from 8 to 9 before any output is stored
A hospital's assistant drafts answers to patients' questions about their medication. Automated guardrails catch many problems, but a rare mistake could harm a patient. Which addition gives the MOST confidence that these answers are correct?
  1. A disclaimer at the end of every answer saying it may contain mistakes
  2. ✓ Review by trained clinical staff before any answer reaches a patient
  3. A higher temperature so that the model considers more possible answers
  4. A longer maximum output length so that answers include more detail
Contextual grounding threshold
A value from 0 to 0.99. Responses scoring below it are blocked as ungrounded or irrelevant. A higher threshold blocks more, including some correct answers.
Automated Reasoning checks
Test a response against logic rules built from your policy documents. Detect mode only: they return findings, such as INVALID, and the app decides what to do.
Why not trust a model's self-rated confidence?
Models sound equally sure about invented and real facts. Use an independent check, such as a grounding score or a judge model, instead.
Citations in Amazon Bedrock Knowledge Bases
Generated answers come with citations that link parts of the response to the source chunks, so each claim can be checked.
When to use human review
For the most critical responses, where a mistake could cause real harm. It gives the most confidence but is slow, so reviewers must be well trained.