# Structured output (JSON schema, regex, EBNF)

> VI: https://5ac.vn/wiki/structured-output/ · EN: https://5ac.vn/en/wiki/structured-output/ · lang: en · spec_as_of 2026-10-21 (spec no formal spec) · cluster C17

Requiring a model to answer in a machine-readable format — JSON against a schema, regex or EBNF — rather than free text; the base layer for pipelines and tool agents.

---
## Definition

Structured output is a requirement placed on a model: the answer must come back in a format a program can read — JSON that validates against a JSON Schema, a string matching a regex, or an EBNF grammar — rather than as free prose. Text written for a person only has to read well; structured output is written for software, so the next pipeline step can parse it and move on without a human cleaning it up. No common specification governs the term: each engine describes its own capability with a different toolset, and verification always sits with the user.

## Mechanism

The inference engine is where the format actually gets enforced. The piece on DeepSeek's production inference stack records that the engine takes structured output as regex, JSON schema or EBNF, alongside two features rarely offered to eval and RL teams: batch-invariant inference and deterministic sampling. At the open-source end, llama-server in llama.cpp ships an OpenAI-compatible API with JSON schema and function calling, and the local AI article files SGLang under "strong with structured outputs, long context, MoE".

Where it breaks first is quantization: the local AI piece warns that Q3/Q2 — the point where a model has to be squeezed hardest — is where "math, code, structured output, and tool use degrade first", and a smaller model at higher precision can beat a larger one crushed too far.

JSON Schema 2020-12 also sits in the spec table of the MCP eras; the version history belongs to the [MCP protocol eras](/en/wiki/mcp-eras/) entry, which this page links to rather than retells.

## Application context

For an agent team the measured value sits far from the brochure: in the comparison of six Chinese flash models for agent harnesses, exactly one model returned json_schema verified HTTP 200 — "the only json_schema response verified at 200 among the six". The same piece records that the BFCL tool-calling leaderboard was last updated 12 April 2026, before every model in that comparison shipped, and that no public GAIA numbers exist for the class, so it routes number-bearing outputs through a separate review model regardless. Output quality also drops with the quantization tier: that is why the team settled on the 4-bit build for chat and documents while leaving headroom for structured output.

A CRM, invoicing or internal reporting pipeline needs exactly one schema to write straight into the system: a conforming payload runs unattended, a missing field raises an alert for a person. That is the practical bar.

## Sources fetched

- [DeepSeek Open-Sources Its Production Inference Stack: What Changes for Self-Hosters](/en/blog/deepseek-opens-production-inference-stack/) — the engine takes structured output as regex, JSON schema or EBNF — accessed 2026-10-21
- [Chinese Flash Models for Agent Harnesses: Benchmarks and Prices Compared](/en/blog/chinese-flash-models-agent-harness-comparison/) — json_schema verified HTTP 200, BFCL leaderboard last updated 12 April 2026, no public GAIA numbers — accessed 2026-10-21
- [Local AI 2026: From an RTX 3090 to Enterprise On-Prem Infrastructure](/en/blog/local-ai-2026-from-rtx3090-to-enterprise/) — llama-server JSON schema, SGLang structured outputs, quantization tiers — accessed 2026-10-21

## Related

- [MCP protocol eras (version history)](/en/wiki/mcp-eras/)
- [Inference engine](/en/wiki/inference-engine/)
