The Open-Source AI Stack

The Stack · Runtime · Open source

XGrammar

Fast grammar-based constrained-decoding engine, used as a structured-output backend by several open serving engines.

Apache 2.0 · stable · Project site → · GitHub →

XGrammar, from the MLC team, is an engine for grammar-based constrained decoding focused on being fast enough to run inside a production serving loop. It compiles a JSON Schema or context-free grammar and applies the per-step token mask that keeps generation valid, with an implementation aimed at keeping that masking cheap relative to the model forward pass. Its place in the ecosystem is as a backend rather than a user-facing API. Open serving engines integrate XGrammar (and alternatives like Outlines and llguidance) as the component that enforces structure, so a request carrying a JSON Schema is handed to one of these engines under the hood. The work is described in the XGrammar paper. For open-source AI it is part of why structured output is now a standard request parameter on open engines rather than a bolt-on: the masking is fast enough that schema-constrained generation is practical at serving scale. Teams rarely call it directly; they get it through the engine they already run.

Sources

Want a follow-up? Ask the chat about XGrammar in context. It will compare to siblings at the same layer and ground every claim in the wiki.

Other projects at the Runtime layer

12 siblings · ordered open first