Skip to content

Structured Decoding

Technique for controlling decoding where the model is restricted in choosing the next token so that the response is guaranteed to conform to a schema — for example, JSON.

What differs from Structured Output

Structured Output is the result: a valid JSON. Structured Decoding is one of the ways to achieve it: restrictions are imposed during generation, not post-processing.

How it works

  • on each step, tokens that violate grammar are masked;
  • the schema is defined through JSON Schema or regular expressions;
  • the model physically cannot generate an invalid response.

See also

← All terms