Skip to main content
Interactive 3D/Constrained Decoding & Structured Generation
Output Format
Constraint Type
Temperature0.70
HUD
FSM State: 0
Tokens gen: 0/9
Valid vocab: 6/24
Guaranteed valid output
Libraries: Outlines, Instructor, Guidance, lm-format-enforcer

Constrained Decoding & Structured Generation - Interactive Visualization

Constrained decoding guarantees that LLM output conforms to a schema (JSON, SQL, code) by masking invalid tokens at each generation step. A finite state machine (FSM) tracks which tokens are valid given the output so far. Libraries like Outlines, Instructor, and LMQL implement this, eliminating the need to parse or retry invalid outputs.

  • FSM state diagram - watch the finite state machine advance through JSON schema states as each token is generated
  • Token mask visualization - see which tokens are zeroed out at each step to enforce the current grammar state
  • Schema-to-FSM compilation - understand how a JSON Schema or regex compiles into a state machine before generation begins
  • Compare unconstrained vs constrained output on the same prompt to see how often unconstrained generation produces invalid JSON
  • See how Outlines, Instructor, and LMQL each implement constrained decoding and where they differ in approach

Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.