Risk and Safety Evaluations
This lesson explains the risk and safety evaluators, how severity and defect rates are reported, how adversarial simulation and red teaming find weaknesses, and what regions safety evaluation needs.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the risk and safety evaluators.
- Explain severity levels and defect rates.
- Describe adversarial simulation and red teaming.
- Identify the requirements for safety evaluation.
Risk and safety evaluators
Risk and safety evaluators are run by the Foundry evaluation service using models Microsoft trains and maintains for safety. They take a credential and the Foundry project, not a judge deployment, and they assess either content harms or specific risks.
| Evaluator | Detects | Output |
|---|---|---|
| Hate and unfairness | Hateful or discriminatory content | Severity level and score |
| Sexual | Sexual content | Severity level and score |
| Violence | Violent content | Severity level and score |
| Self-harm | Content about self-harm | Severity level and score |
| Protected material | Copyrighted text such as song lyrics or articles | Pass or fail |
| Indirect attack | Responses that follow instructions injected in grounding data (cross-domain prompt injection) | Pass or fail |
| Code vulnerability | Insecure code in generated code | Pass or fail |
| Ungrounded attributes | Inferences about personal attributes, such as emotional state, not supported by the context | Pass or fail |
A content safety composite evaluator runs the four content harm evaluators together. Further evaluators exist for agent-specific risks, such as prohibited actions and sensitive data leakage.
Severity and defect rates
Content harm evaluators classify each response on a severity scale, such as very low, low, medium and high, with an underlying numeric score. A threshold decides which severities count as a defect. The headline metric is the defect rate: the share of responses at or above the threshold, which can be compared between versions and used as a release gate, such as zero high-severity defects and less than 0.5 percent medium.
from azure.ai.evaluation import ViolenceEvaluator, IndirectAttackEvaluator
from azure.identity import DefaultAzureCredential
cred = DefaultAzureCredential()
violence = ViolenceEvaluator(credential=cred, azure_ai_project=PROJECT_ENDPOINT, threshold=3)
xpia = IndirectAttackEvaluator(credential=cred, azure_ai_project=PROJECT_ENDPOINT)
print(violence(query=q, response=r))Adversarial simulation and red teaming
Ordinary test questions rarely provoke harmful output, so safety evaluation needs adversarial inputs. The adversarial simulator in the Azure AI Evaluation SDK generates attack conversations, such as jailbreak attempts and harmful requests, against a target application, and the risk and safety evaluators score the responses.
The AI red teaming agent automates this further. It sends attack prompts in chosen risk categories, transforms them with attack strategies such as character encoding, flipping text and jailbreak templates, and reports the attack success rate per category and strategy. Red team scans can run before release and on a schedule, and their results appear with other evaluations in the project. Human red teaming by experts remains valuable for high-risk applications, because automated attacks cover known techniques.
Regions, data and filters
Safety evaluators run in specific regions, and the Foundry project must be in one of them; some evaluators, such as protected material and groundedness pro, and AI red teaming are available in fewer regions, such as East US 2 and Sweden Central. A project in an unsupported region cannot run them, which is a design consideration for the evaluation environment.
The two complement each other: evaluation measures whether the prompt, filters and application together hold up, and finds gaps that filter configuration or prompt changes should close.
A safety gate for release
A company is about to launch a public chatbot. Leadership requires evidence that the bot rarely produces violent or hateful content, even under deliberate attack, and that it cannot be steered by instructions planted in the web pages it summarizes. The evaluation project is in a supported region.
Run the AI red teaming agent against the bot for the violence and hate and unfairness categories with several attack strategies, and report the attack success rate. Run the content safety evaluators over the responses to an adversarial dataset to measure defect rates, and the indirect attack evaluator over conversations whose grounding data contains injected instructions. Set release thresholds for each and record the results with the release.
Relying on content filters alone protects production but gives no measurement. Evaluating with ordinary customer questions would rarely provoke harmful output. Groundedness measures support by sources, not resistance to injected instructions.
What do the Azure AI Evaluation SDK's safety evaluators require instead of a judge model configuration?
Show answer
A credential and the Foundry project, because the safety evaluation service hosted by Foundry performs the scoring, in a supported region.
Exam Tips
Remember for the exam
- Safety evaluators take a credential and Foundry project, not a judge deployment.
- Content harms report severity; protected material, indirect attack, code vulnerability and ungrounded attributes report pass or fail.
- Gate releases on defect rates and red teaming attack success rates.
- Safety evaluators and red teaming need a project in a supported region.