NCP-GENL Prompt Engineering Practice Question
An engineer is using an NVIDIA NIM for a code generation model to produce Python functions from natural language descriptions. The model frequently generates code that uses deprecated libraries or incorrect function signatures. The engineer wants to improve the accuracy of the generated code by providing examples. Which prompting strategy is most appropriate?
⚠ Common exam trap
The trap here is assuming that chain-of-thought or self-consistency will fix incorrect API usage, when the model needs concrete examples of correct code to learn the pattern.
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 that demonstrate the correct use of the desired libraries and function signatures.
Few-shot prompting with examples that demonstrate correct library usage and function signatures is the most direct way to guide the model to produce accurate code. By showing the desired pattern, the model can imitate it, reducing the likelihood of deprecated libraries or incorrect signatures. Other strategies like zero-shot, chain-of-thought, or self-consistency do not provide the concrete examples needed to correct systematic API 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.
- ✗
Zero-shot prompting with a detailed description of the desired function and its parameters.
Why it's wrong here
Zero-shot prompting relies solely on the model's pre-trained knowledge. If the model frequently uses deprecated libraries or incorrect signatures, a detailed description alone may not correct these issues because the model may not have up-to-date knowledge. Without examples, the model has no concrete pattern to follow for the specific libraries or signatures required, so it is likely to continue making the same mistakes.
- ✓
Few-shot prompting with examples that demonstrate the correct use of the desired libraries and function signatures.
Why this is correct
Few-shot prompting provides the model with concrete examples of the desired output, including correct library usage and function signatures. By showing several input-output pairs where the output uses the correct libraries and signatures, the model can learn the pattern and apply it to new inputs. This is especially effective for code generation where precise syntax and API usage matter, and it directly addresses the deprecated library and signature issues.
- ✗
Self-consistency prompting where the model generates multiple code solutions and the most common one is selected.
Why it's wrong here
Self-consistency involves generating multiple reasoning paths and selecting the most consistent answer. For code generation, if the model consistently uses a deprecated library, the most common solution will still be wrong. This technique is better for tasks with a single correct answer that can be voted on, but it does not correct systematic errors like using outdated APIs unless the majority of samples happen to be correct, which is unlikely if the model is biased.
- ✗
Chain-of-thought prompting that asks the model to first explain its reasoning about which libraries to use, then write the code.
Why it's wrong here
Chain-of-thought can improve reasoning, but it does not guarantee correct library usage or signatures. The model might reason incorrectly about which libraries are current or how to call functions. Without examples of correct code, the model may still generate deprecated or incorrect code. While reasoning can help, it is not as direct as providing examples of the desired output for this specific problem.
About these practice questions
This NCP-GENL question is part of Courseiva's 352-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 NVIDIA exam blueprint
This NCP-GENL practice question is part of Courseiva's free NVIDIA 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 NCP-GENL exam.