Courseiva
Implementing AI Solutions →mediumMultiple Choice

AI0-001 Implementing AI Solutions Practice Question

An AI application needs to generate structured JSON output from an LLM. The development team wants to ensure the output always conforms to a specific schema. Which prompt engineering technique is MOST suitable?

⚠ Common exam trap

The AI0-001 exam often tests the misconception that few-shot examples alone are sufficient for format control, but the trap here is that without an explicit schema and strict instruction, the model may still produce inconsistent or non-compliant output, especially when the schema is complex or the prompt context shifts.

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

✓

System prompt with JSON schema and a 'respond only with valid JSON' instruction

Providing the JSON schema directly in the system prompt, combined with an explicit instruction to respond only with valid JSON, is the most direct and reliable way to constrain an LLM's output format. This technique leverages the model's instruction-following capability and schema awareness without requiring examples or retraining, ensuring strict adherence to the desired structure.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Few-shot examples showing correct JSON

    Why it's wrong here

    Few-shot examples steer the model toward JSON-like formatting, but they consume context and provide no enforcement mechanism, so malformed or schema-violating output remains possible. It is tempting because examples reliably improve format adherence in general prompting tasks, where approximate consistency suffices rather than guaranteed schema conformance.

  • ✓

    System prompt with JSON schema and a 'respond only with valid JSON' instruction

    Why this is correct

    Embedding the schema in the system prompt and instructing the model to respond only with valid JSON constrains generation at the prompt level, satisfying the requirement that output always conforms to a specific schema. The system role carries persistent, high-priority instructions, making schema adherence more reliable than user-turn guidance alone.

  • ✗

    Chain-of-thought prompting

    Why it's wrong here

    Chain-of-thought prompting elicits intermediate reasoning steps, which improves arithmetic and multi-step logic but imposes no token-level constraint on output structure, so JSON keys and types can still drift. It is tempting because it genuinely lifts accuracy on complex reasoning tasks, where it would be the right choice.

  • ✗

    Fine-tuning the model on JSON datasets

    Why it's wrong here

    Fine-tuning teaches the model JSON patterns through weight updates, but it cannot guarantee every response validates against a specific schema and requires labelled data plus retraining. It is tempting because it durably shifts a model's output style, which suits stable, high-volume formatting needs rather than strict per-request schema enforcement.

About these practice questions

One of 962 original AI0-001 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 →

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.