Skip to content
← Speculative & Constrained Decoding / 20
hardNewBasetenSnowflakeAmazon

Implement a JSON-schema token mask: walk the vocabulary through the automaton, pack it into int32 words, apply it to logits.

The coding round behind structured output: a character automaton for a small schema, a vocabulary trie that prunes dead prefixes, the int32 bitmask layout engines ship to the GPU, and the four edge cases that produce invalid JSON or a crash when missed.

Updated Oct 2026 · Worked answers on inference mechanisms, with calculations, implementation details, and follow-up questions.

The coding round behind structured output: a character automaton for a small schema, a vocabulary trie that prunes dead prefixes, the int32 bitmask layout engines ship to the GPU, and the four edge cases that produce invalid JSON or a crash when missed.

10 answers per topic instead of 5, plus saved progress and bookmarks · costs nothingor unlock all 213 remaining answers · $25

Every worked answer and derivation in all 12 topics, every concept page, the full practice-test bank, and every code drill’s edge-case tests and reference solution.

6 months · One payment · No auto-renewal

UP NEXT ON YOUR JOURNEY
EDITOR'S NOTE

The bug interviewers wait for is checking only a token's first character. The second is the special token with empty text that every walk accepts.

DISCUSSION · 0

Nobody has commented on this answer. Add a correction or another way to work it.