Courseiva
mediumMultiple ChoiceObjective-mapped

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

    Lower temperature makes outputs more conservative and less random, reducing the likelihood of generating invalid syntax.

  • Increase the context window

    Why it's wrong here

    Context window determines how much input can be processed; it doesn't directly affect output quality.

  • Set top-k to 1

    Why it's wrong here

    top-k=1 is greedy decoding; it may reduce randomness but can also produce repetitive or incomplete code, not necessarily correct syntax.

  • Increase the max output tokens

    Why it's wrong here

    Max output tokens only controls length; it doesn't affect correctness.

About these practice questions

One of 683 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.