Grammar-Constrained Decoding Visualizer
Watch token-by-token grammar-constrained decoding in 3D: a finite-state grammar masks an LLM's logits so only structurally valid JSON tokens can ever be sampled, compared live against unconstrained sampling that can break the output.
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 simulator builds a real ten-state automaton for a small {"name": …, "age": …} object, samples tokens step by step from a live 3D bar chart of the masked (or unmasked) next-token distribution, and animates a marker travelling the automaton's 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.
Step through token-by-token grammar-constrained decoding in 3D: a finite-state JSON grammar masks an LLM's logits so only structurally valid tokens can ever be sampled, compared live against unconstrained sampling that can break the output.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install