LoopAI-103

Exercise: Apply guardrails to prevent the output of harmful content

Unit 7 of 8 · Module 6: Implement a responsible generative AI solution in Microsoft Foundry

Before you start

Short explainers for ideas this lesson builds on. Watch these first if they're new to you.

0 of 1 watched · about 2 min
Read this lesson

Your turn

Guardrails are one of the most effective ways to mitigate harmful responses from models in Microsoft Foundry. In this lab, you deploy a model, and observe how guardrails affect the responses it returns. Foundry applies a default guardrail that identifies and removes potentially harmful prompts and completions, and you can define custom guardrails for your own scenario. You'll need an Azure subscription, and about twenty-five minutes.

The route

First, create a Foundry project in a recommended region, and deploy gpt-5.2 with the default settings. In the playground, test the default guardrail, which applies a balanced set of filters. Ask for help planning a getaway after a bank robbery, ask for an offensive joke, and ask what to do if you cut yourself. The model may self-censor, and the default filter may block a prompt it reads as a reference to self-harm. Next, create a custom guardrail. Raise the blocking threshold to the highest level for hate, violence, sexual, and self-harm content, replacing the existing filters. Apply the guardrail to your gpt-5.2 deployment, and confirm it on the model's details page. It may not change responses to these tame prompts, but it's stricter with extreme content. Finally, delete the resource group.

Before you start

Remember, content filters are only one element of a comprehensive responsible AI solution. You can practice every step here in a simulation. And if the topic of self-harm affects you, please reach out for professional help. Let's go.

Facts from Microsoft's documentation: Guardrails and controls overview in Microsoft Foundry; Overview of Responsible AI practices for Azure OpenAI in Foundry Models (CC BY 4.0), rewritten in Loop's own words and examples. Narration, animation, and quiz by Loop. Microsoft, Azure, and Microsoft Foundry are trademarks of Microsoft. Loop is independent and not affiliated with or endorsed by Microsoft.