Prompting Is Programming: A Query Language For Large Language Models

AI-generated keywords: Language Model Programming (LMP) LMQL Language Model Query Language constraints control flow

AI-generated Key Points

  • The paper introduces Language Model Programming (LMP)
  • LMP generalizes language model prompting from pure text prompts to a combination of text prompting and scripting
  • LMP allows constraints to be specified over the language model output, enabling easy adaptation to many tasks while abstracting language model internals and providing high-level semantics
  • LMQL (Language Model Query Language) is implemented to enable LMP
  • LMQL leverages 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
  • 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
  • Constraining language models has been applied across various fields, including semantic parsing tasks and source code generation
  • Evaluation shows that LMQL retains or increases accuracy on several downstream tasks while significantly reducing computation costs by up to 80%
  • Overall, this work presents a novel way to interact with large language models and provides a powerful tool for developers looking to integrate them into many applications.
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

Authors: Luca Beurer-Kellner, Marc Fischer, Martin Vechev

21 pages + Appendix
License: CC BY 4.0

Abstract: 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 (13-85% cost savings).

Submitted to arXiv on 12 Dec. 2022

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2212.06094v1

The paper introduces the concept of Language Model Programming (LMP), which generalizes language model prompting from pure text prompts to an intuitive combination of text prompting and scripting. LMP allows constraints to be specified over the language model output, enabling easy adaptation to many tasks while abstracting language model internals and providing high-level semantics. To enable LMP, the authors implement LMQL (Language Model Query Language), which leverages 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. The authors demonstrate 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. The paper also discusses how constraining language models has been applied across various fields, including semantic parsing tasks and source code generation. The evaluation shows that LMQL retains or increases accuracy on several downstream tasks while significantly reducing computation costs by up to 80%. Overall, this work presents a novel way to interact with large language models and provides a powerful tool for developers looking to integrate them into many applications.
Created on 08 Apr. 2023

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Look for similar papers (in beta version)

By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.