Courseiva
Implementing AI SolutionshardMultiple ChoiceObjective-mapped

AI0-001 Few-shot prompting Practice Question

A team is deploying a fine-tuned LLM for code generation. They need to ensure the model output is always valid JSON. Which prompt engineering technique should they use?

⚠ Common exam trap

Candidates might mistakenly think that setting temperature to 0 will guarantee valid JSON output, but temperature controls randomness, not format. The only way to enforce a specific format with standard prompting is through explicit instructions and examples.

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 examples of valid JSON outputs

Few-shot prompting provides the model with examples of valid JSON outputs, conditioning it to mimic the format in its response. This is an effective technique for constraining output structure without requiring model retraining or special modes.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Chain-of-thought prompting

    Why it's wrong here

    Chain-of-thought prompting guides reasoning but does not constrain the output to valid JSON. It is not designed for format enforcement.

  • Few-shot examples of valid JSON outputs

    Why this is correct

    Correct. Providing few-shot examples of valid JSON outputs conditions the model to mimic that structure, making it the most direct technique listed.

  • Temperature setting to 0

    Why it's wrong here

    Setting temperature to 0 reduces randomness but does not guarantee valid JSON. The model may still produce malformed JSON.

  • Using a larger model variant

    Why it's wrong here

    Using a larger model variant may improve overall quality but does not specifically ensure valid JSON output without additional prompting techniques.

About these practice questions

Courseiva writes every AI0-001 question from scratch — 754 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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 AI0-001 practice question is part of Courseiva's free CompTIA 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 AI0-001 exam.