WEBVTT

00:00:01.290 --> 00:00:02.390
Hi, I'm Gumdrop!

00:00:02.390 --> 00:00:06.788
XGrammar sits under SGLang and vLLM, and stops a model emitting a

00:00:06.788 --> 00:00:08.988
tool call your program can't parse.

00:00:10.517 --> 00:00:14.124
What's new: the schema is separate from the wire syntax.

00:00:14.124 --> 00:00:18.812
One JSON description compiles to a grammar that masks the vocabulary each step.

00:00:20.717 --> 00:00:23.967
The caller declares a shape as a Structural Tag, and the compiler

00:00:23.967 --> 00:00:25.321
turns it into a grammar.

00:00:25.741 --> 00:00:29.213
Masks are precomputed into a cache, so at decode time the common

00:00:29.213 --> 00:00:30.371
case is a lookup.

00:00:30.791 --> 00:00:35.251
At every step, a token that would leave the language gets zero probability.

00:00:35.251 --> 00:00:37.309
The rest are renormalised and sampled.

00:00:37.729 --> 00:00:40.708
So there's no decode path to an invalid string.

00:00:40.708 --> 00:00:42.363
Not ninety-nine percent: a proof.

00:00:43.842 --> 00:00:47.693
In the blog's own figure, the tag is a JSON document: a

00:00:47.693 --> 00:00:50.582
schema for the arguments, between begin and end markers.

00:00:51.002 --> 00:00:55.018
The serving engine hands it to XGrammar, which constrains the model's output

00:00:55.018 --> 00:00:56.356
to follow that structure.

00:00:56.776 --> 00:01:01.361
Back comes a structured output: the answer markers, with a JSON object inside.

00:01:03.067 --> 00:01:06.271
A JSON-only decoder ties the schema to JSON.

00:01:06.271 --> 00:01:11.077
DeepSeek V4 writes tool calls as XML, with its own control tokens.

00:01:11.497 --> 00:01:16.485
Structural Tag keeps one schema and adds a style: nine wire formats, one library.

00:01:16.485 --> 00:01:20.761
Triggered tags let a model reason freely, then call a tool strictly.

00:01:22.342 --> 00:01:26.094
On the smallest Llama, the tag took schema accuracy from twenty-one

00:01:26.094 --> 00:01:27.459
percent to a hundred.

00:01:27.459 --> 00:01:30.870
Output accuracy went from five to forty-six and a half.

00:01:32.392 --> 00:01:34.982
A grammar's guarantee is unconditional, and narrow.

00:01:34.982 --> 00:01:36.462
The output always parses.

00:01:36.462 --> 00:01:39.421
Whether it's right is still the model's job.

00:01:41.192 --> 00:01:44.973
To recap: a tag becomes a grammar that masks tokens.

00:01:44.973 --> 00:01:46.864
It guarantees parsing, not correctness.

00:01:47.284 --> 00:01:49.394
Every source is in the full article.

00:01:49.394 --> 00:01:49.996
I'm Gumdrop.

00:01:49.996 --> 00:01:50.298
Bye!
