Courseiva

Generative AI Leader Fundamentals of Generative AI Practice Question

A software team is using a generative AI model to write code snippets. They want to control the model's creativity and ensure it produces consistent, deterministic output for the same prompt. Which parameter should they adjust?

⚠ Common exam trap

The trap here is thinking that top-p or top-k alone can produce fully deterministic output, when only temperature zero does.

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 token selection. Setting it to zero makes the model choose the highest-probability token each time, yielding deterministic output for the same prompt. Top-p, top-k, and max tokens do not provide the same level of determinism.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Top-p (nucleus sampling)

    Why it's wrong here

    Top-p controls the cumulative probability threshold for token selection, but it still allows randomness. It does not guarantee deterministic output. While lower top-p reduces diversity, temperature is the primary parameter for determinism when set to zero.

  • ✗

    Top-k sampling

    Why it's wrong here

    Top-k restricts sampling to the k most likely tokens, but it still involves random selection among them. It reduces diversity but does not guarantee identical outputs. Temperature set to zero is the correct way to achieve determinism.

  • ✗

    Maximum output tokens

    Why it's wrong here

    Maximum output tokens limits the length of the response but does not affect randomness or determinism. It is useful for controlling cost and truncation, but it will not make outputs consistent across runs. This parameter is unrelated to creativity.

  • ✓

    Temperature

    Why this is correct

    Setting temperature to zero makes the model select the most likely next token at each step, producing deterministic output for the same prompt. This is ideal for code generation where consistency is important. Temperature directly controls randomness, making it the correct choice.

About these practice questions

One of 1,008 original Generative AI Leader 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Google Cloud exam blueprint

This Generative AI Leader practice question is part of Courseiva's free Google Cloud 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 Generative AI Leader exam.