Courseiva
mediumMultiple Choice

Generative AI Leader Practice Question: A developer is building a code‑generation…

A developer is building a code‑generation assistant using the Codey API on Vertex AI. The assistant should generate Python functions based on natural language descriptions. However, the generated code sometimes contains syntax errors. Which parameter adjustment would MOST directly help reduce syntax errors?

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

✓

Lower the temperature (e.g., from 0.8 to 0.2)

Reducing temperature makes the model more deterministic, which typically reduces creative but incorrect outputs like syntax errors. Prompt engineering can also help, but adjusting temperature is the simplest direct fix. Increasing max tokens or changing top-k does not directly address syntax correctness.

Answer analysis

Option-by-option breakdown

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

  • ✓

    Lower the temperature (e.g., from 0.8 to 0.2)

    Why this is correct

    Lowering the temperature sharpens the model's token probability distribution, so sampling favours high-confidence tokens rather than risky alternatives. This directly reduces the erratic token choices that produce malformed Python syntax, satisfying the stem's requirement to cut syntax errors without altering the prompt or model.

  • ✗

    Increase the context window

    Why it's wrong here

    A larger context window only lets the model accept longer prompts; it does not constrain token selection, so malformed syntax can still be emitted. Context length matters when prompts or few-shot examples exceed the current limit, which is not the failure here.

  • ✗

    Set top-k to 1

    Why it's wrong here

    Setting top-k to 1 forces greedy decoding, always picking the single highest-probability token; this narrows lexical variety but does nothing to guarantee syntactically valid Python, since token-level likelihood and grammar correctness are separate axes. Top-k suits controlling output diversity or reproducibility, not repairing malformed code.

  • ✗

    Increase the max output tokens

    Why it's wrong here

    Max output tokens caps generation length; syntax errors arise from token choice, not truncation, unless the function is being cut off mid-statement. Raising it helps when complete functions exceed the current ceiling, which the stem does not indicate.

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 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.