TRACK GRAMMAR STATE
Maintain parser state as generated text advances through the supported structured-output grammar.
ICE is an offline-first constrained-decoding layer for local small language models. It uses grammar-state compatibility to restrict token selection while generation is in progress.
Instead of relying only on instructions or retrying invalid output, constrained decoding limits the token choices available at each generation step according to the supported grammar state.
THE CORE IDEA
Restrict token selection before the next token is chosen.
Maintain parser state as generated text advances through the supported structured-output grammar.
Use token-prefix compatibility to identify which vocabulary tokens remain legal from the current state.
Apply the compatibility mask before token selection, then validate the completed output.
z′ = z + M(S, V)
0 = ALLOW / −∞ = MASK
Run both generation paths against the same prompt and schema. Inspect generated text, token telemetry, and final validation.
Waiting for the first token…
—
Waiting for the first token…
NOT CHECKED
Metrics update when telemetry is received from the backend.
Based on the validation fields returned by the backend, not visual inspection of the output.
(No final output)
(No final output)
ICE sits in the decoding path. It does not replace the language model: it constrains which tokens can be selected at each step according to the supported grammar.
Let the model produce logits z. ICE constructs a mask
from the current grammar state: compatible tokens receive zero,
while incompatible tokens receive negative infinity.
z′ = z + M(S, V)
ALLOW / SUPPRESS