AIP-C01 Responsible AI: Transparency, Fairness Evaluations and Policy-Compliant GenAI on AWS
Responsible AI in a generative AI application means making FM outputs transparent (users and auditors can see why an answer was given, how confident it is and what evidence supports it), fair (outputs do not treat groups differently) and compliant with written policy, and proving each with measurements rather than promises. Task 3.4 of AIP-C01 covers building that on AWS: Amazon Bedrock agent traces and user-facing explanations, knowledge base citations, confidence and fairness metrics in Amazon CloudWatch, counterfactual bias tests, prompt A/B tests with Prompt Management and Bedrock Flows, LLM-as-a-judge evaluations, guardrails mapped from policy, model cards and Lambda compliance checks. This lesson explains how each works and where the near-identical alternatives fall short.
On this page10 sections
- How do you get reasoning traces from an Amazon Bedrock agent?
- How should an application show users an explanation of an AI output?
- How do you present evidence and source attribution for generated answers?
- How do you measure confidence and disclose uncertainty with CloudWatch?
- How do you test an FM for bias with counterfactual evaluations?
- How do you track fairness metrics in Amazon CloudWatch?
- How do Prompt Management and Bedrock Flows support systematic A/B testing?
- How do Amazon Bedrock LLM-as-a-judge evaluations measure bias and harm?
- How do you turn responsible AI policy into Amazon Bedrock guardrails and enforce them?
- How do model cards and Lambda compliance checks document limitations and enforce policy?
- Capture Amazon Bedrock agent traces, attribute steps in multi-agent systems, and keep prompts out of user-facing output
- Build user-facing explanations and source citations that reflect what actually happened instead of model self-report
- Measure confidence and uncertainty with observable signals, publish them to CloudWatch, and disclose weak evidence to users
- Design counterfactual fairness tests and CloudWatch disparity alarms that hold up to review
- Run reproducible prompt A/B tests with Prompt Management versions, Flows aliases and condition nodes
- Use Amazon Bedrock LLM-as-a-judge evaluations, including your own responses, and keep scores comparable across releases
- Translate policy into guardrail policies, enforce them with IAM, and document and check compliance with model cards and Lambda
How do you get reasoning traces from an Amazon Bedrock agent?
You get a step-by-step reasoning trace from an Amazon Bedrock agent by setting enableTrace to true on the InvokeAgent request. (Amazon Bedrock Agents, now labelled Agents Classic, is no longer open to new customers; tracing still works for existing agents, and AWS points new agent builds at Amazon Bedrock AgentCore and its built-in observability.) Trace is switched on per request, needs no instrumentation code, and arrives in the same response stream as the answer: alongside the answer chunk (one chunk for the whole answer by default, or many when the final response is streamed), the stream carries TracePart events that record what the agent did at each step of orchestration.
What a trace contains
| Trace element | What it records | Who should see it |
|---|---|---|
rationale (orchestration trace) | The model's own text explaining why it chose the next step | Engineers and auditors; it is unvetted model text |
invocationInput | Which action group (and API/function with its parameters) or knowledge base (and query) the agent is calling | Engineers and auditors; safe to map to approved user-facing wording |
observation | What the call returned, a knowledge base result, or the final response | Engineers and auditors |
modelInvocationInput / modelInvocationOutput | The full prompt text sent to the model for that step (including the prompt templates) and the raw model output | Server side only; it exposes prompt templates and any confidential instructions in them |
| Pre-processing, post-processing, guardrail and failure traces | Input classification, response shaping, guardrail assessments, and why a step failed | Engineers |
A trace is evidence from inside the agent, which is what sets it apart from the other observability tools. AWS CloudTrail is an API audit log: it captures who made a call and when, at the boundary of the service. AWS X-Ray captures timing and dependencies of the code it instruments. Neither sees the orchestration decisions the agent makes between the request and the answer. And any account the model writes about its own steps is self-report, which is only as accurate as the model's narration.
Multi-agent collaboration: attributing each step
With a supervisor agent routing to collaborator agents, every trace part also carries collaboratorName and callerChain. For a single agent, callerChain holds only that agent's alias ARN; with collaboration it lists every agent that forwarded the request. Those two fields are how you attribute a rationale to the agent that produced it. Identifiers that describe the conversation as a whole (the session ID) or a single model call (an invocation log record) cannot tell you which agent in the chain made a decision.
Keeping traces safe and long-lived
Because the trace includes prompts, it must never be forwarded to a browser and "hidden" by client-side code: anything sent to the client is exposed. The backend receives the stream, extracts only what users may see, and separately persists the full trace events to controlled storage, for example a CloudWatch Logs log group encrypted with an AWS KMS key, with the retention period the audit policy requires and IAM access limited to the audit team. Disabling trace in production to protect prompts destroys the very evidence auditors need.
Live progress without exposing internals
Trace parts stream as orchestration progresses, so a backend can show progress while a step runs. Map each step's invocationInput (which action group or knowledge base is starting) to a pre-approved status line such as "Looking up your booking", rather than displaying the raw rationale. The agent's streamFinalResponse setting only streams the final answer text as it is generated; it says nothing while an action group or knowledge base call is in progress.
How should an application show users an explanation of an AI output?
A user-facing explanation should be a deliberate, validated output that describes the real basis of the result, not the model's raw reasoning. Two failure modes drive the design: raw reasoning can contain speculation and unvetted wording, and a model asked to explain itself can describe steps it never took.
| Source of the explanation | Faithful to what happened? | Safe to show users? |
|---|---|---|
Extended reasoning content blocks returned by Converse (reasoningContent) | Not guaranteed; it is the model's working text | No; log it for internal review |
Agent trace rationale text | Model text about its choice; may be phrased loosely | No, unless vetted; keep it for engineers |
| A schema-bound explanation field (for example a JSON field listing decision factors) validated by code | As faithful as the factors it is checked against | Yes, after validation |
An explanation the backend builds from trace invocationInput and observation records, then lets the model reword | Yes: it lists only steps that ran | Yes |
| A fixed paragraph about how decisions are made in general | Not specific to the outcome | Yes, but it explains nothing about this result |
For a decision such as an insurance claim triage result, ask the model for structured output that includes a dedicated explanation field (required by a JSON schema), validate it in code (allowed factors, no unapproved wording), and display only that field, while the full reasoning goes to an internal log. For an agent, the most faithful explanation is built from the trace: the backend collects the invocation inputs and observations of the current turn and lets the model only phrase those facts in friendly language. Keep in mind what each tool controls: temperature controls how variable the wording is, not whether it is true; a contextual grounding check measures whether claims are supported by reference passages, not which actions ran; and a guardrail assessment records why content was filtered, which is not the basis of a business decision.
How do you present evidence and source attribution for generated answers?
Source attribution means each claim in an answer links to the specific retrieved passage that supports it, using data your application recorded rather than sources the model writes itself. Model-written source lists are where fabricated citations come from.
Amazon Bedrock Knowledge Bases citations
The RetrieveAndGenerate response includes a citations array. Each citation has a generatedResponsePart (the text and its span within the answer) and retrievedReferences (the chunk content, its location such as the S3 URI, and its metadata). Rendering these as footnotes on the matching span gives evidence for each part of the answer with no extra calls. A separate Retrieve call shows what was found but loses the mapping between text spans and sources, and a contextual grounding score is a number, not a source.
Linking to the original document, not the bucket
If documents are synced from another system (a content management system, a ticketing tool) into a private S3 bucket, the S3 URI is useless to users and must not be made accessible. For an S3 data source, add a <file>.metadata.json sidecar with custom metadataAttributes, such as the original page URL. After ingestion, those attributes come back in retrievedReferences[].metadata on every citation, so the interface links to the original page, where the source system applies the user's own permissions. The principle is to keep the source system as the place that decides who may open a document: anything that hands users direct access to the synced copy in S3 sidesteps those permissions, and any link the model writes from memory is a guess rather than a record.
Custom RAG pipelines
When you retrieve with your own code (for example from Amazon OpenSearch Service or Aurora PostgreSQL with pgvector) and generate with the Converse API, build attribution yourself: give each retrieved passage an identifier in the prompt, require structured output that maps each claim to passage identifiers, and validate in code that every identifier belongs to this request's retrieval set before turning it into a link from stored metadata. The model can still cite the wrong passage within the set, but it can no longer cite a document that was never retrieved. Dumping all retrieved passages beneath the answer shows evidence but does not attribute any claim.
How do you measure confidence and disclose uncertainty with CloudWatch?
Confidence in an FM answer should be measured from observable signals, published to Amazon CloudWatch as custom metrics, and used to decide what the user sees. A model's statement about its own confidence ("I am 90% sure") is self-report and is not a measurement.
Signals that measure uncertainty
| Signal | What it measures | Valid? |
|---|---|---|
| Contextual grounding and relevance scores from a guardrail assessment | How well the answer is supported by the reference passages and how relevant it is to the query | Yes: an independent measurement |
| Retrieval relevance scores | Strength of the evidence found for the question | Yes: evidence strength |
| Self-consistency agreement: sample several answers at a moderate temperature and measure how often they agree | Model stability on the question; low agreement means high uncertainty | Yes, and it works when the API returns no token probabilities |
| Self-rated confidence in the answer text | What the model claims | No |
| Identical answers at temperature 0 | Determinism, not correctness | No |
| Output length | Verbosity | No |
Default Amazon Bedrock and guardrail metrics (invocations, latency, errors, interventions) are operational; they say nothing about how well each answer is grounded. To trend grounding over time, set the contextual grounding check to detect (action none) or read the assessment even when blocking is on, and publish each grounding and relevance score as a custom metric. A dashboard then shows the trend, and an alarm on a low percentile or on the share of answers below a threshold flags degradation.
Publishing at volume: the embedded metric format
From a Lambda function handling thousands of requests a minute, write metrics with the CloudWatch embedded metric format (EMF): structured log lines that CloudWatch turns into metrics with no PutMetricData calls. Choose dimensions with few values (use case, model ID, prompt version) so graphs and alarms aggregate cleanly, and write high-cardinality values such as the request ID as a property: it lands in CloudWatch Logs, where Logs Insights finds the exact request behind a low score, without creating a separate metric per request.
Calibrating thresholds
A confidence threshold picked by intuition means nothing. If a "verified" label must meet a stated accuracy target for labelled answers, run the scoring on a labelled question set, measure accuracy in each score band (publishing per-band accuracy as a metric), and set the threshold at the lowest band that meets the target. A new model changes how scores relate to correctness, so repeat the calibration for each model version. A threshold means something only when it is tied to measured correctness; any change that moves scores or alerts without that labelled comparison leaves the label's promise unverified.
Streaming caveat: with streaming output, the contextual grounding check evaluates the response in chunks, and AWS notes that relevance is judged per chunk, so an irrelevant response can reach the user before it is flagged. Where the disclosure must come before the user reads the answer, evaluate the complete response first.
Telling the user when the evidence is weak
Transparency includes saying "I could not find support for this". Three patterns cover most policies:
- Abstain before generating. Compare the best retrieval score with the policy's threshold in code; if nothing passes, skip generation, return an honest no-support message with a route to a person who can help, and count the abstention as a metric. The decision rests on a measured threshold applied in code; anything that still produces an answer without supporting passages, or that leaves the decision to the model, gives up that guarantee.
- Explain a guardrail block. A guardrail has two configurable messages: one for blocked prompts (
blockedInputMessaging) and one for blocked responses (blockedOutputsMessaging). The contextual grounding check evaluates the response, so the response message is the one users see when it intervenes; rewriting it to say the answer could not be confirmed and where to go instead is a configuration change, not a code change. - Tiered disclosure. Block mode is a single cut-off: the answer is returned or replaced. A policy with several tiers (withhold below one score, show with a warning between two scores, show normally above) needs the numeric score, so set the check to detect, read the score from the guardrail assessment, and apply the thresholds in the application. Any arrangement built only from block decisions yields pass or replace, never "show with a warning".
How do you test an FM for bias with counterfactual evaluations?
A counterfactual fairness test sends prompts that are identical except for one demographic signal (a name, dialect, gender or background) and compares the business outcome and tone across the variants. If only that signal changed, any systematic difference is attributable to it. This is the evidence a responsible AI board needs before launch; toxicity sampling of past transcripts, general-knowledge benchmarks and jailbreak suites measure different properties.
Rules for a test whose results you can defend
- Vary one thing only. Income, tenure, postcode and every other field stay identical within each pair. Making each variant "realistic" for its group adds confounders.
- Use several signals per group. Many names associated with each group, so one name's particular associations do not drive the result.
- Use synthetic cases. Real applicants' records with a group inferred from the name are not counterfactual pairs, and inferring protected attributes may break privacy policy.
- Control sampling noise. Generate several responses per prompt and compare score distributions (with a significance test), not single generations.
- Control version drift. Run both halves of each pair against the same prompt version and model version in one test run, and score them with the same judge. Different days, prompt updates or different judges are confounds.
Measuring is different from mitigating. Masking names with a sensitive information filter or blocking demographic words with a denied topic may reduce one route to bias, but it measures nothing, and removing the signal from a counterfactual test defeats the test.
How do you track fairness metrics in Amazon CloudWatch?
Fairness monitoring in production publishes outcome metrics per group as CloudWatch custom metrics (a dimension for the group or cohort) and alarms on the disparity between groups with metric math. An overall average, or an anomaly band on it, can stay flat while one group is treated worse.
Probe-based monitoring
When policy forbids storing or inferring real users' protected attributes, measure with synthetic probes: a fixed set of counterfactual cases run through the production prompt and model on a schedule (for example a Lambda function invoked by Amazon EventBridge Scheduler), publishing per-group results. Add the prompt version and model ID as dimensions so that a change in disparity can be correlated with a deployment. Per-user identifiers as dimensions create high-cardinality metrics that answer nothing.
Turning a fairness rule into an alarm
| Policy | What to publish | Alarm |
|---|---|---|
| Gap between cohort average scores must stay under a set number of points | One average-score metric per cohort | Metric math, such as the absolute difference between cohorts (or MAX minus MIN), against the threshold |
| Lowest group's approval rate must be at least a set fraction of the highest group's (for example the four-fifths rule) | Per-group counts: approved and evaluated | Metric math computes each rate as sum of approvals over sum of evaluations, then MIN over MAX; alarm when the ratio is below the fraction for the required number of consecutive periods (M of N datapoints) |
Publishing counts rather than pre-computed rates matters when some groups have few samples in a period: rates computed from summed counts are weighted correctly, while averaging small-sample rates is not. A per-group alarm against that group's own history detects drift, not disparity; an average across all groups hides the gap.
How do Prompt Management and Bedrock Flows support systematic A/B testing?
Systematic A/B testing of prompt variants (for example a variant written to reduce stereotyped language) needs three things: variants that cannot change during the test, a controlled split of traffic, and results recorded per variant. Amazon Bedrock Prompt Management and Amazon Bedrock Flows (formerly Prompt Flows) provide the first two as configuration.
Prompt Management versions
A prompt has a working draft that authors edit, and versions: immutable snapshots of the template and its configuration. A version can be invoked directly by passing its ARN as the modelId in Converse or InvokeModel, or referenced from a Flows prompt node. That lets you run every variant against the same test inputs, re-run exactly the same variant months later, and switch production to the winner by changing configuration rather than code. The value lies in immutability plus a built-in record of what each version contained; any mechanism where the text can change in place loses that.
Flows versions and aliases
| Reference | Changes when authors edit? | Use for |
|---|---|---|
| Prompt node pointing at the prompt's draft | Yes | Development only |
| Prompt node pointing at a prompt version | No | Each arm of a running test |
Flow test alias (TSTALIASID) | Yes: it tracks the flow's working draft | Testing in the console |
| Flow version invoked through a flow alias | No; moving the alias to another version switches traffic | Production, and switching to the winner without a deployment |
Inline prompts copied into prompt nodes give up the prompt versioning that makes the test reproducible.
Splitting traffic consistently
To send a share of users to the new variant and keep each user on the same variant, hash a stable user ID into buckets in the application, pass the bucket into the flow as input, and route with a condition node to the prompt node bound to the test version. Emit the variant as a CloudWatch dimension so fairness metrics separate by arm. A valid A/B test needs both arms live at once, assignment decided by your code rather than the model, and assignment that stays the same for a user across requests.
How do Amazon Bedrock LLM-as-a-judge evaluations measure bias and harm?
An LLM-as-a-judge evaluation is an Amazon Bedrock model evaluation job in which a second model (the evaluator, or judge) scores each response from the model under test against selected metrics. It needs no human raters, runs on your own prompt dataset, and suits automated checks before each release.
Built-in metrics for responsible AI
| Metric | Scores |
|---|---|
Builtin.Stereotyping | Whether a response contains stereotypes of any kind |
Builtin.Harmfulness | Whether a response contains harmful content |
Builtin.Refusal | How evasive the response is, or whether it declines to answer |
Quality metrics such as Builtin.Correctness, Builtin.Completeness, Builtin.Helpfulness, Builtin.Faithfulness | Answer quality; Faithfulness concerns staying true to supplied context |
Responsible AI metrics trade off against each other. A prompt change that cuts stereotyping can cause over-refusal: legitimate questions that mention a protected characteristic (for example a question about accessibility support for disabled travellers) get declined, and both Stereotyping and Harmfulness give a refusal a good score. Track Refusal alongside them to see whether a fix traded one harm for another. You can also define custom metrics with your own judge prompt and rating scale.
The dataset
Each JSONL record holds prompt, an optional referenceResponse (ground truth for correctness-type metrics) and an optional category. Scores are reported per category, so one job can give results per customer segment; splitting the dataset into one job per segment only adds work.
Judging responses you generated elsewhere
To evaluate a model that is not in Amazon Bedrock (for example on a SageMaker AI endpoint) without importing it, generate the responses yourself and supply them in each record's modelResponses (the response plus a modelIdentifier). Bedrock then skips inference and the judge scores the supplied responses. Such a dataset supports one response per prompt and a single unique modelIdentifier, so comparing two models takes one job per model, and you compare the reports.
Keeping scores comparable over time
A judge score depends on the judge. If the evaluator model changes between releases, a score change mixes the product change with the judge change. To attribute it, re-score the previous release's saved responses with the new evaluator (as your own inference responses) and compare both under that evaluator; for trend reporting, keep the evaluator model, its version and the dataset fixed, and re-baseline whenever the evaluator changes. The metric name being the same does not make the scale the same.
Match the tool to the property you need to measure: human-based evaluation jobs use a work team of people as raters; SageMaker Clarify pre-training bias metrics describe imbalance in a training dataset rather than in generated text; guardrails act on content at request time rather than scoring a release.
How do you turn responsible AI policy into Amazon Bedrock guardrails and enforce them?
A policy-compliant AI system translates each written policy rule into the guardrail policy type that detects that kind of content, then makes the guardrail impossible to skip. Choosing the wrong policy type is the usual mistake.
| Policy rule | Guardrail policy | Why not the near-twin |
|---|---|---|
| Never give a class of advice (legal advice on a specific dispute, tax-filing advice), however phrased | Denied topic: a natural-language definition plus sample phrases, detected semantically | A word filter matches exact strings, misses paraphrases and over-blocks; content filter categories (such as misconduct) cover other harms |
| Never reveal an identifier with a known format (account number) | Sensitive information filter with a regex entity, masking or blocking in output | A word list of real values is unmaintainable and itself sensitive |
| Statements must be supported by supplied documents | Contextual grounding check with a threshold | A denied topic would stop the whole subject |
| Harmful content (hate, insults, sexual, violence, misconduct) | Content filters with a strength per category | The prompt attack filter addresses manipulation, not output harms |
Define denied topics positively. Describe what to block ("advice on how to resolve a specific legal dispute"), not "all legal questions except questions about our terms of service". AWS advises against exceptions and negative phrasing in definitions; they cause both over-blocking of allowed requests and under-blocking of prohibited ones. Sample phrases teach what to block, not what to allow.
Enforcing the guardrail with IAM
The bedrock:GuardrailIdentifier condition key lets a policy deny InvokeModel, InvokeModelWithResponseStream, Converse and ConverseStream unless the request names the approved guardrail. The ARN pattern decides which versions match:
| Pattern in the condition | Matches |
|---|---|
…:guardrail/ID (bare ARN) | The DRAFT version only |
…:guardrail/ID:1 | Version 1 only |
…:guardrail/ID:* (with ArnLike / ArnNotLike) | Any numeric version, not the draft |
…:guardrail/ID* | Any version, including the draft |
A Deny that should allow future published versions but refuse the draft therefore uses ArnNotLike with the :* pattern.
Known limitation: AWS documents that a role restricted this way should not also call RetrieveAndGenerate, InvokeAgent or InvokeInlineAgent. Those APIs make several internal InvokeModel calls, some without the guardrail, so they are denied even when the request names it. Use a separate role without the condition for that workload and set the guardrail in its request (for example in the RetrieveAndGenerate generation configuration). The condition key can only test a guardrail that the call carries, so internal calls without one always fail the condition.
Selective input evaluation: when a prompt contains guardrail input tags (or guardContent blocks in Converse), only the tagged content is evaluated on input. Tagging your fixed instructions and leaving user text outside the tags means user input is never assessed, while responses are still filtered. Tag the user input, or don't tag selectively.
How do model cards and Lambda compliance checks document limitations and enforce policy?
Model cards document what a model is for and where it fails; Lambda functions enforce the rules a guardrail cannot express. Together with guardrails they make responsible AI policy checkable.
SageMaker Model Cards vs AWS AI Service Cards
| Amazon SageMaker Model Card | AWS AI Service Card | |
|---|---|---|
| Written by | You, for your use of a model (including a Bedrock FM) | AWS, about its own service or model (for example Amazon Nova models) |
| Contents | Intended uses and out-of-scope uses, risk rating (unknown, low, medium, high), evaluation results (such as your bias evaluations), ethical considerations, caveats and limitations | AWS's intended use cases, limitations, responsible AI design choices and deployment guidance |
| Governance features | Approval status (Draft, PendingReview, Approved, Archived); content edits create new versions, giving an immutable history; export to PDF | Public documentation; your own record usually cites it |
Tags or a prompt description field lack this structure and history; AWS Artifact reports cover infrastructure compliance, not model behaviour. The model card's approval status can become a preventive control: a release pipeline stage (for example in AWS CodePipeline) invokes a Lambda function that calls DescribeModelCard and fails the release unless the status is Approved. Note the distinction between preventive controls, which stop a non-compliant release before it ships, and detective controls such as AWS Config rules, which report noncompliance after the fact; and keep fields apart: the risk rating describes how risky the use is, while the approval status records whether it was signed off.
Automated compliance checks with Lambda
Guardrails detect and block unwanted content. They cannot enforce that something must be present (an AI-generated content notice, a jurisdiction-specific risk warning), that a value exactly equals a system of record (a quoted fee that must match the pricing database), or rules that need a lookup, a log entry with expected and actual values, or routing to human review. Those need code in the response path:
- A post-processing Lambda function checks each draft response before it is returned, then appends, blocks or replaces it as policy says, and logs each violation to CloudWatch Logs or a compliance store. It runs alongside any guardrail, not instead of it.
- In an Amazon Bedrock flow, a Lambda function node after the prompt node runs the check (reading reference data such as disclosures from DynamoDB, logging failures, queueing them for review), and a condition node routes on its result: failures to an output carrying a holding message, passes to the main output.
The general principle: instructions and extra context make compliance more likely, but only deterministic code that compares the response with the rule verifies it. A contextual grounding check is probabilistic support scoring, so a near-miss value can still score as grounded; a model reviewing its own output is self-assessment; masking removes information rather than checking it; and any analysis run over logs later is detective, finding violations after users have seen them.
Tip. Task 3.4 questions describe a GenAI application whose answers must be explainable, fair or policy compliant, and add constraints such as no custom code, prompts that must stay confidential, a private bucket, no stored protected attributes, sticky per-user test arms, an exact value from a system of record, or scores that must stay comparable over time. Wrong options are usually real AWS features aimed at the wrong question: CloudTrail or X-Ray where an agent trace is needed, model self-report where a measurement is needed, an overall average where a per-group disparity is needed, a draft or test alias where a pinned version is needed, a guardrail where a presence or equality check needs code, or a detective control where a blocking one is required. Expect near-twins that differ in one detail (blocked-input versus blocked-response message, ARN patterns with and without a colon, dimension versus property in EMF) and multiple-response items that pair two complementary actions.
- Set enableTrace on InvokeAgent for reasoning traces; collaboratorName and callerChain attribute steps across collaborating agents.
- Traces contain prompts: keep them server side, persist them to encrypted, retained, access-controlled storage, and show users only vetted or mapped text.
- Faithful explanations come from recorded steps or validated schema fields, never from raw reasoning or a model describing itself.
- Cite from RetrieveAndGenerate citations or validated passage IDs; store original URLs as metadata attributes to link users to the source system.
- Confidence is measured (grounding, retrieval and self-consistency scores), published with EMF using low-cardinality dimensions, and calibrated per model version.
- Counterfactual tests vary one signal, use many signals per group, sample repeatedly and run both halves on the same versions.
- Fairness alarms use per-group metrics and metric math on the gap or ratio between groups, not an overall average.
- Pin A/B arms to prompt versions and serve flows through aliases; hash user IDs for sticky splits and tag metrics by variant.
- LLM-as-a-judge offers Stereotyping, Harmfulness and Refusal metrics, per-category scores, and bring-your-own responses with one model identifier per job.
- Guardrails block content; Lambda checks enforce required content and exact values; SageMaker Model Cards record your model's limitations and approval status.
Frequently asked questions
How do I see why an Amazon Bedrock agent took an action?
Set enableTrace to true on the InvokeAgent request. The response stream then includes trace parts whose orchestration trace contains the rationale for each step, the invocation input (which action group or knowledge base was called, with what parameters) and the observation that came back. In multi-agent collaboration, collaboratorName and callerChain identify which agent produced each step. Store the full trace server side, because it includes prompt text.
Can I show a model's extended reasoning to end users as an explanation?
It is not a good idea for regulated or customer-facing decisions. Reasoning content is the model's unvetted working text and is not guaranteed to be a faithful account of how the answer was produced. Ask for a separate, schema-bound explanation field that you validate in code, or build the explanation from recorded steps such as agent trace invocation inputs and observations, and keep raw reasoning in internal logs.
How do I make Bedrock Knowledge Bases citations link to the original document instead of S3?
Add a metadata sidecar file (<file>.metadata.json) next to each document in the S3 data source, with a custom attribute holding the original URL. After ingestion, the attribute is returned in the metadata of each retrieved reference in the RetrieveAndGenerate citations, so your interface can link to the source system, which applies its own permissions, while the bucket stays private.
How can I quantify uncertainty when the model API returns no token probabilities?
Use observable signals: sample several answers at a moderate temperature and measure how often they agree (self-consistency), and use evidence strength such as retrieval relevance and contextual grounding scores. Publish them as CloudWatch custom metrics, calibrate the threshold against a labelled question set, and repeat the calibration for each model version. A confidence percentage the model states about itself is not a measurement.
What is a counterfactual fairness test for a foundation model?
It sends prompts that are identical except for one demographic signal, such as a name or dialect, and compares outcomes and tone across the variants. To be defensible it uses synthetic cases, several names per group, several samples per prompt compared as distributions, and the same prompt, model and judge versions for both halves of each pair.
How do I alarm on bias in CloudWatch?
Publish metrics per group, using a dimension for the group, and use metric math to compute the disparity: for example the difference between cohort averages, or the ratio of the lowest group's rate to the highest group's rate computed from summed counts. Alarm on that expression, with M-of-N datapoints if the policy requires a sustained breach. Add prompt version and model ID dimensions to tie changes to deployments.
Which Amazon Bedrock evaluation metrics measure bias?
In LLM-as-a-judge model evaluation jobs, the built-in Stereotyping metric scores whether responses contain stereotypes and Harmfulness scores harmful content. Add the Refusal metric to catch over-refusal, which can appear when a fix for bias makes the model decline legitimate questions. Add a category field to dataset records to get scores per segment from one job.
What is the difference between a SageMaker Model Card and an AWS AI Service Card?
An AWS AI Service Card is documentation AWS publishes about its own service or model, covering intended uses, limitations and responsible AI design choices. A SageMaker Model Card is the record you write about your use of a model: intended and out-of-scope uses, risk rating, evaluation results and limitations, with an approval status, version history and PDF export. Your model card often cites the service card.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.