Efficiency

Outlines (Efficient Guided Generation)

First page
Outlines (Efficient Guided Generation)
Paper summary

A library for guided LLM text generation that enforces structural constraints with minimal overhead.

Ask this paper

Key points
01

Regex guarantees: Guarantees that generated output matches a specified regular expression, supporting grammar-constrained generation at the token level.

02

JSON schema enforcement: Produces output that follows a JSON schema, unlocking reliable structured-output generation without post-hoc parsing retries.

03

Fast implementation: Achieves low overhead via efficient state-machine construction and token-mask caching, making constrained decoding practical in production.

04

Broad adoption: Became widely used in LLM pipelines where structured output is non-negotiable - function calling, tool use, API output, and data extraction.

Abstract

In this article we show how the problem of neural text generation can be constructively reformulated in terms of transitions between the states of a finite-state machine. This framework leads to an efficient approach to guiding text generation with regular expressions and context-free grammars by allowing the construction of an index over a language model's vocabulary. The approach is model agnostic, allows one to enforce domain-specific knowledge and constraints, and enables the construction of reliable interfaces by guaranteeing the structure of the generated text. It adds little overhead to the token sequence generation process and significantly outperforms existing solutions. An implementation is provided in the open source Python library Outlines

Every Monday
Get next week’s papers.
Subscribe on Substack