Large Language Models (LLMs) exhibit a unique phenomenon known as emergent abilities, demonstrating adeptness across numerous tasks, from text summarization to code generation. While these abilities open up novel avenues in software design and crafting, their incorporation presents substantial challenges. Developers face decisions regarding the use of LLMs for directly performing tasks within applications as well as for generating and executing code to accomplish these tasks. Moreover, effective prompt design becomes a critical concern, given the necessity of extracting data from natural language outputs. To address these complexities, this paper introduces AskIt, a domain-specific language (DSL) specifically designed for LLMs. AskIt simplifies LLM integration by providing a unified interface that not only allows for direct task execution using LLMs but also supports the entire cycle of code generation and execution. This dual capability is achieved through (1) type-guided output control, (2) template-based function definitions, and (3) prompt generation for both usage modes. Our evaluations underscore AskIt's effectiveness. Across 50 tasks, AskIt generated concise prompts, achieving a 16.14 % reduction in prompt length compared to benchmarks. Additionally, by enabling a seamless transition between using LLMs directly in applications and for generating code, AskIt achieved significant efficiency improvements, as observed in our GSM8K benchmark experiments. The implementations of AskIt in TypeScript and Python are available at https://github.com/katsumiok/ts-askit and https://github.com/katsumiok/pyaskit, respectively.
翻译:摘要:大型语言模型(LLMs)展现出一种称为涌现能力的独特现象,在从文本摘要到代码生成的众多任务中表现出色。尽管这些能力为软件设计与开发开辟了全新路径,但其整合过程仍面临重大挑战。开发者在决定是否直接利用LLMs在应用程序中执行任务、还是通过生成并执行代码来完成这些任务时,需要审慎权衡。此外,由于必须从自然语言输出中提取数据,有效的提示词设计成为关键问题。为应对这些复杂性,本文提出AskIt——一种专为LLMs设计的领域特定语言(DSL)。AskIt通过提供统一接口简化LLM集成,不仅支持直接使用LLMs执行任务,还能实现代码生成与执行的全流程支持。这种双重能力通过以下方式实现:(1)类型引导的输出控制;(2)基于模板的函数定义;(3)针对两种使用模式的提示词生成机制。评估结果验证了AskIt的有效性。在50项任务中,AskIt生成的提示词相较基准方法实现16.14%的长度缩减。此外,通过支持在应用程序中直接使用LLMs与生成代码两种模式间的无缝转换,AskIt在GSM8K基准测试中展现出显著的效率提升。AskIt的TypeScript与Python实现代码已分别发布于https://github.com/katsumiok/ts-askit 和 https://github.com/katsumiok/pyaskit。