# Prompting Is Programming: A Query Language For Large Language Models

**Authors:** Luca Beurer-Kellner, Marc Fischer, Martin Vechev  
**arXiv:** [2212.06094](https://arxiv.org/abs/2212.06094)  
**Date:** 2022-12-12  
**Summary page:** https://www.summarizepaper.com/en/arxiv-id/2212.06094v1/

## 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.

## Summary

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.
