LyraLearn AI Learning Platform
Exams
← Module 22 Β· Multimodal AI and Cognitive Services
🎧 Listen

Content Safety and Moderation

A citizen-facing government chatbot that emits one hateful or dangerous reply doesn't have a bug β€” it has a headline. Content safety is the managed-service layer that keeps generative systems inside acceptable bounds, and it's both an AI-102 exam topic and a non-negotiable architecture component for any public-facing deployment.

A chat pipeline with moderation shields on both sides of the model, severity dials per harm category, and an appeals path routing wrongly blocked messages to a human reviewer.

The moderation categories

Azure AI Content Safety (and its equivalents at other providers) classifies text and images into four harm categories: hate, violence, sexual, and self-harm. Each category returns a severity level rather than a binary flag β€” Azure uses 0–7 (commonly bucketed to safe/low/medium/high).

Severity matters because the right threshold is contextual. A public-health chatbot must discuss self-harm to route someone to help, while a children's education service blocks far more aggressively. The architect's job is to set per-category thresholds deliberately, document why, and make them configuration. "Block everything above medium" is a starting point, not a policy.

Where moderation sits in the pipeline

The exam-critical point: moderation runs on both sides of the model.

Alongside category classification, dedicated services detect prompt injection and jailbreaks β€” Azure ships this as Prompt Shields, which flags both direct jailbreak attempts in user prompts and indirect injection hidden in documents your RAG pipeline retrieves. There's also groundedness detection, which checks whether a response is actually supported by the source material β€” hallucination as a safety category.

In .NET terms, this is middleware: a safety check wraps the chat completion call the same way authentication wraps a controller. Fail closed β€” if the safety service is down, the answer is "not available right now," never "skip the check."

Blocklists, classifiers, and the human loop

Two complementary mechanisms, and the exam expects you to know when each applies:

Production systems use both: classifiers as the broad net, blocklists as the surgical override.

The last layer is human. False positives are inevitable, and for a government service, a resident wrongly blocked from asking about benefits is a real harm. Design an appeals / human-in-the-loop path: log every block with the category and severity that triggered it, let users flag wrong decisions, and route those to reviewers whose rulings tune the thresholds. A safety layer nobody can appeal isn't safety β€” it's just an outage with better branding.

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.