Courseiva

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

AI0-001 often tests the confusion between techniques that improve reasoning (chain-of-thought) and techniques that constrain output format (few-shot examples, structured output), tempting candidates to pick chain-of-thought for a formatting problem.

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 examples of valid JSON outputs condition the model on the exact schema, key names, and formatting it should produce, dramatically increasing the probability of schema-conformant output. Because LLMs are next-token predictors, showing several input-output pairs where the output is valid JSON teaches the pattern in-context without retraining. This is the most reliable prompt-engineering technique for enforcing structural output constraints.

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 elicits intermediate reasoning steps, which adds prose around the payload and does not constrain the output grammar to JSON. It is tempting because it improves accuracy on multi-step reasoning tasks, and would be correct when the model must solve a problem requiring intermediate derivation rather than emit a fixed schema.

  • ✓

    Few-shot examples of valid JSON outputs

    Why this is correct

    Few-shot prompting places several complete, valid JSON examples in the prompt, so the model infers the required schema, key names and formatting by pattern matching. This constrains generation toward syntactically valid JSON, satisfying the always-valid-JSON requirement more reliably than zero-shot instructions alone.

  • ✗

    Temperature setting to 0

    Why it's wrong here

    Temperature 0 makes sampling deterministic, so the same prompt yields the same text, but it does not constrain that text to JSON syntax; the model can still emit invalid or partial JSON. It suits reproducibility and factual tasks. Enforcing valid JSON needs schema-constrained decoding or a JSON response-format parameter.

  • ✗

    Using a larger model variant

    Why it's wrong here

    Larger model variants improve reasoning and fluency, not structural conformance; a bigger model can still emit prose around JSON. They suit tasks needing deeper comprehension where output format is flexible. Guaranteeing valid JSON requires schema-constrained decoding or a response-format parameter, which enforces grammar at generation time.

About these practice questions

Courseiva writes every AI0-001 question from scratch — 962 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.