Asked about Asking for JSON versus guaranteeing it

How does constrained decoding actually work?

An answer that works

At each generation step the sampler is restricted to tokens that keep the output valid against the schema. Invalid continuations are given zero probability, so malformed output is not reachable rather than merely discouraged.

Reading an answer is not being able to give one. The section that teaches this is Asking for JSON versus guaranteeing it, 2 hours of Structured output.

Learn this properly