AlgoViz

Grammar-constrained decoding and domain validation

medium 6 min

A parser can restrict the next tokens to those that keep a partial output compatible with a grammar.

Trace the example

Follow the evidence through each stage, then test a change in the case.

Generate a valid status that can still be wrong

Generate a valid status that can still be wrong. Selected component: Grammar state inside Serving engine.
Open full-size diagram

Serving engine

Track expected status value

The output has reached the enum field. The engine knows which continuations the supported grammar accepts.

A schema-constrained generator produces a parseable status. What still determines whether it can update a payment record?