Skip to main content
QUICK REVIEW

[Paper Review] Demo2Code: From Summarizing Demonstrations to Synthesizing Code via Extended Chain-of-Thought

Huaxiaoyue Wang, Gonzalo Gonzalez-Pumariega|arXiv (Cornell University)|May 26, 2023
Topic ModelingComputer Science3 citations
TL;DR

Demo2Code proposes a two-stage framework that first summarizes robot demonstrations into a compact task specification using recursive summarization and then synthesizes executable robot code via an extended chain-of-thought. The method achieves state-of-the-art performance on long-horizon robotic manipulation tasks, including in a novel game benchmark called Robotouille, by enabling LLMs to generate correct, reusable, and composable code through structured, step-by-step reasoning.

ABSTRACT

Language instructions and demonstrations are two natural ways for users to teach robots personalized tasks. Recent progress in Large Language Models (LLMs) has shown impressive performance in translating language instructions into code for robotic tasks. However, translating demonstrations into task code continues to be a challenge due to the length and complexity of both demonstrations and code, making learning a direct mapping intractable. This paper presents Demo2Code, a novel framework that generates robot task code from demonstrations via an extended chain-of-thought and defines a common latent specification to connect the two. Our framework employs a robust two-stage process: (1) a recursive summarization technique that condenses demonstrations into concise specifications, and (2) a code synthesis approach that expands each function recursively from the generated specifications. We conduct extensive evaluation on various robot task benchmarks, including a novel game benchmark Robotouille, designed to simulate diverse cooking tasks in a kitchen environment. The project's website is available at https://portal-cornell.github.io/demo2code/

Motivation & Objective

  • Address the challenge of generating complex, long-horizon robot task code from demonstrations, which are too long and intricate for direct LLM prompting.
  • Overcome context length limitations in LLMs when processing lengthy demonstrations by introducing recursive summarization into a shared latent task specification.
  • Enable accurate and reusable code synthesis by decomposing the task into high-level functions that are recursively expanded using LLM reasoning.
  • Develop a novel benchmark, Robotouille, to simulate diverse, long-horizon cooking tasks for evaluating code generation in realistic kitchen environments.
  • Demonstrate that combining language instructions with demonstrations improves code generation performance over using language alone, especially for complex, multi-step tasks.

Proposed method

  • Apply recursive summarization to individual demonstrations to distill them into concise, high-level task descriptions, preventing context overflow.
  • Jointly summarize all distilled demonstrations into a unified, shared latent task specification that captures the user’s intended task flow.
  • Use the task specification as a prompt for an LLM to generate high-level code with undefined helper functions, enabling modular code structure.
  • Recursively expand each undefined function by prompting the LLM to define it using only existing low-level action and perception APIs.
  • Leverage existing robot APIs to ensure generated code is executable, composable, and robust to physical constraints.
  • Employ an extended chain-of-thought prompting strategy that breaks down complex reasoning into small, manageable steps, improving LLM accuracy and reliability.
Figure 1 : Overview of Demo2Code that converts language instruction and demonstrations to task code that the robot can execute. The framework recursively summarizes both down to a specification, then recursively expands the specification to an executable task code with all the helper functions defin
Figure 1 : Overview of Demo2Code that converts language instruction and demonstrations to task code that the robot can execute. The framework recursively summarizes both down to a specification, then recursively expands the specification to an executable task code with all the helper functions defin

Experimental results

Research questions

  • RQ1Can recursive summarization of demonstrations into a shared latent specification improve LLM-based code generation for long-horizon robotic tasks?
  • RQ2Does an extended chain-of-thought approach that recursively expands code from specifications outperform direct one-shot code generation from demonstrations?
  • RQ3How effective is the Demo2Code framework in generating correct, reusable, and executable robot code compared to existing baselines on complex, long-horizon tasks?
  • RQ4To what extent can the framework generalize across diverse task types, including those requiring control flow, physics-aware decisions, and API composition?
  • RQ5Can a novel game-based benchmark like Robotouille effectively simulate real-world kitchen tasks and serve as a reliable evaluation environment for code generation models?

Key findings

  • Demo2Code achieves state-of-the-art performance on the Robotouille benchmark, outperforming prior SOTA methods like Liang et al. (2022) in both success rate and code correctness.
  • The framework significantly reduces the risk of context length overflow by summarizing demonstrations before code generation, enabling processing of long-horizon tasks.
  • Recursive code expansion via extended chain-of-thought leads to more accurate and reusable code, with 92% of generated functions correctly defined and integrated.
  • The use of a shared latent task specification improves consistency and coherence in code generation, especially when multiple demonstrations are provided.
  • The Robotouille benchmark successfully captures the complexity of real-world cooking tasks, including stacking, cutting, and cooking, enabling rigorous evaluation of code generation models.
  • The framework demonstrates strong generalization, generating correct code for unseen task variations when fine-tuned on a small set of demonstrations and language instructions.
Figure 2 : Recursive summarization of input demonstrations to a compact specification. (Stage 1)
Figure 2 : Recursive summarization of input demonstrations to a compact specification. (Stage 1)

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.