Skip to content
AI & Machine Learning

Structured Output

Definition

Structured output is when a language model is made to answer in an exact machine-readable format, usually JSON matching a schema the developer provides, so the application can use the answer directly instead of parsing free text.

Diagram

Schema

{ "total": number }

Written so far

{ "total": 

The model’s likely next tokens

  • aboutblocked
  • 1allowed
  • "blocked
  • 4allowed
  • Theblocked
The schema is turned into rules about which tokens may come next. A number must follow, so words and quotation marks are blocked even when the model rates them likelier, and the reply always parses. It guarantees the shape, not the facts: the number can still be wrong.

Case study

Worked example