Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Switching from free-text completions to strict-JSON or structured-output mode usually raises the realized cost per useful answer by 10-40%, even when the underlying information returned is identical. Name the three mechanisms responsible and explain how each adds tokens or wall-clock time.
Structured-output mode adds 10-40% to output cost via three axes: constrained-decoding mask hurts speculation acceptance, JSON syntax adds envelope tokens, and parse failures cause retries.
Imagine asking someone for an answer in two ways. First, just tell me. Second, fill out this fixed form with labeled boxes (name, age, address). The second response always takes more words because of the labels, the brackets, and the formal structure, even when the underlying information is the same. On top of that, the person has to slow down while writing to make sure every label is spelled right and every bracket matches; rules force corrections. And occasionally they hand back a form that has a typo and you ask them to redo it, doubling the work for that one. That is what JSON mode does to an LLM: more words for the envelope, slower per word because of the rules, and the occasional do-over.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: three cost axes + constrained sampling and speculation drop + envelope overhead + retry tax + schema design tips + grammar-aware speculation.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing JSON mode is free because the model already produces structured-looking text. Constrained decoding actively masks tokens, lowering speculative-decoding acceptance, and the schema envelope tokens are real billed output.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.