Design prompts for JSON-only LLM responses

Quick Overview

This question evaluates a candidate's skills in prompt engineering, API and schema design, and robust output validation for large language models, with emphasis on producing strict JSON-only responses.

Design prompts for JSON-only LLM responses

Company: Intuit

Role: Software Engineer

Category: ML System Design

Difficulty: medium

Interview Round: Technical Screen

You need an LLM API to return strict JSON only. How would you structure prompts and the request so the model reliably responds with JSON and no extra text? Include: message roles and instructions, use of a JSON schema or function/tool calling to constrain output, parameter choices (e.g., temperature, max tokens), and runtime enforcement (schema validation, parsing, retry with repair prompts, or few-shot JSON examples). Provide a minimal example of the request and the expected JSON shape. Then explain how you would evaluate whether the output meets the ‘ideal answer’ criteria and how you would iterate on prompts and guards to improve reliability.

Quick Answer: This question evaluates a candidate's skills in prompt engineering, API and schema design, and robust output validation for large language models, with emphasis on producing strict JSON-only responses.

|Home/ML System Design/Intuit
Intuit logo
Intuit
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenML System Design
8
0

Design an LLM request that returns strict JSON only

Context

You are designing a backend call to an LLM for a technical screen (System Design & Engineering, Software Engineer). The service must return valid JSON only—no prose, no Markdown, no code fences—so downstream code can parse and validate responses reliably.

Task

Describe how you would:

  1. Structure message roles and instructions so the model returns only JSON.
  2. Constrain outputs using either a JSON Schema or function/tool calling.
  3. Choose parameters (e.g., temperature, top_p, max tokens) to reduce variability.
  4. Enforce correctness at runtime (schema validation, parsing, retries with repair prompts, and/or few-shot JSON examples).
  5. Provide a minimal example of the request and the expected JSON shape.
  6. Explain how you would evaluate whether the output meets the “ideal answer” criteria and how you would iteratively improve prompts and guards to increase reliability.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...