Cheat sheet · Module 2
Cheat sheet: Prompting and structured output
Generative AI · Cheat sheet · Prompting and structured output
Prompting types:
| Type | When |
|---|---|
| Zero-shot | Simple, well-known task |
| Few-shot | Need a specific output format or style |
| Chain-of-thought | Multi-step reasoning on a model that does not already reason |
| Self-consistency | High-stakes reasoning with a short answer; cost is about N times |
Structured output options:
| Option | Guarantees |
|---|---|
| Prompt for JSON, then parse | Nothing |
| JSON mode | Valid JSON, not your schema |
| Schema-constrained outputs | Conforms to your schema; not truth, completeness or refusals |
| Tool calling | Schema-checked arguments in strict mode; for actions, not a “stronger” option |
Quick answers
- Reasoning models: spend inference-time compute; reasoning tokens are billed as output; use for hard multi-step tasks; cost latency and tokens; visible reasoning is not an audit trail.
- Structured output: constrain, then validate (form and meaning), bounded retry with the error, fallback. Valid does not mean correct.
- Prompts: delimit untrusted text; judge changes on a labelled set and pass rate.
- Check the docs: effort and thinking settings and supported schema features differ by model and change often.