Code as Policies: Language Model Programs for Embodied Control

Code as Policies: Language Model Programs for Embodied Control

25 May 2023 | Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, Andy Zeng
This paper presents Code as Policies (CaP), a method for generating robot policies using large language models (LLMs) trained on code-completion. The approach allows LLMs to write robot policy code based on natural language commands, enabling spatial-geometric reasoning, generalization to new instructions, and precise control parameterization. By chaining logic structures and referencing third-party libraries, LLMs can generate policies that react to perception outputs and parameterize control APIs. The method uses hierarchical code generation, which improves performance on benchmark tasks like HumanEval, achieving 39.8% accuracy. CaP is demonstrated across multiple real robot platforms, showing its flexibility and ease of use. The approach enables robots to perform complex tasks through code-generated policies, which are interpretable and can be modified easily. The paper also discusses limitations, including the need for domain-specific data and the challenges of interpreting complex commands. Overall, CaP offers a new way to link language, perception, and action in robotics, enabling more flexible and interpretable robot policies.This paper presents Code as Policies (CaP), a method for generating robot policies using large language models (LLMs) trained on code-completion. The approach allows LLMs to write robot policy code based on natural language commands, enabling spatial-geometric reasoning, generalization to new instructions, and precise control parameterization. By chaining logic structures and referencing third-party libraries, LLMs can generate policies that react to perception outputs and parameterize control APIs. The method uses hierarchical code generation, which improves performance on benchmark tasks like HumanEval, achieving 39.8% accuracy. CaP is demonstrated across multiple real robot platforms, showing its flexibility and ease of use. The approach enables robots to perform complex tasks through code-generated policies, which are interpretable and can be modified easily. The paper also discusses limitations, including the need for domain-specific data and the challenges of interpreting complex commands. Overall, CaP offers a new way to link language, perception, and action in robotics, enabling more flexible and interpretable robot policies.
Reach us at info@study.space