Constrained decoding applies rules during token generation rather than hoping a prompt will produce the right format. Depending on the implementation, the allowed next tokens may be limited by a JSON schema, grammar or other formal language. This can reduce malformed outputs in applications that need predictable structure.
A grammar-constrained setup can, for instance, allow only the values positive, neutral or negative for a sentiment field, so the model cannot invent a fourth label. Constraints are most common in locally run models and some provider features. They can make output more predictable, but overly strict grammars can push the model into awkward answers when none of the allowed options fits. Constraints act on tokens as they are generated.
Constraints govern form, not factual correctness. A response can satisfy a schema while containing incorrect values, so applications still need semantic validation and sensible failure handling. Related: Structured Output, JSON Mode.