arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2212.06094cs.CLcs.AI
收藏

提示即编程:一种面向大语言模型的查询语言

Prompting Is Programming: A Query Language for Large Language Models

ETH Zurich(苏黎世联邦理工学院)

Luca Beurer-Kellner, Marc Fischer, Martin Vechev

AI总结:

本文提出语言模型编程(LMP)思想并实现查询语言 LMQL,将文本提示与脚本和约束结合,在保持或提高下游任务准确率的同时显著降低计算成本。

摘要:

大语言模型在问答和代码生成等广泛任务上表现出了卓越的性能。从高层来看,给定一个输入,语言模型可以被用来以统计上可能的方式自动补全序列。基于此,用户通过语言指令或示例来提示这些模型,以实现各种下游任务。先进的提示方法甚至可以隐含语言模型、用户和计算器等外部工具之间的交互。然而,为了获得最先进的性能或使语言模型适应特定任务,必须实现复杂的、任务和模型特定的程序,这可能仍然需要临时的交互。基于此,我们提出了语言模型编程(LMP)这一新颖思想。LMP 将语言模型提示从纯文本提示推广为文本提示与脚本编写的直观组合。此外,LMP 允许对语言模型输出指定约束。这使得能够轻松适应许多任务,同时抽象掉语言模型内部细节并提供高层语义。为了实现 LMP,我们实现了 LMQL(Language Model Query Language 的缩写),它利用 LMP 提示中的约束和控制流来生成高效的推理过程,从而最大限度地减少对底层语言模型的昂贵调用次数。我们表明,LMQL 能够以直观的方式涵盖广泛的最先进提示方法,尤其有助于实现用现有高级 API 难以实现的交互式流程。我们的评估表明,在若干下游任务上我们保持或提高了准确率,同时在按使用付费的 API 场景中显著减少了所需的计算量或成本(节省 26-85% 的成本)。

英文摘要:

Large language models have demonstrated outstanding performance on a wide range of tasks such as question answering and code generation. On a high level, given an input, a language model can be used to automatically complete the sequence in a statistically-likely way. Based on this, users prompt these models with language instructions or examples, to implement a variety of downstream tasks. Advanced prompting methods can even imply interaction between the language model, a user, and external tools such as calculators. However, to obtain state-of-the-art performance or adapt language models for specific tasks, complex task- and model-specific programs have to be implemented, which may still require ad-hoc interaction. Based on this, we present the novel idea of Language Model Programming (LMP). LMP generalizes language model prompting from pure text prompts to an intuitive combination of text prompting and scripting. Additionally, LMP allows constraints to be specified over the language model output. This enables easy adaption to many tasks while abstracting language model internals and providing high-level semantics. To enable LMP, we implement LMQL(short for Language Model Query Language), which leverages the constraints and control flow from an LMP prompt to generate an efficient inference procedure that minimizes the number of expensive calls to the underlying language model. We show that LMQL can capture a wide range of state-of-the-art prompting methods in an intuitive way, especially facilitating interactive flows that are challenging to implement with existing high-level APIs. Our evaluation shows that we retain or increase the accuracy on several downstream tasks, while also significantly reducing the required amount of computation or cost in the case of pay-to-use APIs (26-85% cost savings).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑