Skip to main content
Back to Library
Prompt Engineering Guide

Mastering JSON schema generation
on Phi-3.5 MoE

Stop guessing. See how professional prompt engineering transforms Phi-3.5 MoE's output for specific technical tasks.

The "Vibe" Prompt

"Generate JSON schema for a user profile with fields like name, age, email, and interests."
Low specificity, inconsistent output

Optimized Version

STABLE
You are an expert JSON schema generator. Your goal is to create a JSON schema for a 'user_profile' object based on the following requirements: 1. The schema should define a 'user_profile' object with properties including 'name', 'age', 'email', and 'interests'. 2. 'name' should be a required string. 3. 'age' should be an optional integer, with a minimum value of 0 and a maximum value of 120. 4. 'email' should be a required string, formatted as an 'email' type. 5. 'interests' should be an optional array of strings, where each string represents a hobby or interest. The array should allow a minimum of 0 items and a maximum of 10 items. First, analyze each requirement to understand its implications for JSON schema keywords (e.g., 'type', 'properties', 'required', 'format', 'minimum', 'maximum', 'items', 'minItems', 'maxItems'). Second, construct the JSON schema step-by-step, ensuring all requirements are met and the schema is valid according to JSON Schema Draft 7 or later specifications. Finally, present the complete JSON schema.
Structured, task-focused, reduced hallucinations

Engineering Rationale

The optimized prompt leverages several best practices for instructing large language models. It starts by assigning a 'role' ('expert JSON schema generator'), which helps set the model's tone and focus. It then breaks down the complex task into specific, numbered 'requirements', making the expectations explicit and unambiguous. The prompt introduces a 'chain-of-thought' by explicitly asking the model to 'analyze each requirement' and 'construct the JSON schema step-by-step'. This guides the model through a logical reasoning process before generating the final output, reducing hallucination and improving adherence to constraints. The explicit mention of 'JSON Schema Draft 7 or later' provides a version context. This structured approach, combined with clear formatting, significantly improves the likelihood of a correct and complete schema generation compared to the vague 'vibe' prompt.

-400%
Token Efficiency Gain
The output JSON schema must be syntactically valid.
The output JSON schema must correctly define 'name' as a required string.
The output JSON schema must correctly define 'age' as an optional integer with min 0 and max 120.

Ready to stop burning tokens?

Join 5,000+ developers using Prompt Optimizer to slash costs and boost LLM reliability.

Optimize My Prompts