🤖 AI Summary
This paper addresses the state fragmentation between natural-language prompts and formal programs (e.g., Python), which necessitates manual interoperability implementation. To resolve this, we propose a shared program state abstraction mechanism, underpinned by a novel Natural Function Interface (NFI) specification that unifies runtime state across natural-language code and host programs—enabling seamless variable access, object manipulation, and control-flow coordination. Implemented in the Nightjar system, our approach integrates natural-language interface compilation, state bridging, and dynamic execution scheduling to achieve, for the first time, fully transparent state interoperability within a programming environment. Experiments demonstrate a 4–19% improvement in task accuracy, a 39.6% average reduction in generated code length, and runtime overhead ranging from 0.4× to 4.3× that of manual implementations. Our core contribution is establishing a state-consistency paradigm for collaborative execution between natural and formal languages.
📝 Abstract
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).