Checking Generative Output for Quality, Safety and Bias
This lesson explains how generative AI outputs are checked for content quality, safety and bias before release, which the exam guide groups under AI evaluation.
Learning outcomes
After completing this lesson, you will be able to:
- Validate content quality such as format and tone.
- Measure toxicity and robustness.
- Detect bias in generated output with counterfactual tests.
Content quality validation
Content quality covers several properties. Format includes valid JSON, required sections and length limits. Language and tone include brand voice, reading level and responding in the correct language. Accuracy is measured against sources, and policy compliance covers prohibited advice and required disclaimers.
Different checks suit different properties: programmatic checks handle format and length cheaply and reliably, while LLM judges and guardrails handle tone and policy. Outputs that fail can be regenerated, repaired automatically or blocked before they reach users.
Check the output
Safety and toxicity
Amazon Bedrock programmatic evaluations include toxicity metrics and robustness metrics, which measure whether small changes to the input, such as typos, change the output, and judge-based metrics include harmfulness. Red-teaming with adversarial prompts tests whether the model can be pushed into unsafe output or manipulated through prompt injection.
At run time, Amazon Bedrock Guardrails enforce safety policies on every request and response. The rate at which guardrails intervene is itself a useful quality signal: a rising rate can indicate a change in user behaviour, an attack or a regression in the model or prompt.
Safety checks
Bias detection in generative output
Generative bias appears as stereotypes, unequal quality across groups or different recommendations for equivalent requests. Detect it with counterfactual (paired) prompts that differ only in a demographic attribute, such as a name or pronoun, and compare outputs and scores. SageMaker Clarify foundation model evaluations (built on the open-source fmeval library) and Bedrock evaluations include prompt stereotyping datasets that measure whether a model prefers stereotypical sentences. The following table summarises the checks.
| Check | Method |
|---|---|
| Format and length | Programmatic validation (schema, regex, length) |
| Tone and policy | LLM judge with rubric, guardrail denied topics |
| Toxicity and harm | Toxicity metrics, harmfulness judge, Guardrails content filters |
| Robustness | Perturbed prompts; robustness metrics |
| Stereotyping and unequal treatment | Paired prompts, Clarify FM evaluations, stereotyping datasets |
The following diagram shows the checks used to find biased language in an HR assistant's drafts and their effect.

A job-description assistant
An HR assistant drafts job descriptions. Before launch, the team checks for biased language and unequal quality.
- Generate descriptions for 200 roles twice, with prompts that differ only in the hiring manager's stated preference wording, and compare gendered-language counts.
- Run a Clarify FM evaluation for prompt stereotyping on the chosen model.
- Use a judge to flag exclusionary phrases ("young and energetic") against a rubric; add a guardrail word filter for known terms.
The checks find age-related phrasing in 7% of drafts; a revised system prompt and a word filter bring it below 0.5%. Measuring only fluency or ROUGE would never have revealed this problem.
How do paired prompts reveal bias?
Show answer
Prompts that differ only in a group attribute, such as a name, should get equivalent responses; differences show stereotyping or unequal treatment.
Exam Tips
Remember for the exam
- Validate format and length programmatically before release.
- Paired prompts reveal stereotyping and unequal treatment.
- Clarify FM evaluations and Bedrock evaluations measure stereotyping and toxicity.
- Red-team with adversarial prompts before launch.
- Guardrail intervention rates are a production quality signal.