IT lexicon AI & ML Structured output

Structured output

AI & ML På svenska → Updated: 2026-07-30

Guaranteeing that an LLM's answer follows an exact format (usually JSON per a schema) by constraining which tokens it's allowed to generate — instead of hoping and parsing afterward. It turns "ask nicely for JSON" into a hard guarantee.

Mechanic ("constrained decoding"): at each generation step, only the tokens that can lead to valid output per a schema/grammar (JSON Schema, a regex, a CFG) are allowed. The model then CAN'T produce invalid JSON — the format is guaranteed. Implementations: OpenAI Structured Outputs / "JSON mode", llama.cpp's GBNF grammar, Outlines, and function-calling APIs. Win: no fragile parsing or retry loop, reliable integration with code, safer pipelines. Trade-off: requires support in the inference engine, and a too-rigid grammar can sometimes force unnatural answers. The modern, robust solution to the problem that output parsing handled manually. Tightly tied to function calling. Related to output parsing and function calling.

← Back to the lexicon