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 条
  • [1] Considerations for Prompting Large Language Models
    Schulte, Brian
    JAMA ONCOLOGY, 2024, 10 (04) : 538 - 538
  • [2] Graph Neural Prompting with Large Language Models
    Tian, Yijun
    Song, Huan
    Wang, Zichen
    Wang, Haozhu
    Hu, Ziqing
    Wang, Fang
    Chawla, Nitesh V.
    Xu, Panpan
    THIRTY-EIGHTH AAAI CONFERENCE ON ARTIFICIAL INTELLIGENCE, VOL 38 NO 17, 2024, : 19080 - 19088
  • [3] Prompting Large Language Models With the Socratic Method
    Chang, Edward Y.
    2023 IEEE 13TH ANNUAL COMPUTING AND COMMUNICATION WORKSHOP AND CONFERENCE, CCWC, 2023, : 351 - 360
  • [4] Prompting Large Language Models to Power Educational Chatbots
    Farah, Juan Carlos
    Ingram, Sandy
    Spaenlehauer, Basile
    Lasne, Fanny Kim-Lan
    Gillet, Denis
    ADVANCES IN WEB-BASED LEARNING, ICWL 2023, 2023, 14409 : 169 - 188
  • [5] DDPrompt: Differential Diversity Prompting in Large Language Models
    Mu, Lin
    Zhang, Wenhan
    Zhang, Yiwen
    Jin, Peiquan
    PROCEEDINGS OF THE 62ND ANNUAL MEETING OF THE ASSOCIATION FOR COMPUTATIONAL LINGUISTICS, VOL 2: SHORT PAPERS, 2024, : 168 - 174
  • [6] Editing Graph Visualizations by Prompting Large Language Models
    Argyriou, Evmorfia
    Boehm, Jens
    Eberle, Anne
    Gonser, Julius
    Lumpp, Anna-Lena
    Niedermann, Benjamin
    Schwarzkopf, Fabian
    GRAPH DRAWING AND NETWORK VISUALIZATION, GD 2023, PT II, 2023, 14466 : 253 - 254
  • [7] Considerations for Prompting Large Language Models-Reply
    Chen, Shan
    Savova, Guergana K.
    Bitterman, Danielle S.
    JAMA ONCOLOGY, 2024, 10 (04) : 538 - 539
  • [8] Prompting is not a substitute for probability measurements in large language models
    Hu, Jennifer
    Levy, Roger
    2023 CONFERENCE ON EMPIRICAL METHODS IN NATURAL LANGUAGE PROCESSING, EMNLP 2023, 2023, : 5040 - 5060
  • [9] PROMPTING LARGE LANGUAGE MODELS WITH SPEECH RECOGNITION ABILITIES
    Fathullah, Yassir
    Wu, Chunyang
    Lakomkin, Egor
    Jia, Junteng
    Shangguan, Yuan
    Li, Ke
    Guo, Jinxi
    Xiong, Wenhan
    Mahadeokar, Jay
    Kalinli, Ozlem
    Fuegen, Christian
    Seltzer, Mike
    2024 IEEE INTERNATIONAL CONFERENCE ON ACOUSTICS, SPEECH AND SIGNAL PROCESSING (ICASSP 2024), 2024, : 13351 - 13355
  • [10] Prompting Large Language Models for Automatic Question Tagging
    Xu, Nuojia
    Xue, Dizhan
    Qian, Shengsheng
    Fang, Quan
    Hu, Jun
    MACHINE INTELLIGENCE RESEARCH, 2025,