AIOS Compiler: LLM as Interpreter for Natural Language Programming and Flow Programming of AI Agents

Shuyuan Xu,Zelong Li,Kai Mei,Yongfeng Zhang
2024-05-22
Abstract:Since their inception, programming languages have trended towards greater readability and lower barriers for programmers. Following this trend, natural language can be a promising type of programming language that provides great flexibility and usability and helps towards the democracy of programming. However, the inherent vagueness, ambiguity, and verbosity of natural language pose significant challenges in developing an interpreter that can accurately understand the programming logic and execute instructions written in natural language. Fortunately, recent advancements in Large Language Models (LLMs) have demonstrated remarkable proficiency in interpreting complex natural language. Inspired by this, we develop a novel system for Code Representation and Execution (CoRE), which employs LLM as interpreter to interpret and execute natural language instructions. The proposed system unifies natural language programming, pseudo-code programming, and flow programming under the same representation for constructing language agents, while LLM serves as the interpreter to interpret and execute the agent programs. In this paper, we begin with defining the programming syntax that structures natural language instructions logically. During the execution, we incorporate external memory to minimize redundancy. Furthermore, we equip the designed interpreter with the capability to invoke external tools, compensating for the limitations of LLM in specialized domains or when accessing real-time information. This work is open-source at
Computation and Language,Artificial Intelligence,Machine Learning,Programming Languages
What problem does this paper attempt to address?
The main issues this paper attempts to address are logical representation, instruction execution, and cross-step information management in natural language programming. Specifically: 1. **Logical Representation**: How to use natural language instructions to represent the logic of a program. To solve this problem, the authors designed a set of programming syntax to logically structure natural language instructions, unifying natural language programming, pseudocode programming, and flow programming under the same representation. 2. **Instruction Execution**: Ensuring that each step can be executed precisely according to the corresponding instructions. To achieve this, the authors designed two additional components: one for retrieving information from memory and another for calling external tools. These components help large language models (LLMs) execute natural language instructions more efficiently and accurately. 3. **Cross-Step Information Management**: Considering the limitation of the number of input tokens (i.e., context window size) for LLMs, it is impractical to include all runtime information directly in the input prompt. Therefore, the authors addressed this issue by temporarily storing a large amount of intermediate results and retrieving relevant information as needed in subsequent steps. By addressing these issues, the paper proposes a new system called CoRE, which utilizes large language models as interpreters to interpret and execute programs written in natural language. This lowers the barrier to programming, enabling non-professional programmers to easily create AI agents.