Prompting Is Programming: A Query Language for Large Language Models

被引:23
|
作者
Beurer-Kellner, Luca [1 ]
Fischer, Marc [1 ]
Vechev, Martin [1 ]
机构
[1] Swiss Fed Inst Technol, Zurich, Switzerland
关键词
language model programming; prompt programming;
D O I
10.1145/3591300
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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).
引用
收藏
页数:24
相关论文
共 50 条
  • [21] Query2doc: Query Expansion with Large Language Models
    Wang, Liang
    Yang, Nan
    Wei, Furu
    2023 CONFERENCE ON EMPIRICAL METHODS IN NATURAL LANGUAGE PROCESSING (EMNLP 2023), 2023, : 9414 - 9423
  • [22] Propagating Large Language Models Programming Feedback
    Koutcheme, Charles
    Hellas, Arto
    PROCEEDINGS OF THE ELEVENTH ACM CONFERENCE ON LEARNING@SCALE, L@S 2024, 2024, : 366 - 370
  • [23] Fully Autonomous Programming with Large Language Models
    Liventsev, Vadim
    Grishina, Anastasiia
    Harma, Aki
    Moonen, Leon
    PROCEEDINGS OF THE 2023 GENETIC AND EVOLUTIONARY COMPUTATION CONFERENCE, GECCO 2023, 2023, : 1146 - 1155
  • [24] Does Metacognitive Prompting Improve Causal Inference in Large Language Models?
    Ohtani, Ryusei
    Sakurai, Yuko
    Oyama, Satoshi
    2024 IEEE CONFERENCE ON ARTIFICIAL INTELLIGENCE, CAI 2024, 2024, : 458 - 459
  • [25] On Hardware Security Bug Code Fixes by Prompting Large Language Models
    Ahmad, Baleegh
    Thakur, Shailja
    Tan, Benjamin
    Karri, Ramesh
    Pearce, Hammond
    IEEE TRANSACTIONS ON INFORMATION FORENSICS AND SECURITY, 2024, 19 : 4043 - 4057
  • [26] Prompting Language Models for Linguistic Structure
    Blevins, Terra
    Gonen, Hila
    Zettlemoyer, Luke
    PROCEEDINGS OF THE 61ST ANNUAL MEETING OF THE ASSOCIATION FOR COMPUTATIONAL LINGUISTICS, ACL 2023, VOL 1, 2023, : 6649 - 6663
  • [27] Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
    Wei, Jason
    Wang, Xuezhi
    Schuurmans, Dale
    Bosma, Maarten
    Ichter, Brian
    Xia, Fei
    Chi, Ed H.
    Le, Quoc V.
    Zhou, Denny
    ADVANCES IN NEURAL INFORMATION PROCESSING SYSTEMS 35, NEURIPS 2022, 2022,
  • [28] A Communication Theory Perspective on Prompting Engineering Methods for Large Language Models
    Song, Yuan-Feng
    He, Yuan-Qin
    Zhao, Xue-Fang
    Gu, Han-Lin
    Jiang, Di
    Yang, Hai-Jun
    Fan, Li-Xin
    Journal of Computer Science and Technology, 2024, 39 (04) : 984 - 1004
  • [29] AskIt: Unified Programming Interface for Programming with Large Language Models
    Okuda, Katsumi
    Amarasinghe, Saman
    2024 IEEE/ACM INTERNATIONAL SYMPOSIUM ON CODE GENERATION AND OPTIMIZATION, CGO, 2024, : 41 - 54
  • [30] Enhancing Interactive Image Retrieval With Query Rewriting Using Large Language Models and Vision Language Models
    Zhu, Hongyi
    Huang, Jia-Hong
    Rudinac, Stevan
    Kanoulas, Evangelos
    PROCEEDINGS OF THE 4TH ANNUAL ACM INTERNATIONAL CONFERENCE ON MULTIMEDIA RETRIEVAL, ICMR 2024, 2024, : 978 - 987