Large language models (LLMs) trained on code completion have been shown to be capable of synthesizing simple Python programs from docstrings [1]. We find that these code-writing LLMs can be re-purposed to write robot policy code, given natural language commands. Specifically, policy code can express functions or feedback loops that process perception outputs (e.g.,from object detectors [2], [3]) and parameterize control primitive APIs. When provided as input several example language commands (formatted as comments) followed by corresponding policy code (via few-shot prompting), LLMs can take in new commands and autonomously re-compose API calls to generate new policy code respectively. By chaining classic logic structures and referencing third-party libraries (e.g., NumPy, Shapely) to perform arithmetic, LLMs used in this way can write robot policies that (i) exhibit spatial-geometric reasoning, (ii) generalize to new instructions, and (iii) prescribe precise values (e.g., velocities) to ambiguous descriptions ("faster") depending on context (i.e., behavioral commonsense). This paper presents code as policies: a robot-centric formulation of language model generated programs (LMPs) that can represent reactive policies (e.g., impedance controllers), as well as waypoint-based policies (vision-based pick and place, trajectory-based control), demonstrated across multiple real robot platforms. Central to our approach is prompting hierarchical code-gen (recursively defining undefined functions), which can write more complex code and also improves state-of-the-art to solve 39.8% of problems on the HumanEval [1] benchmark. Code and videos are available at https://code-as-policies.github.io
翻译:在代码完成方面受过培训的大型语言模型(LLMS)已被证明能够将来自 docstring [1] 的简单的 Python 程序合成为简单 Python 程序。 我们发现,这些代码撰写 LLMS 可以被重新用于写入机器人政策代码, 特别是, 政策代码可以表达功能或反馈循环, 处理感知输出( 例如, 来自天体探测器 [2], [3] ), 并参数化原始 API。 当提供输入时, 一些语言指令( 格式化为批注), 并随后提供相应的政策代码( 略微提示 ) 。 LLMMS 可以在新的指令中进行整合, 可以在新的指令中进行新的命令, 自动重新配置 API 的电话来生成新的政策代码。 通过将经典逻辑结构结构结构结构( 例如, NumPY, 、 Shal Py, 和 Ricreal- descrideal ) 来进行算算算算算法。</s>