Skip to content
โ† ๐ŸŒณ Decoding Algorithms
Advanced

Grammar-Constrained Decoding

Constrained decoding masks every token the grammar cannot accept before sampling, using an automaton compiled from a regex, JSON schema or context-free grammar. This page covers how the mask is computed fast enough to hide under a 5 ms decode step, why per-step masking does not sample from the model conditioned on the grammar, and how it interacts with speculation.

Get full Premium access ยท โ‚น2,000 / $25

Every worked answer and derivation in all 12 topics, every concept page, and the full practice-test bank.

6 months ยท One payment ยท No auto-renewal

RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS