The rise of large language models (LLMs) has introduced a new type of programming: natural language programming. By writing prompts that direct LLMs to perform natural language processing, code generation, reasoning, etc., users are writing code in natural language -- natural language code -- for the LLM to execute. An emerging area of research enables interoperability between natural language code and formal languages such as Python. We present a novel programming abstraction, shared program state, that removes the manual work required to enable interoperability between natural language code and program state. With shared program state, programmers can write natural code that directly writes program variables, computes with program objects, and implements control flow in the program. We present a schema for specifying natural function interfaces that extend programming systems to support natural code 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 that contain natural code that shares 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 to using Nightjar is that it may incur runtime overhead (0.4-4.3x runtime of manual implementations).


翻译:大型语言模型(LLMs)的兴起催生了一种新型编程范式:自然语言编程。通过编写提示词来指导LLMs执行自然语言处理、代码生成、推理等任务,用户实际上是在用自然语言编写代码——即自然语言代码——供LLM执行。一个新兴的研究领域致力于实现自然语言代码与Python等形式化语言之间的互操作性。本文提出了一种新颖的编程抽象——共享程序状态,它消除了实现自然语言代码与程序状态互操作性所需的人工操作。借助共享程序状态,程序员可以编写能直接写入程序变量、与程序对象进行计算并实现程序控制流的自然代码。我们提出了一种用于规范自然函数接口的架构,该架构可扩展编程系统以支持自然代码,并利用此架构将共享程序状态定义为一种自然函数接口。我们在Nightjar编程系统中实现了共享程序状态。Nightjar使程序员能够编写包含自然代码的Python程序,这些自然代码可与Python程序状态共享数据。实验表明,Nightjar程序在任务准确率上达到或优于手动编写的实现(提升4-19%),同时平均减少39.6%的代码行数。使用Nightjar的代价是可能产生运行时开销(手动实现运行时间的0.4-4.3倍)。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
《用于代码弱点识别的 LLVM 中间表示》CMU
专知会员服务
14+阅读 · 2022年12月12日
【KDD2022】GraphMAE:自监督掩码图自编码器
专知会员服务
23+阅读 · 2022年6月12日
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
【NeurIPS2019】图变换网络:Graph Transformer Network
如何使用自然语言工具包(NLTK)在Python3中执行情感分析
Python程序员
21+阅读 · 2019年10月28日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员