AI From Scratch/Phase 05/Lesson 20/~60 minutes

Structured Outputs & Constrained Decoding

BuildPython

Ask an LLM for JSON. Get JSON most of the time. In production, "most" is the problem. Constrained decoding turns "most" into "always" by editing the logits before sampling.

Loading lesson page...