What problem does it solve?
You avoid brittle, post-validated generations that produce malformed JSON, XML, or code by constraining the model to emit only tokens that keep the output structurally valid.
Core Features & Use Cases
- Guaranteed structured generation: Enforce valid JSON/XML/code structure during decoding so invalid outputs are impossible.
- Type-safe outputs with Pydantic: Define schemas via Pydantic models and generate directly into strongly-typed objects.
- Fast, grammar-level constraints: Compile schemas to grammar/FSM and filter tokens at generation time for speed and correctness.
- Flexible backend support: Run with local models (Transformers, llama.cpp, vLLM) or limited API backends (OpenAI) depending on your deployment needs.
- Common use cases: data extraction, classification, form processing, API spec/code generation, and other workflows where downstream systems require strict structure.
Quick Start
Use outlines with a local Transformer model to generate a Pydantic-defined JSON object from a prompt while enforcing the schema automatically.