Generative AI Leader Practice Question: Techniques to Improve Generative AI Model Output
A data scientist is using the Gemini API to generate product descriptions for an e-commerce site. The descriptions are often too verbose and include speculative claims that are not in the product specifications. The scientist wants to reduce hallucinations and control the length of the output without retraining the model. What should they do?
⚠ Common exam trap
This exam often tests the misconception that adjusting generation parameters like temperature or top_k is the primary way to control factual accuracy and length, when in fact prompt engineering is the most direct and effective method for these specific requirements without retraining. A related trap is assuming that few-shot examples are always superior to explicit instructions; for strict length control and factual grounding, clear natural-language constraints in the prompt are the most direct solution.
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
✓
Refine the prompt to be concise and include instructions to stick to facts and limit output to 50 words.
Refining the prompt to be concise and include explicit instructions to stick to facts and limit output to 50 words directly addresses both issues without retraining. Prompt engineering is the most effective technique for controlling output length and reducing hallucinations in the Gemini API, as it guides the model's behavior through natural language constraints rather than altering generation parameters. Note that few-shot examples (Option C) are also a form of prompt engineering and could help, but the question asks for the most direct approach: explicit natural-language instructions in the prompt are the simplest and most reliable way to enforce a strict word limit and factual grounding, whereas few-shot examples alone do not guarantee a specific output length.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the max output token count to 2048 and decrease temperature to 0.1.
Why it's wrong here
Raising max output tokens permits longer responses, worsening the verbosity the scientist wants to cut; lower temperature alone does not enforce a length ceiling. Token limits and temperature are tempting because they tune generation behaviour, and would be correct if the goal were richer, more deterministic output rather than shorter factual text.
- ✓
Refine the prompt to be concise and include instructions to stick to facts and limit output to 50 words.
Why this is correct
Refining the prompt directly constrains generation through the model's instruction-following behaviour, requiring no retraining. Explicit instructions to limit output to 50 words satisfy the length constraint, while directing the model to stick to supplied product specifications reduces speculative claims at inference time. This addresses both the verbosity and hallucination issues within the Gemini API workflow.
- ✗
Add three few-shot examples of short, factual descriptions.
Why it's wrong here
Few-shot examples shape style and factual grounding but do not cap output length; verbosity persists because no token limit is set. Few-shot prompting is tempting because it genuinely reduces hallucination, and would be correct if the only problem were speculative claims rather than uncontrolled length.
- ✗
Set temperature to 0.0 and top_k to 1.
Why it's wrong here
Temperature and top_k alter sampling randomness, not output length, so verbose descriptions continue; they also do not prevent speculative claims grounded outside the specifications. Deterministic decoding is tempting because it reduces creative variation, and would be correct if the issue were random wording rather than length and unsupported assertions.
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 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.