ChatPaper.aiChatPaper

プロンプトとプログラム間での状態共有

Sharing State Between Prompts and Programs

December 16, 2025
著者: Ellie Y. Cheng, Logan Weber, Tian Jin, Michael Carbin
cs.AI

要旨

大規模言語モデル(LLM)の台頭は、新しいプログラミングの形態、すなわち自然言語プログラミングをもたらした。ユーザーは、LLMに対して自然言語処理、コード生成、推論などを実行するよう指示するプロンプトを書くことで、LLMが実行するための自然言語によるコード、すなわち「自然言語コード」を記述している。 新たに登場した研究分野では、自然言語コードとPythonのような形式言語との間の相互運用性を実現しようとしている。本稿では、自然言語コードとプログラム状態の間の相互運用性を実現するために必要だった手作業を省く、新しいプログラミング抽象概念である「共有プログラム状態」を提案する。共有プログラム状態を用いることで、プログラマはプログラム変数への直接的な書き込み、プログラムオブジェクトを用いた計算、プログラム内での制御フローの実装を自然コードで記述できる。我々は、プログラミングシステムを拡張して自然コードをサポートする「自然関数インターフェース」を指定するためのスキーマを提示し、このスキーマを活用して共有プログラム状態を自然関数インターフェースとして規定する。 この共有プログラム状態を、Nightjarプログラミングシステムに実装した。Nightjarにより、プログラマはPythonプログラムの状態を共有する自然コードを含むPythonプログラムを記述できるようになる。Nightjarプログラムは、手動で実装した場合と比較して、同等または高いタスク精度(+4~19%向上)を達成しつつ、コード行数を平均39.6%削減できることを示す。Nightjarを使用する際のトレードオフとして、実行時のオーバーヘッドが生じる可能性がある(手動実装の0.4~4.3倍の実行時間)。
English
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).
PDF01December 20, 2025