- Newest
- Most votes
- Most comments
To view grounding scores for an AWS Bedrock agent with guardrails enabled (specifically for contextual grounding), you need to make some adjustments to your approach. Here's what you can do:
-
Enable tracing: When invoking the agent, you need to enable tracing to get detailed information about the guardrail evaluations, including grounding scores. You can do this by setting the 'trace' parameter to 'ENABLED_FULL' in your invoke_agent call.
-
Check the response: With tracing enabled, the response from invoke_agent should include a 'trace' field. This field will contain detailed information about the guardrail evaluations, including the contextual grounding scores.
-
Examine the trace: In the trace, look for the 'guardrailEvaluations' section. Within this, you should find information about the contextual grounding check, including the grounding and relevance scores.
-
Parse the scores: The scores will be provided as values between 0 and 1. A higher score indicates better grounding or relevance.
It's important to note that the contextual grounding check is only performed on the output, not on the prompt. If you've marked specific content blocks with the 'guard_content' qualifier, the contextual grounding check will focus on those blocks along with the grounding source and query.
If you're not seeing the scores even with tracing enabled, double-check that your guardrail is correctly associated with the agent and that the contextual grounding check is indeed enabled in your guardrail configuration.
Remember, by default, only detected content (content that breaches your guardrail configurations) is returned in the response. If you want to see all evaluations, including those that didn't trigger the guardrail, make sure you've set the output scope to 'FULL' in your guardrail configuration.
If you're still not seeing the scores, you might want to review your IAM permissions to ensure you have the necessary access to view detailed guardrail information.
Sources
Use the ApplyGuardrail API in your application - Amazon Bedrock
Use contextual grounding check to filter hallucinations in responses - Amazon Bedrock
GuardrailContextualGroundingFilter - Amazon Bedrock
answered a year ago
Even with enableTrace=True, the response from invoke_agent does not contain any contextual grounding scores (like groundingScore, relevanceScore, etc.).
Instead, the guardrailTrace section only contains:
contentPolicy
sensitiveInformationPolicy
topicPolicy
wordPolicy
There's no mention of contextualGroundingPolicy or anything related to grounding/relevance scoring.
Additional Observation: The boto3 documentation for invoke_agent https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agent-runtime/client/invoke_agent.html#invoke-agent also does not show any fields or structure related to contextual grounding in the response format.
This raises two questions:
1.Is contextual grounding currently supported in invoke_agent traces at all?
2.If so, is there any special configuration required to surface these scores?
answered a year ago
Relevant content
asked a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 7 months ago
