Turning generated text into something a program can depend on. The three ways to ask for structure and how reliable each one actually is, schemas and what to do when validation fails, refusals and edge cases, splitting one prompt into several steps, and what all of it costs in tokens and in time.
A grocery wholesaler extracts order details from supplier emails using a prompt that ends by asking for JSON. The parser raises a decode error at line 1 column 1, because the model returned the sentence "Sure, here is the extracted data", then a markdown code fence holding a well formed object, then an offer of further help. The team needs a route that cannot hand the parser a document it rejects. Which one qualifies?
AA stronger prompt naming the container, forbidding any text before or after it, forbidding a code fence and giving one filled example of the shape.
BConstrained decoding, where a grammar compiled from the schema masks every token that would break the document before the sampler runs.
CFunction calling in its original form, since the provider checks the emitted arguments against the schema before the application ever sees them.
DThe same prompt at temperature 0, since a deterministic sampler cannot choose the tokens that opened the greeting.