AIF-C01 Fundamentals of Generative AI Practice Question
A company is using Amazon Bedrock to generate code snippets. They notice the model occasionally generates code that fails to compile. What is the most effective way to improve code quality without retraining?
⚠ Common exam trap
A common misconception in AWS AI services is that adjusting hyperparameters like temperature or token limits can fix output quality issues, when in fact prompt engineering techniques like few-shot learning are the primary non-retraining methods for improving model behavior.
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
✓
Use few-shot prompt engineering with correct code examples and formatting instructions.
Few-shot prompt engineering provides the model with explicit examples of correct code and formatting instructions, guiding it to generate syntactically valid code without modifying the underlying model. This approach leverages in-context learning to improve output quality by conditioning the model on desired patterns, which is more effective than parameter adjustments alone for addressing compilation errors.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Reduce the temperature parameter to 0 for deterministic output.
Why it's wrong here
Temperature 0 makes token selection deterministic but does not supply the model with API signatures, library versions or compile feedback, so syntactically invalid code persists. It is tempting because low temperature reduces random variation, which suits tasks needing reproducible classification or extraction rather than correctness of generated code.
- ✗
Increase the max token limit to allow the model to complete the code fully.
Why it's wrong here
Raising the max token limit only extends output length; truncated snippets may complete, but code that fails to compile because of wrong APIs or syntax still fails. It is tempting because truncation is a visible cause of broken snippets, so this suits prompts whose responses are cut off mid-function rather than logically incorrect.
- ✗
Fine-tune the model on a dataset of correct code snippets.
Why it's wrong here
Fine-tuning involves further training the model on a specialised dataset, which directly contravenes the question's requirement to improve code quality *without retraining*. This process updates the model's weights and biases, fundamentally altering its learned representations. Fine-tuning is, however, an effective method for adapting a pre-trained model to a specific domain or task, such as generating code for a particular framework or language dialect, and would be the correct choice if a permanent, deeper adaptation of the model's underlying knowledge base was desired and retraining was an acceptable approach.
- ✓
Use few-shot prompt engineering with correct code examples and formatting instructions.
Why this is correct
Few-shot prompting supplies in-context examples of compilable code plus explicit formatting rules, steering the model's token distribution toward syntactically valid output without weight updates. This directly satisfies the no-retraining constraint, unlike fine-tuning, and targets the compilation failures observed in the stem.
Go deeper
Related to this question
About these practice questions
One of 862 original AIF-C01 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AIF-C01 practice question is part of Courseiva's free Amazon Web Services 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 AIF-C01 exam.