Skip to content

Structured Generation

Definition

Structured Generation is an approach where the decoding process is constrained by a formal specification of the output format. The model is forced to generate only tokens that are valid within the given schema, thereby eliminating syntax errors and simplifying integration.

Implementation Methods

  • Constrained decoding: filtering out tokens incompatible with the schema at each step.
  • Grammar-constrained generation: using formal grammar for validation.
  • JSON Schema: constraining generation by a JSON structure.

Example

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer" }
  },
  "required": ["name", "age"]
}

Benefits

  • Guaranteed validity of the output.
  • Simplified parsing and processing.
  • Reduced number of errors in integrations.

See also

← All terms