In this article we describe an efficient approach to guiding language model text generation with regular expressions and context-free grammars. Our approach adds little to no overhead to the token sequence generation process, and makes guided generation feasible in practice. An implementation is provided in the open source Python library Outlines.
翻译:本文描述了一种利用正则表达式和上下文无关文法来引导语言模型文本生成的高效方法。该方法几乎不会给令牌序列生成过程增加额外开销,使得引导生成在实践中切实可行。我们在开源Python库Outlines中提供了具体实现。