
Your AI Gives an Answer. But Can You Trust It?
Learn how Amazon Bedrock Guardrails uses contextual grounding checks to detect unsupported AI responses and improve reliability in RAG applications.
Your AI Gives an Answer. But Can You Trust It?
Imagine asking an AI assistant a simple question about your company's refund policy.
It responds confidently:
"Customers can request a full refund within 60 days of purchase."
The answer sounds reasonable. It is written clearly, and there is no indication that anything is wrong.
But when you check the actual company policy, you discover that the refund period is only 30 days.
The AI did not struggle to produce an answer. It struggled to produce a correct one.
This is one of the challenges developers face when building applications powered by large language models (LLMs). These models can generate natural, convincing responses, but that does not mean every statement they produce is supported by reliable information.
This behavior is commonly called an AI hallucination.
For applications that answer questions using company documents, customer records, product information, or internal knowledge bases, an unsupported answer can become more than a minor inconvenience. It can mislead users and damage trust in the application.
So how can developers reduce this risk?
On AWS, Amazon Bedrock Guardrails provides contextual grounding checks that can evaluate whether a model's response is supported by a reference source and relevant to the user's question.
Let's explore how it works and how developers can use it when building more reliable AI applications.
Why AI models hallucinate
Large language models generate responses by predicting sequences of text based on patterns learned during training and the context provided to them.
They are designed to produce useful, coherent answers. However, they do not automatically verify every statement against an authoritative source.
This can lead to several problems:
- Invented information: The model provides details that were never present in the source material.
- Incorrect facts: It combines information in a way that produces an inaccurate conclusion.
- Unsupported assumptions: It fills gaps in available information instead of acknowledging that something is missing.
- Irrelevant responses: It produces an answer that sounds reasonable but does not actually address the user's question.
For example, imagine a company has the following refund policy:
- Standard purchases are eligible for refunds within 30 days.
- Digital products are non-refundable.
- Refund requests after 30 days require special approval.
A customer asks:
"Can I get a refund for a purchase I made 45 days ago?"
An AI model might respond:
"Yes, you can request a refund within 60 days of purchase."
The response is grammatically correct, but the information is not supported by the company's policy.
The problem is not necessarily that the model lacks the ability to understand the question. It is that generating a convincing response and verifying a response are two different tasks.
Grounding: giving AI something reliable to reference
One way to reduce hallucinations is through a technique called grounding.
Instead of asking a model to answer entirely from its general training knowledge, developers provide relevant information that the model should use when generating a response.
This is especially useful when building applications around company-specific information.
For example, a customer support assistant might retrieve information from:
- Company policy documents
- Product documentation
- Frequently asked questions
- Internal knowledge bases
- Customer support manuals
The model then uses this information as context for its answer.
A common architecture for this is Retrieval-Augmented Generation (RAG).
How RAG works
RAG combines information retrieval with language generation.
A simplified process looks like this:
- A user submits a question.
- The application searches a connected knowledge base for relevant information.
- The most relevant document sections are retrieved.
- The retrieved information is provided to the language model as context.
- The model generates a response based on the retrieved information.
For example, when a customer asks about a refund, the application retrieves the company's refund policy and provides it to the model.
Instead of relying entirely on what it learned during training, the model now has relevant company information available.
This makes the answer more context-aware and gives developers a source against which they can evaluate the response.
However, there is an important limitation.
Providing reference information does not guarantee that the model will use it correctly.
A model can still misunderstand a document, introduce unsupported details, or produce an answer that does not address the question.
This is where response validation becomes important.
Introducing Amazon Bedrock Guardrails
Amazon Bedrock Guardrails helps developers implement safeguards for generative AI applications.
It provides configurable policies that can evaluate user inputs and model responses.
Depending on the application's requirements, these policies can include:
- Content filters for harmful or inappropriate content.
- Denied topics to restrict specific subjects.
- Word filters to detect unwanted terms.
- Sensitive information filters to detect or mask personally identifiable information.
- Contextual grounding checks to evaluate whether responses are supported by reference information and relevant to the user's question.
For this article, we will focus on contextual grounding checks.
Unlike simply providing a model with additional context, contextual grounding checks evaluate the response itself.
They help answer two important questions:
- Is the model's response supported by the information provided?
- Does the response actually answer the user's question?
These are called the grounding check and the relevance check.
How contextual grounding checks work
Amazon Bedrock Guardrails evaluates a model response using three important inputs:
1. Grounding source
This is the reference information the response should be based on.
For example, the company's official refund policy.
2. User query
This is the question the user originally asked.
For example, "Can I get a refund for a purchase made 45 days ago?"
3. Model response
This is the generated answer that needs to be evaluated.
For example, "Yes, customers can request a refund within 60 days."
Using these inputs, Bedrock Guardrails evaluates two dimensions.
Grounding check
The grounding check evaluates whether the information in the model's response is supported by the reference source.
If the response introduces information that is not supported by the provided source, it can receive a lower grounding score.
In our refund example, the model claims that customers have 60 days to request a refund, even though the company policy specifies 30 days.
That claim is not grounded in the reference information.
Relevance check
The relevance check evaluates whether the response actually addresses the user's question.
A response can be factually correct and still be irrelevant.
For example:
User question:
"What is the company's refund period?"
Reference source:
"Customers can request a refund within 30 days of purchase."
Model response:
"Our company also offers free shipping on selected orders."
The response contains information that might be true, but it does not answer the question.
This is why grounding and relevance are separate checks. A reliable AI application needs responses that are both supported by the available information and relevant to the user's request.
Understanding grounding and relevance scores
Amazon Bedrock Guardrails produces grounding and relevance scores for the response.
Developers can configure thresholds that determine whether a response should be allowed or filtered.
For example, imagine configuring both thresholds to 0.70.
- A grounding score below 0.70 means the response does not meet the required grounding threshold.
- A relevance score below 0.70 means the response does not meet the required relevance threshold.
- If either score falls below its configured threshold, the response can be blocked when the corresponding filter action is set to BLOCK.
The thresholds can be configured between 0 and 0.99. A threshold of 1 is invalid.
A higher threshold makes the check stricter, increasing the likelihood that unsupported or irrelevant responses will be filtered.
However, setting a very high threshold can also block legitimate responses.
It is important to test different thresholds using your own reference documents and real user questions rather than assuming one value works for every application.
AWS also provides two safeguard tiers for contextual grounding checks:
Classic tier
This tier performs stricter grounding evaluations. Information that is not explicitly stated in the reference source can reduce the grounding score, including reasonable inferences and conversational phrasing.
It supports English, French, and Spanish.
Standard tier
This tier is designed to handle responses that include reasoning and conversational content more robustly. It can provide more consistent scores for differently worded responses that have the same meaning.
It supports the same languages as the Standard tier for content filters.
One important deployment consideration is that the Standard tier requires cross-Region inference through a supported guardrail profile. Its availability is also limited to specific AWS Regions.
As of November 2026, the listed regions include Tokyo in Asia Pacific, but not Singapore. Developers deploying in other regions should check the current supported-region documentation before choosing this tier.
For conversational applications using the Standard tier, AWS suggests 0.7 as a reasonable starting point for grounding and relevance thresholds. These values should still be tested against your application.
Putting it all together: a more reliable AI support assistant
Let's combine the concepts into one practical architecture.
Imagine building an AI-powered customer support assistant for an online store.
Customers can ask questions about refunds, shipping, product warranties, and other company policies.
A simplified architecture could look like this:
Step 1: Customer submits a question
The customer asks:
"Can I get a refund for an order I purchased 45 days ago?"
Step 2: Retrieve relevant information
Amazon Bedrock Knowledge Bases retrieves the relevant sections of the company's refund policy.
The retrieved information becomes the reference source for the model.
Step 3: Generate an answer
The language model receives the customer question and the retrieved policy information.
It generates a response explaining the refund requirements.
Step 4: Evaluate the response
Amazon Bedrock Guardrails performs contextual grounding checks using the reference source, user query, and generated response.
It evaluates whether the answer is grounded and relevant.
Step 5: Apply the configured safeguards
If the response does not meet the configured thresholds, the application can block it and return a predefined message.
For example:
"I couldn't verify this answer against our current refund policy. Please contact our support team for assistance."
If the response passes the checks, the application can proceed with returning it to the customer.
The resulting architecture looks like this:
Customer → Application → Knowledge Base → Language Model → Bedrock Guardrails → Customer
The important addition is the validation step between generation and delivery.
Instead of immediately returning whatever the model produces, the application evaluates the response against the information it was supposed to use.
What developers should keep in mind
Contextual grounding checks are useful, but they are not a complete solution to AI hallucinations.
There are several considerations worth understanding before implementing them.
1. Your reference information still matters
Guardrails cannot reliably validate an answer against information that was never provided as a grounding source.
If your documents are outdated, incomplete, or incorrect, the application can still produce misleading answers.
The quality of the reference information remains important.
2. A high score does not guarantee absolute correctness
A response that passes a grounding check is not automatically guaranteed to be true in the real world.
The check evaluates the response against the reference source and query you provide.
If the reference source itself contains an error, the evaluation does not magically correct it.
3. Grounding is not the same as authorization
Imagine a customer support assistant that can retrieve internal company documents.
Even if a response is properly grounded, the application must still ensure that the user is authorized to access the information.
Grounding checks do not replace authentication, authorization, or access-control policies.
4. Retrieved references also need protection
When using Amazon Bedrock Knowledge Bases, guardrails are applied to the input and generated response, not automatically to the retrieved references themselves at runtime.
Developers should therefore consider how retrieved content is sourced, validated, and protected.
5. Test before deploying
Different applications have different requirements.
A customer support chatbot, an internal documentation assistant, and a financial information application may need different grounding and relevance thresholds.
Test with both correct and incorrect responses, ambiguous questions, missing information, and edge cases.
You should also consider how your application behaves when a response is blocked or when the grounding source does not contain enough information to answer.
For streaming applications, there is another detail worth considering: a response can begin reaching the user before the complete contextual grounding evaluation finishes. If you need to prevent unverified content from being displayed, design your response flow to validate before releasing the complete answer.
Getting started with Amazon Bedrock Guardrails
If you want to experiment with contextual grounding checks, you can start through the Amazon Bedrock console.
At a high level:
- Open the Amazon Bedrock console.
- Navigate to Guardrails.
- Create a new guardrail.
- Configure its details and blocked response messages.
- Enable contextual grounding checks.
- Configure grounding and relevance thresholds.
- Select the appropriate safeguard tier.
- Review and create the guardrail.
- Test it using a reference source, a user query, and different model responses.
You can also configure and apply guardrails programmatically through AWS APIs.
The
ApplyGuardrail API is particularly useful when you want to evaluate content independently of a specific model invocation. It accepts the reference source, query, and response as separate inputs for contextual grounding evaluation.This is also useful when building applications that use models outside Amazon Bedrock. You can apply the guardrail to content generated by other model providers rather than relying exclusively on a particular foundation model.
For a practical starting point, AWS provides documentation covering the console setup, API configuration, and examples of contextual grounding checks.
Final thoughts
AI applications are becoming increasingly capable, but capability alone does not make them trustworthy.
A model can generate a response that sounds correct, follows the user's question, and looks professional while still introducing information that was never supported by its sources.
That is why developers should think beyond simply generating answers.
Grounding provides the model with relevant information. Contextual grounding checks provide an additional way to evaluate whether the generated response actually uses that information correctly.
With Amazon Bedrock Knowledge Bases and Amazon Bedrock Guardrails, developers can build a process that retrieves information, generates an answer, and evaluates the result before presenting it to the user.
It does not eliminate hallucinations, and it does not replace proper testing or application-level security. But it adds an important layer of validation that can make generative AI applications more dependable.
The goal should not be to build an AI that always sounds confident. It should be to build an AI application that knows when its answers are supported by evidence.
Further reading
The views and opinions expressed in this article are my own.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article