Generative AI Leader Fundamentals of Generative AI Practice Question
A developer uses Vertex AI to generate code but the output is not syntactically correct. Which parameter should be adjusted?
⚠ Common exam trap
Google Cloud often tests the misconception that increasing candidate_count or max_output_tokens will improve output quality, when in fact these parameters only affect quantity or length, not the underlying token selection logic that determines syntactic correctness.
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 during generation. A high temperature increases the likelihood of less probable tokens, which can lead to syntactically incorrect code. Lowering temperature makes the model more deterministic and conservative, favoring higher-probability tokens that are more likely to form valid syntax.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
candidate_count
Why it's wrong here
candidate_count controls how many alternative completions are returned, not their syntactic validity; raising it just yields more flawed candidates. It is the right parameter when comparing multiple outputs or sampling diverse responses, not when correcting malformed code, which temperature or prompt structure governs.
- ✗
max_output_tokens
Why it's wrong here
max_output_tokens caps response length; truncating code mid-statement can cause syntax errors, but the parameter does not control correctness of what is generated. It is correct when responses are cut off prematurely, not when complete outputs remain syntactically invalid.
- ✓
temperature
Why this is correct
Temperature controls sampling randomness: higher values increase diversity but raise the chance of malformed syntax, while lower values make token selection more deterministic. Reducing temperature steers Vertex AI toward the most probable, syntactically valid continuations, directly addressing the incorrect code output.
- ✗
top_k
Why it's wrong here
top_k truncates the sampling pool to the k most probable tokens, controlling output diversity rather than grammar; syntax errors stem from decoding or prompt design, not vocabulary breadth. It is tempting because top_k genuinely shapes randomness in creative generation, and would be the right lever when outputs are too varied or repetitive.
Go deeper
Related to this question
About these practice questions
Courseiva writes every Generative AI Leader question from scratch — 1,008 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 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.