Large Language Models (LLMs) have become increasingly capable of handling diverse tasks with the aid of well-crafted prompts and integration of external tools, but as task complexity rises, the workflow involving LLMs can be complicated and thus challenging to implement and maintain. To address this challenge, we propose APPL, A Prompt Programming Language that acts as a bridge between computer programs and LLMs, allowing seamless embedding of prompts into Python functions, and vice versa. APPL provides an intuitive and Python-native syntax, an efficient parallelized runtime with asynchronous semantics, and a tracing module supporting effective failure diagnosis and replaying without extra costs. We demonstrate that APPL programs are intuitive, concise, and efficient through three representative scenarios: Chain-of-Thought with self-consistency (CoT-SC), ReAct tool use agent, and multi-agent chat. Experiments on three parallelizable workflows further show that APPL can effectively parallelize independent LLM calls, with a significant speedup ratio that almost matches the estimation.
翻译:大型语言模型(LLMs)借助精心设计的提示和外部工具的集成,已能处理日益多样的任务,但随着任务复杂度的提升,涉及LLMs的工作流可能变得复杂,从而难以实现和维护。为应对这一挑战,我们提出了APPL,一种提示编程语言,它充当计算机程序与LLMs之间的桥梁,允许将提示无缝嵌入Python函数,反之亦然。APPL提供直观且符合Python原生习惯的语法、具备异步语义的高效并行化运行时,以及支持有效故障诊断和无额外成本重放的追踪模块。我们通过三个代表性场景——思维链自洽性推理(CoT-SC)、ReAct工具使用智能体和多智能体对话——展示了APPL程序具有直观、简洁和高效的特点。在三个可并行化工作流上的实验进一步表明,APPL能有效并行化独立的LLM调用,其显著加速比几乎与理论估计相符。