arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2512.14805cs.PLcs.AI
收藏

在提示和程序之间共享状态

Sharing State Between Prompts and Programs

MIT CSAIL(麻省理工学院计算机科学与人工智能实验室)

Ellie Y. Cheng, Logan Weber, Tian Jin, Michael Carbin

AI总结:

本文提出共享程序状态抽象,使提示可直接访问程序变量并实现控制流,通过Nightjar系统验证了其在任务准确性和代码效率上的优势。

摘要:

大型语言模型的兴起引入了一种新的编程类型:自然语言编程。用户编写提示,这些提示是自然语言的指令,以指导LLM执行自然语言处理、代码生成、推理等任务。一个新兴的研究领域使提示和程序之间能够互操作。我们提出了一种新的编程抽象,即共享程序状态,它消除了使提示和程序状态之间互操作所需的手动工作。通过共享程序状态,程序员可以编写直接访问程序变量的提示,使用程序对象进行计算,并在程序中实现控制流。我们提出了一种指定自然函数接口的方案,该方案扩展了编程系统以支持带有提示的程序,并利用此方案将共享程序状态指定为自然函数接口。我们将在Nightjar编程系统中实现共享程序状态。Nightjar使程序员能够编写包含提示的Python程序,这些提示共享Python程序状态。我们展示了Nightjar程序在任务准确性上与手动编写实现相当或更高(+4-19%),同时平均减少39.6%的代码行数。权衡是Nightjar可能会带来运行时开销(0.4-4.3倍的手动实现)。

英文摘要:

The rise of large language models (LLMs) has introduced a new type of programming: natural language programming. Users write prompts, which are instructions in natural language, to direct LLMs to perform tasks such as natural language processing, code generation, reasoning, etc. An emerging area of research enables interoperability between prompts and programs. We present a novel programming abstraction, shared program state, that removes the manual work required to enable interoperability between prompts and program states. With shared program state, programmers can write prompts that directly access program variables, compute with program objects, and implement control flow in the program. We present a schema for specifying natural function interfaces that extend programming systems to support programs with prompts and leverage this schema to specify shared program state as a natural function interface. We implement shared program state in the Nightjar programming system. Nightjar enables programmers to write Python programs containing prompts that share the Python program state. We show that Nightjar programs achieve comparable or higher task accuracy than manually written implementations (+4-19%), while decreasing the lines of code by 39.6% on average. The tradeoff is that Nightjar may incur runtime overhead (0.4-4.3x manual implementations).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑