Module 3 of 5 · Beginner · 7 min read
Structure and output format
Tags, sections and schemas that make prompts reliable and outputs ready to use.
- 1Separate instructions from material with tags like <document>.
- 2Specify the exact output shape, with numbers instead of adjectives.
- 3Use JSON schemas when a program will read the output.
01Tags and delimiters
When a prompt mixes instructions with pasted content, the model can confuse the two, especially if the content contains instructions of its own. Wrap each part in a named tag and refer to it by name.
Tags also make long prompts easier for you to maintain: you can swap the <transcript> without touching the instructions.
02Say exactly what shape you want
Replace vague adjectives with specifics. "Short" becomes "three bullets under 15 words". "Detailed" becomes "a section per risk, each with likelihood, impact and mitigation".
- Tables: name the columns.
- Reports: name the headings.
- Lists: give the count and the order.
- Length: give a word or sentence limit.
03Structured outputs for code
If software will parse the result, use the API's structured output or JSON schema feature. It guarantees valid JSON matching your schema instead of relying on the model to follow prose instructions.
Tell the model what to do when data is missing (use null, never guess) so it does not invent values to fill the schema.
Finished reading?
Mark it complete to track your progress, then test yourself with the Prompting Fundamentals quiz.