AI0-001 Implementing AI Solutions Practice Question
A chatbot application uses a system prompt to set the assistant's behavior. The developer wants the LLM to output structured JSON for downstream processing. Which technique BEST ensures the output is valid JSON?
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 the LLM's built-in JSON mode (e.g., response_format='json_object')
Many LLMs support a JSON mode that constrains output to valid JSON. System prompts can request JSON but may be ignored. Few-shot examples help but are not foolproof. Chain-of-thought is for reasoning, not formatting.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set the temperature to 0 to make output deterministic
Why it's wrong here
Temperature 0 helps consistency but does not force JSON structure; output may still be freeform text.
- ✗
Include a few-shot example showing a JSON output in the prompt
Why it's wrong here
While a few-shot example can guide the LLM toward a desired output format, it does not enforce structural validity; the model may still produce malformed JSON, omit required keys, or include trailing commas. This technique is tempting because it works well for tasks like classification or style imitation where exact syntax is secondary. It would be the correct choice if the goal were merely to demonstrate a response pattern rather than guarantee parseable JSON for downstream processing.
- ✗
Add a chain-of-thought reasoning step before the output
Why it's wrong here
Chain-of-thought improves reasoning but does not enforce JSON formatting.
- ✓
Use the LLM's built-in JSON mode (e.g., response_format='json_object')
Why this is correct
JSON mode enforces valid JSON output, reducing parsing errors and ensuring structure.
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 →
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.