Skip to main content
Back to Library
Prompt Engineering Guide

Mastering JSON schema generation
on Cerebras Llama 3.1 70B

Stop guessing. See how professional prompt engineering transforms Cerebras Llama 3.1 70B's output for specific technical tasks.

The "Vibe" Prompt

"Output the JSON schema for an object that represents a 'Product'. It should have a name (string), price (number), description (string, optional), and available (boolean)."
Low specificity, inconsistent output

Optimized Version

STABLE
You are an expert in JSON schema. Your task is to generate a JSON schema definition for a 'Product' object. Follow these steps: 1. Define the root object type as 'object'. 2. Specify '$schema' as 'http://json-schema.org/draft-07/schema#'. 3. Set a 'title' to 'Product Schema'. 4. Add 'properties' for 'name', 'price', 'description', and 'available'. 5. For 'name': type 'string', add a 'minLength' of 1. 6. For 'price': type 'number', add a 'minimum' of 0. 7. For 'description': type 'string', make it 'optional'. 8. For 'available': type 'boolean'. 9. List 'name', 'price', and 'available' as 'required' properties. 10. Ensure the output is a valid JSON schema object.
Structured, task-focused, reduced hallucinations

Engineering Rationale

The optimized prompt uses a Chain-of-Thought approach, breaking down the task into specific, numbered instructions. This clarity guides the model step-by-step, reducing ambiguity and the need for inference. Specifying types, constraints (minLength, minimum), and required fields explicitly ensures accuracy and completeness. The naive prompt is more open-ended, relying on the model to infer schema conventions and property details, which can lead to inconsistencies or omissions. The optimized prompt also explicitly states the role of the AI ('expert in JSON schema') and the desired output format ('valid JSON schema object'), further enhancing precision.

0%
Token Efficiency Gain
The optimized_prompt will generate a 'title' property in the schema.
The 'description' property in the optimized_prompt's output schema will correctly indicate it's optional (i.e., not listed in 'required').
The 'price' property in the optimized_prompt's output schema will include 'minimum: 0'.

Ready to stop burning tokens?

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

Optimize My Prompts