Generative AI Leader Practice Question: Techniques to Improve Generative AI Model Output
A software company is using a large language model to generate code snippets from natural language descriptions. The generated code often contains syntax errors or uses deprecated functions. The team wants to improve the correctness of the code. Which technique should they use?
⚠ Common exam trap
The trap here is thinking that adjusting sampling parameters like temperature can fix systematic issues like syntax errors or deprecated API usage.
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
✓
Few-shot prompting with examples of correct code and explanations of why deprecated functions are avoided.
Few-shot prompting supplies the model with examples of correct code and explanations, which guides it to generate syntactically valid and up-to-date code. This technique leverages in-context learning to improve accuracy without retraining. Other parameter adjustments like temperature, max output tokens, or top-p do not provide the necessary guidance for 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.
- ✗
Increasing the temperature to allow more creative code solutions.
Why it's wrong here
Higher temperature increases randomness, which would likely lead to more syntax errors and unpredictable code. It does not help with correctness or avoiding deprecated functions. For code generation, lower temperature is generally preferred to ensure deterministic, correct output.
- ✓
Few-shot prompting with examples of correct code and explanations of why deprecated functions are avoided.
Why this is correct
Few-shot prompting provides the model with concrete examples of correct code and reasoning, which helps it mimic the desired patterns and avoid deprecated functions. By including explanations, the model learns the rationale, improving its ability to generate syntactically correct and modern code. This is a direct and effective technique for this scenario.
- ✗
Using a top-p value of 1.0 to consider all possible tokens.
Why it's wrong here
Top-p of 1.0 means no nucleus sampling restriction, effectively considering all tokens. This increases diversity but also the chance of errors. It does not guide the model toward correct or modern code. In fact, it may worsen the issue by allowing unlikely tokens.
- ✗
Reducing the max output tokens to force shorter code.
Why it's wrong here
Limiting output length may truncate code, causing incomplete or syntactically invalid snippets. It does not address the use of deprecated functions or improve correctness. Shorter code is not necessarily more correct, and truncation can introduce new errors.
Go deeper
Related to this question
About these practice questions
This Generative AI Leader question is part of Courseiva's 1,008-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.