Skip to content
Back to the collection

Efficient Guided Generation for Large Language Models

Brandon T. Willard, Rémi Louf

2023 · arXiv

Read the paper
HN score
0
Mentions
3
Readers
3
Months
3
What’s in a score?

From the 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

Metadata: arXiv. Abstracts retain their original authors’ rights.

In the conversation

Original HN comments, with labels from simple text rules. A label describes the whole comment and may miss context or irony. Read the discussion to make up your own mind. About the labels

3 selected excerpts · 3 total mentions

mcyc
Neutral mention · rule
This is a fantastic guide! I did a lot of work on structured generation for my PhD. Here are a few other pointers for people who might be interested: Some libraries: - Outlines, a nice library for structured generation - https://github.com/dottxt-ai/outlines - Guidance (already covered by FlyingLawnmower in this thread), another nice library - https://github.com/guidance-ai/guidance - XGrammar, a less-featureful but really well optimized constrained generation library - https://github.com/mlc-ai/xgrammar - This one has a lot of cool technical aspects that make it an interesting project Some papers: - Efficient Guided Generation for Large Language Models - By…
Read the full comment
the outlines authors, probably the first real LLM constrained generation paper - https://arxiv.org/abs/2307.09702 - Automata-based constraints for language model decoding - A much more technical paper about constrained generation and implementation - https://arxiv.org/abs/2407.08103 - Pitfalls, Subtleties, and Techniques in Automata-Based Subword-Level Constrained Generation - A bit of self-promotion. We show where constrained generation can go wrong and discuss some techniques for the practitioner - https://openreview.net/pdf?id=DFybOGeGDS Some blog posts: - Fast, High-Fidelity LLM Decoding with Regex Constraints - Discusses adhering to the canonical tokenization (i.e., not just the constraint, but also what would be produced by the tokenizer) - https://vivien000.github.io/blog/journal/llm-decoding-with-regex-constraints.html - Coalescence: making LLM inference 5x faster - Also from the outlines team - This is about skipping inference during constrained generation if you know there is only one valid token (common in the canonical tokenization setting) - https://blog.dottxt.ai/coalescence.html
tikhonj
Neutral mention · rule
Looks like it actually changes how you do token generation to conform to a given context-free grammar. It's a way to structure how you sample from the model rather than a tweak to the prompt, so it's more efficient and guarantees that the output matches the formal grammar. There's a reference to the paper that describes the method at the bottom of the README: https://arxiv.org/pdf/2307.09702
remilouf
Neutral mention · rule
Figure 2 in our paper (https://arxiv.org/abs/2307.09702) shows the difference between guidance and outlines to generate a sequence that is valid to a regex. Jsonformer uses the same technique as guidance. Extrapolate this to several fields. Note that we still need to manage the KV cache in outlines. It’s a small interface change that will be made this week hopefully, but we’ve been focusing on constrained generation so far.

Keep following the thread.

More in Language models

More from the same topics.