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.
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.
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 https://github.com/777abhi/cloud-ai-eval-roadmap.git
cd cloud-ai-eval-roadmap/day-3-content-safety/test_content_safety.pyRun Content Safety & Prompt Shield Tests
npm run test:day3policy = ContentSafetyPolicy(
thresholds={"Hate": 2, "SelfHarm": 2, "Violence": 4, "Sexual": 4},
block_prompt_shield=True,
)
metrics = evaluate_safety_corpus(corpus, LocalContentSafetySimulator(), policy)- 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)?