noamgat/lm-format-enforcer
Enforce the output format (JSON Schema, Regex etc) of a language model observed · 2026-08-28
Health v2 · maintenance only
64/100
- Activity 75
- Release rhythm 42
- Longevity 76
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-02. Adoption (stars, forks) is never an input.
- gap_med: 11
- age_days: 1077
- days_rel: 389
- days_push: 151
- n_releases_24m: 8
Adoption not part of the score
2029 stars · 92 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A Python library that enforces output formats like JSON Schema or regex on language models by filtering allowed tokens at each generation step. It integrates with transformers, LangChain, llama.cpp, vLLM, and other inference stacks.
Use cases
- force an LLM to output valid JSON matching a schema
- make a language model follow a regex output pattern
- get structured data extraction from LLM responses
- prevent malformed JSON from a chat model
- constrain model output to a pydantic model schema
- guarantee parseable LLM output for downstream pipelines
When to choose
- you need guaranteed schema-valid or regex-valid LLM output
- you use Hugging Face transformers, vLLM, llama.cpp, or LangChain and want constrained decoding
- prompt engineering alone isn't reliable enough for structured output
When to avoid
- you need function-calling or structured output built into a hosted API like OpenAI's
- your model server already provides native grammar-constrained sampling
- you work outside the Python ecosystem
Facets
library · maturity active
llm-inference parser prompt-engineering serialization large-language-models machine-learning developer-tools python structured-output -schema constrained-decoding regex-enforcement token-filtering langchain-integration transformers natural-language-processing
2 sources
- readme: https://github.com/noamgat/lm-format-enforcer · fetched 2026-08-28 · c862ee8ec38a
- registry_pypi: https://pypi.org/pypi/lm-format-enforcer/json · fetched 2026-08-29 · 77fca9570aba
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| noamgat/lm-format-enforcer | main | 64 |
For agents
markdown · JSON · MCP: product_card(name="noamgat/lm-format-enforcer")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem