TL;DR
ProgPrompt is a novel prompting strategy that enables Large Language Models (LLMs) to function as situated robot task planners by framing plans as Pythonic programs. By using code structures like imports, comments, and assertions, it bridges the gap between high-level natural language instructions and executable robot actions that respond to real-time environment feedback.
What Problem Does This Paper Address?
While LLMs like GPT-3 possess immense "common sense" world knowledge, applying them to robotics is difficult. Standard natural language prompts often lead to "hallucinated" actions—the LLM might suggest "opening a jar" when the robot doesn't have a "jar-opening" primitive, or it might suggest "picking up a chicken" when there is no chicken in the room.
The core challenge is situatedness: a robot needs a plan that is compatible with its specific API, aware of the objects actually present in its environment, and capable of recovering when things go wrong (e.g., trying to open a microwave that is already open).
Methods
The authors introduce ProgPrompt, which moves away from free-form text and instead prompts the LLM to generate a Python function. The prompt consists of three main components:
- Action Primitives (Imports): A list of functions the robot can actually execute (e.g.,
grab(obj),find(obj)). - Environment State (Object List): A list of all objects currently detected in the scene.
- Example Tasks: A few "few-shot" examples of tasks written as Python functions, complete with logic.
Two key programmatic features make this work:
- Comments as "Chain of Thought": Natural language comments (e.g.,
# 1: find the lime) help the LLM decompose complex goals into sub-tasks. - Assertions for Feedback: The generated code includes
assertstatements to check preconditions. If an assertion fails (e.g., the robot isn't close enough to an object), the code includes anelseblock with recovery actions (e.g.,find(obj)).
Datasets
The researchers evaluated ProgPrompt in two main settings:
- VirtualHome (VH): A simulated environment for household tasks. They created a dataset of 70 tasks (e.g., "microwave salmon," "wash the plate") across three different virtual houses containing 115 unique objects.
- Physical Robot: They deployed the system on a Franka-Emika Panda robot arm for tabletop manipulation tasks, using an open-vocabulary object detector (ViLD) to generate the object list for the prompt.
Key Insights and Ideas
- Code is a Natural Constraint: LLMs are trained on vast amounts of code and documentation. Framing a task as a programming problem naturally encourages the model to follow a strict syntax and use only the "imported" functions provided in the prompt.
- The Power of Comments: The authors found that including natural language comments within the code significantly improved success rates. This acts as a "Chain of Thought," allowing the model to "think out loud" before generating the corresponding API calls.
- Closed-Loop Planning: By using
assertstatements, the plan becomes a living document. The robot doesn't just execute a blind sequence of steps; it checks the environment state at each critical juncture, allowing for basic error recovery.
Key Results
ProgPrompt significantly outperformed existing baselines in the VirtualHome environment:
- Success Rate (SR): ProgPrompt achieved a 0.40 SR using the Codex backbone, compared to 0.00 for prior state-of-the-art natural language methods that struggled to generate executable sequences.
- Executability: Plans generated by ProgPrompt were highly compatible with the robot's API, with an executability score of 0.90, meaning nearly all generated actions were valid commands.
- Generalization: The system successfully generalized to new environments and tasks it hadn't seen in the few-shot examples, such as identifying that "cutlery" refers to "forks and spoons" in a new scene.
Limitations and Future Work
Despite its success, the authors noted several areas for improvement:
- Simulator Constraints: Some failures occurred because the VirtualHome agent had physical limitations (like not being able to reach objects while sitting) that weren't communicated to the LLM.
- Action Success Feedback: While the system checks preconditions via assertions, it doesn't currently check if an action actually succeeded after execution (e.g., did the object actually get picked up, or did it slip?).
- Complex Logic: Future work aims to incorporate more advanced programming features, such as using real-valued numbers for precise measurements and nested dictionaries to represent complex scene graphs.
Summary updated