outlines  by dottxt-ai

SDK for structured LLM text generation

created 2 years ago
12,187 stars

Top 4.1% on sourcepulse

GitHubView on GitHub
Project Summary

Outlines is a Python library designed to make Large Language Models (LLMs) produce structured text outputs, enabling more predictable and reliable integration with applications. It targets developers and researchers seeking to enhance LLM performance and efficiency by enforcing output constraints.

How It Works

Outlines leverages various structured generation techniques, including multiple choice selection, type constraints (integers, floats), regular expression matching, and context-free grammars (CFGs) in EBNF format. It also supports generating outputs that conform to Pydantic models or JSON schemas, and can infer structure from Python function signatures. This approach aims to improve LLM performance, speed up inference, and reduce the need for extensive post-processing or prompt engineering.

Quick Start & Requirements

  • Install via pip: pip install outlines
  • Supports Hugging Face transformers, llama.cpp, exllama2, mamba, OpenAI, and others.
  • Requires Python 3.7+.
  • Official Docker image available: outlinesdev/outlines.
  • Documentation: https://outlines-dev.github.io/outlines/

Highlighted Details

  • Fast JSON generation with Pydantic models or JSON schemas.
  • Efficient regex-structured generation, nearly matching unstructured generation speed.
  • Supports CFGs for complex structured text generation (e.g., arithmetic expressions, SQL).
  • Can infer output structure from Python function signatures for direct integration.
  • Jinja2 templating for streamlined prompt construction.

Maintenance & Community

Licensing & Compatibility

  • License: MIT.
  • Compatible with commercial use and closed-source applications.

Limitations & Caveats

  • Some Pydantic field constraints are not yet supported.
  • Users must manually apply chat template tokens for instruct models.
Health Check
Last commit

11 hours ago

Responsiveness

Inactive

Pull Requests (30d)
16
Issues (30d)
16
Star History
733 stars in the last 90 days

Explore Similar Projects

Starred by Tobi Lutke Tobi Lutke(Cofounder of Shopify), Stas Bekman Stas Bekman(Author of Machine Learning Engineering Open Book; Research Engineer at Snowflake), and
21 more.

guidance by guidance-ai

0.1%
21k
Guidance is a programming paradigm for steering LLMs
created 2 years ago
updated 22 hours ago
Feedback? Help us improve.