AI-102 Implement generative AI solutions Practice Question
Exhibit
{
"role": "system",
"content": "You are an AI assistant that generates code. When asked to write code, always include comments explaining the code. If the user asks for something harmful, refuse and suggest an alternative."
}Refer to the exhibit. You are configuring a system message for an Azure OpenAI deployment. The assistant is still generating harmful code despite the instruction. Which additional measure should you implement?
⚠ Common exam trap
Candidates often assume prompt engineering (system messages or few-shot examples) is sufficient for safety, but Azure OpenAI requires explicit content filtering via Azure AI Content Safety to reliably block harmful outputs at scale.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Enable Azure AI Content Safety with a custom blocklist for harmful code.
Azure AI Content Safety provides a dedicated content filtering layer that can block harmful code generation at the inference level, regardless of the system message. A custom blocklist allows you to define specific patterns (e.g., code snippets for malware) that the model is prohibited from outputting, enforcing safety beyond prompt instructions.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Fine-tune the model on safe code examples.
Why it's wrong here
Fine-tuning adjusts model weights for task behaviour, not safety enforcement; harmful output persists because content filtering operates outside the model. It is tempting because fine-tuning on safe examples shapes style and domain responses, and would be correct when adapting tone or format for a specific application.
- ✗
Lower the temperature parameter to 0.
Why it's wrong here
Temperature controls sampling randomness, not policy compliance; at zero the model still generates harmful code deterministically. It is tempting because low temperature improves factual consistency and reproducibility, and would be correct when the problem is erratic or creative output rather than unsafe content.
- ✗
Add more examples to the prompt.
Why it's wrong here
Adding prompt examples is still prompt-level guidance, which the model can override; it does not enforce blocking of harmful content. It is tempting because few-shot examples reliably steer output format and task accuracy, and would be the right approach when improving consistency on benign classification or extraction tasks.
- ✓
Enable Azure AI Content Safety with a custom blocklist for harmful code.
Why this is correct
Prompt instructions alone cannot reliably block harmful code generation. Azure AI Content Safety filters model inputs and outputs against configurable harm categories, and a custom blocklist adds scenario-specific terms, enforcing the constraint at the platform layer regardless of what the system message says.
Go deeper
Related to this question
About these practice questions
This AI-102 question is part of Courseiva's 761-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AI-102 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AI-102 exam.