AnyLearn
All cursus
AIadvanced

Constrained Decoding: Output That Always Parses

A 5 percent JSON failure rate does not double your average latency, it doubles your p95. Constrained decoding removes the failure entirely by editing the logits before sampling, so invalid tokens have probability exactly zero. This path builds the mechanism from the decoding loop outward: how a schema compiles into an automaton and then into a per-token mask, why recursive grammars need a stack and how that cost is made near-free, and the part most teams get wrong, that a badly ordered schema constrains the reasoning as well as the output.

0 of 4 lessons complete
Sign in to track progress and earn a certificate.

Lessons, in order

  1. 1
    AI
    Why Asking Nicely Does Not Guarantee JSON
    Start
  2. 2
    AI
    From Schema to Mask: The Automaton Index
    Start
  3. 3
    AI
    Grammars, Stacks, and Making It Free
    Start
  4. 4
    AI
    What Constraints Cannot Fix
    Start