HomeRoadmapsCloud AI Eval Day 3
Cloud AI Evaluation & Azure AI Foundry QE ยท Day 3 ยท 20 min

Content Safety & Guardrail Boundaries
Cloud AI Evaluation & Azure AI Foundry QE โ€” Day 3

Test Azure AI Content Safety 0/2/4/6 severity thresholds across Hate, Self-Harm, Violence, and Sexual categories plus Prompt-Shield jailbreak detection, measuring FPR and FNR.

โšก Runtime: Python 3.10+ ยท Offline Azure AI Foundry Simulators (unittest)๐Ÿ›ก๏ธ Cloud AI Evaluation & Foundry QE Architect
Content SafetyPrompt ShieldsSeverity 0/2/4/6FPR/FNRGuardrails
About this lab

Over-aggressive filters block legitimate financial support queries like โ€œterminate my policyโ€ or โ€œdispute a fraudulent chargeโ€ (high FPR), while loose thresholds miss jailbreaks and high-severity harmful prompts (high FNR). Today you will tune 0/2/4/6 severity thresholds and verify zero false negatives on a labeled safe-vs-unsafe corpus.

๐Ÿ“ฆSample Codebase & Working Solution (Day 3)Available Now
View on GitHub

The official reference codebase for Day 3 is hosted in the repository. Clone the repository and navigate to day-3-content-safety/test_content_safety.py to run the working solution.

Git Clone โ€” Working Solution
git clone https://github.com/777abhi/cloud-ai-eval-roadmap.git
cd cloud-ai-eval-roadmap/day-3-content-safety/test_content_safety.py
๐ŸญProduction Context & Enterprise Implementation
๐Ÿ’ก Why We Are Doing This: Regulated consumer assistants must block prompt-injection exfiltration and severe safety violations without breaking everyday claims and billing-dispute workflows.
๐Ÿข Real-World Production Usecase: Continuous red-team and guardrail regression suites targeting Azure AI Content Safety & Prompt Shields.
โš™๏ธ How Implemented in Production: LocalContentSafetySimulator scores 0/2/4/6 bands across Hate, SelfHarm, Violence, Sexual + PromptShield; evaluate_safety_corpus reports precision, recall, FPR, and FNR.
Phase 1

Run Content Safety & Prompt Shield Tests

Step 1.1: Execute Day 3 Suite
Terminal โ€” Day 3 Lab
npm run test:day3
Step 1.2: Policy Thresholds & Corpus Evaluation
cloudaieval/safety.py
policy = ContentSafetyPolicy(
    thresholds={"Hate": 2, "SelfHarm": 2, "Violence": 4, "Sexual": 4},
    block_prompt_shield=True,
)
metrics = evaluate_safety_corpus(corpus, LocalContentSafetySimulator(), policy)
Day 3 Key Learnings
  • Configured per-category 0/2/4/6 severity thresholds aligned to Azure AI Content Safety.
  • Blocked jailbreak and system-prompt exfiltration attempts via Prompt Shield rules.
  • Measured false-positive rate (FPR) on benign financial queries alongside false-negative rate (FNR) on attacks.

๐Ÿง  Knowledge Check

Why must Content Safety QE suites measure both False Positive Rate (FPR) and False Negative Rate (FNR)?