The Open-Source AI Stack

The Stack · Runtime · Open source

LM Format Enforcer

Token-filtering library that enforces a JSON Schema or regex during generation; integrates with Transformers, vLLM, and llama.cpp.

LM Format Enforcer constrains generation by filtering the tokens a model is allowed to emit so the output conforms to a JSON Schema or a regular expression. It is designed to plug into existing inference stacks, with integrations for Transformers, vLLM, and llama.cpp, so a team can add schema enforcement to a serving setup they already run rather than adopting a new engine. It belongs to the same enforcement family as Outlines, XGrammar, and llguidance: all of them mask the sampler to keep output valid. Its distinguishing emphasis is breadth of integration across stacks rather than being the fastest core or the most ergonomic API. That makes it a pragmatic choice when the goal is to bolt structured output onto a heterogeneous set of runtimes. For open-source AI it is one of the libraries that made schema-constrained output portable across the open serving ecosystem before the engines absorbed the capability natively.

Sources

Want a follow-up? Ask the chat about LM Format Enforcer 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