Structured outputs
Studies in this cluster, in series order. Each one keeps its own URL.
AI / ML
Retrieval, embeddings, vector indexes, evals, and serving patterns for senior interviews.
Structured outputs
6 studies- 1.Structured Outputs / Constrained DecodingStrict JSON Schema vs JSON mode; CFG token masking; required fields + additionalProperties:false; Pydantic/Zod; refusals/truncation still break validity.
- 2.JSON Schema Strictness for Structured OutputsStrict structured outputs need a closed schema: root object, every property required, additionalProperties false, provider-supported subset, schema_version, null for absence.
- 3.Tool/Function Calling vs Structured OutputsTools execute side effects and fetch live data; structured outputs constrain a final JSON contract; agent loops mix both. Pick by side effects, latency, and security — not by habit.
- 4.Grammars & CFG Constrained DecodingCompile a CFG/GBNF to an automaton, mask illegal next tokens, keep a parse stack. Same idea as JSON Schema SO, but you can constrain SQL, arithmetic, or custom DSLs.
- 5.Validation & Repair Loops for LLM OutputsPrefer constrained decoding for syntax. Use a bounded validate→feedback→regenerate loop for business rules or legacy models. Never repair refusals; never execute tools on invalid JSON.
- 6.Streaming Structured OutputStreaming tokens of JSON improves UX but partial JSON is invalid. Incremental parsers paint completed fields; commit side effects only after final schema validation. Constrained decoding still applies per token.