Courseiva

AI-102 Implement generative AI solutions Practice Question

You are designing a generative AI solution that uses Azure OpenAI Service. The solution must generate code snippets in Python and JavaScript. You need to ensure the model reliably outputs code in the correct language based on user input. Which approach should you use?

⚠ Common exam trap

Test-takers frequently confuse hyperparameters like temperature and top_p with content control mechanisms, mistakenly believing they can enforce output language, when in fact they only affect randomness and token selection probability.

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

✓

Use a system message to specify the desired language.

System messages in Azure OpenAI Service allow you to set the context or behavior of the model, such as specifying the desired programming language for code generation. This approach is lightweight, requires no retraining, and reliably guides the model to output code in the correct language based on the user's request, leveraging the model's existing training on both Python and JavaScript.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Set the top_p parameter to a low value.

    Why it's wrong here

    top_p narrows the sampling nucleus, affecting token diversity rather than which programming language the model chooses. It is tempting because low top_p values suit tasks needing focused, predictable completions, but language selection depends on prompt instructions, not probability mass truncation.

  • ✓

    Use a system message to specify the desired language.

    Why this is correct

    A system message sets persistent behavioural instructions applied to every turn, so it constrains the model to emit Python or JavaScript according to the user's request. This satisfies the reliability requirement better than per-prompt phrasing, which the model may inconsistently honour across requests.

  • ✗

    Fine-tune the model on a dataset of code in both languages.

    Why it's wrong here

    Fine-tuning teaches style and domain patterns rather than guaranteeing instruction-following for language selection; it also adds cost and training effort. It is tempting because fine-tuning suits adapting a model to specialised vocabularies or formats, but prompt engineering with explicit system instructions already satisfies this requirement.

  • ✗

    Set the temperature to 0 to make the model deterministic.

    Why it's wrong here

    Temperature controls sampling randomness, not language selection; a deterministic model can still emit JavaScript when Python is requested. It is tempting because temperature 0 suits tasks needing reproducible, consistent output, such as classification or extraction, but it cannot enforce which language the generated code uses.

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 →

How Courseiva writes practice questions · Editorial policy

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.