Constraints, Roles and Structured Output
Good prompts define the task, provide relevant context, specify constraints and describe what a useful answer looks like.
A practical prompt structure
- Task: what should the model do?
- Context: what information should it use?
- Constraints: what must it include or avoid?
- Output: what format should it return?
- Uncertainty: what should it do when evidence is missing?
Roles are not permissions
A role or persona can influence tone and framing. It does not grant the model new capabilities, make it an expert, or override application-level security controls.
For consequential tasks, provide authoritative source material and define when the model must abstain or ask for clarification.
Structured output
A requested JSON shape can make outputs easier to validate and process. For production systems, use schema-constrained generation where available and validate the result in application code.
Never treat valid JSON as proof that the values inside it are accurate. Validate required fields, allowed values and business rules separately.
Sign in to access the lab and homework
The lesson explanation is free to read. Create a free learner account to use the practical exercise, submit homework and track your progress.
CREATE FREE ACCOUNT →