Outlines
Python library that constrains LLM generation to schemas and grammars
What it is
Outlines is a Python library that forces language model output to match a given type, regex, JSON schema, Pydantic model, or context-free grammar while tokens are being generated, instead of fixing output afterward. The same code works across backends such as Hugging Face Transformers, vLLM, Ollama, and OpenAI. Developers building extraction, classification, or function-calling pipelines use it to get valid, parseable results every time, and it also includes reusable prompt templates.
