Courseiva

AI-900 Practice Question: Describe features of generative AI workloads on Azure

A developer is using Azure OpenAI to generate Python code snippets. They notice that the generated code often contains syntax errors because the model introduces too much randomness. Which parameter should the developer decrease to make the output more deterministic and reduce syntax errors?

⚠ Common exam trap

Watch out — candidates often confuse Top_p with Temperature, thinking both control randomness equally, but Temperature is the primary parameter for adjusting the 'creativity' or randomness of the model, while Top_p is a secondary sampling strategy that can also affect determinism but is not the direct answer for reducing randomness in this context.

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

Temperature

Temperature controls the randomness of the model's output. Lowering the temperature (e.g., from 1.0 to 0.2) reduces the probability of sampling less likely tokens, making the model more deterministic and less prone to generating syntactically incorrect code. By decreasing temperature, the developer forces the model to choose higher-probability tokens, which typically results in more predictable and syntactically valid Python code.

Answer analysis

Option-by-option breakdown

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

  • Temperature

    Why this is correct

    Lowering temperature directly scales the logits before the softmax distribution, narrowing the probability mass around the most likely tokens. For code generation, this makes each token choice more predictable, reducing random variations that could lead to syntax errors or fabricated APIs. It is the most fine-grained and explicit control for determinism, which is why it is the correct first parameter to adjust.

  • Top_p

    Why it's wrong here

    Top_p (nucleus sampling) changes randomness by truncating the candidate set to the smallest set of tokens whose cumulative probability exceeds a threshold. This is a more coarse mechanism than temperature: it can accidentally eliminate low-probability but contextually valid tokens that might be needed for correct code, and it does not reshape the entire distribution. While lowering top_p can also reduce randomness, temperature is the primary and more direct parameter, so top_p is wrong here.

  • Frequency_penalty

    Why it's wrong here

    Frequency_penalty modifies token probabilities by subtracting an amount proportional to how often a token has already appeared, which primarily serves to prevent repetitive loops or boilerplate text. It does not narrow the overall sampling distribution for each token choice; its effect is orthogonal to randomness and determinism. Therefore, using frequency_penalty would not directly reduce the chance of generating incorrect or inconsistent Python code due to stochastic sampling.

  • Max_tokens

    Why it's wrong here

    Max_tokens only caps the maximum length of the generated completion and has no influence on how individual token probabilities are sampled or selected. Even with a low max_tokens value, every token is still chosen through the same random sampling mechanism, so the output can vary widely between requests. It addresses output length, not variability, making it ineffective for reducing randomness-induced code generation errors.

About these practice questions

One of 985 original AI-900 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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-900 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-900 exam.