Grammar-constrained decoding and domain validation
medium 6 minA parser can restrict the next tokens to those that keep a partial output compatible with a grammar.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
A parser can restrict the next tokens to those that keep a partial output compatible with a grammar. At each generation step the engine masks ineligible vocabulary entries and samples among what remains. Token boundaries do not always match JSON characters, so a correct implementation tracks possible continuations at the tokenizer boundary. Supported schema features depend on the engine.