Repolode
dottxt-ai

dottxt-ai/outlines

A Python library that constrains LLM outputs during generation so they match a given type, regex, JSON schema, or grammar.

Stars
15,952
Forks
907
Open issues
197
Last commit
28 days ago

What is it?

Outlines is a Python library for structured generation with large language models. Instead of parsing and repairing free-form text after the model responds, it guides generation so the output always matches the type you request, such as a Literal choice, an int, or a Pydantic model.

You call a wrapped model with a prompt and an output type. The library supports regex patterns, JSON schemas, context-free grammars, and Python types, and it can infer structure from function signatures. Prompts can be built from reusable Jinja-based templates.

The README lists integrations with transformers, llama.cpp, vLLM, Ollama, OpenAI, and Gemini. The project is developed by the team at .txt.

Key features

  • 01Constrains generation to Literal choices, ints, and Pydantic models.
  • 02Supports regex patterns, JSON schemas, and context-free grammars.
  • 03Infers the required output structure from function signatures.
  • 04Provides Jinja-based prompt templates that can be reused or loaded from files.
  • 05Works with local models via transformers and llama.cpp, and with servers such as vLLM and Ollama.

Use cases

  • Extracting structured records such as tickets or events from free-form text.
  • Classifying documents or products into a fixed set of categories.
  • Turning natural-language requests into arguments for function calls.
  • Building reusable prompt templates for batch LLM processing.

Quick start

  1. 1

    Install outlines

    pip install outlines
  2. 2

    Load a model and run a structured generation (see README Quickstart for the full code)

Things to know

  • Examples in the README use Hugging Face Transformers models, which may need a GPU for good speed.
  • The hosted .txt API is in early access and requires requesting access.

Topics

FAQ

What is outlines?
A Python library that constrains LLM outputs during generation so they match a given type, regex, JSON schema, or grammar. Outlines is a Python library for structured generation with large language models. Instead of parsing and repairing free-form text after the model responds, it guides generation so the output always matches the type you request, such as a Literal choice, an int, or a Pydantic model.
Is outlines free to use? What license does it have?
outlines is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is outlines still maintained?
Actively maintained. The last commit to outlines was on Sep 21, 2026.
What can I use outlines for?
Extracting structured records such as tickets or events from free-form text. Classifying documents or products into a fixed set of categories. Turning natural-language requests into arguments for function calls. Building reusable prompt templates for batch LLM processing.
How do I install outlines?
Install outlines: pip install outlines Load a model and run a structured generation (see README Quickstart for the full code)
Where can I get outlines?
The source code and installation instructions are on GitHub: https://github.com/dottxt-ai/outlines

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects