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中。