lm-format-enforcer
the six Ws · specification
Independent developer Noam Gat created and maintains lm-format-enforcer.
A Python library that forces LLM output to strictly follow a JSON Schema or regular expression by filtering logits during generation.
Runs locally as a Python package integrated with Hugging Face Transformers, llama.cpp, vLLM, and other inference backends.
Released in 2023 and actively maintained through 2026.
Guarantees schema-valid structured output for local model inference, including with beam search and batched generation.
Combines a character-level parser with a tokenizer prefix tree and integrates with Transformers, llama-cpp-python, vLLM, and Haystack.
Open-source (MIT license) on GitHub, runs entirely locally against the model's logits, no external service or data transmission.