Grammar-valid token
Sampled token
Invalid pick (broken)
drag to pan · scroll to zoom
Structured-output tools keep an LLM's JSON valid by walking a finite-state grammar alongside generation and masking every token that would break the schema before the softmax ever runs. This 2D simulator builds a real ten-state automaton for a small {"name": …, "age": …} object, samples tokens step by step from a live bar chart of the masked (or unmasked) next-token distribution, and animates a marker travelling a draggable, zoomable automaton state graph as each token is accepted. Toggle constrained decoding off to watch unconstrained sampling occasionally pick a structurally illegal token and break the run — the same failure mode grammar-constrained decoding exists to eliminate — and track the valid-JSON success rate across runs live.