Efficient Guided Generation for Large Language Models

Brandon T. Willard, Rémi Louf
7/19/2023
288 citations
cs.CLcs.LG

Official code: dottxt-ai/outlines (16,012 stars, Python, Apache-2.0, last commit 2026-04-16).

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.

Show full abstract

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

View on arXivView PDF

Code Implementations(1)

dottxt-ai/outlinesOfficial100%
Apache-2.0

Structured Outputs

16,012919Python, NixMar 17, 20237 months agoApache-2.0
cfggenerative-aijsonllmsprompt-engineering+3 more

Similar Papers

Cite this paper

@article{willard2023efficient,
  title  = {Efficient Guided Generation for Large Language Models},
  author = {Brandon T. Willard and Rémi Louf},
  year   = {2023},
  eprint = {2307.09702},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2307.09702v4}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2307.09702.svg)](https://codeofpaper.com/paper/2307.09702)

Discussion