Introduction
Large Language Models (LLMs) like GPT-3 possess extensive "common sense" knowledge about the world. However, applying this knowledge to robotics is challenging because LLMs lack situated awareness. A standard LLM might suggest actions that are impossible in the robot's current environment or generate instructions that do not align with the robot's specific API. Previous attempts to bridge this gap often resulted in "hallucinated" actions or required exhaustive, pre-defined step lists.
ProgPrompt addresses this by treating robot task planning as a code-generation problem. By constraining the LLM to a Pythonic structure, researchers can ground the model's reasoning within the robot's specific capabilities and immediate surroundings.
Methodology: The ProgPrompt Framework
The core of the approach is a prompting scheme that formats the robot’s world and capabilities as a Python program. Instead of natural language instructions, the LLM is provided with a structured prompt containing:
- Action Primitives: An
importstatement listing available robot actions (e.g.,grab,open,find). - Environment State: A list of strings representing objects currently detected in the environment, grounding the LLM in its physical context.
- Few-Shot Examples: Fully defined Python functions representing completed tasks to guide the model's output format.
- State Feedback via Assertions: The generated code includes
assertstatements to check preconditions. If an assertion fails, "recovery actions" in anelseblock allow the robot to correct the state before proceeding. - Chain-of-Thought Comments: Natural language comments (e.g.,
# 1: find the salmon) encourage the LLM to decompose complex goals into logical sub-tasks before generating code.
Experimental Evaluation
ProgPrompt was evaluated in two distinct settings:
- VirtualHome (VH): A simulation platform where the system was tested on 70 household tasks across three environments with 115 unique objects.
- Physical Robot: Deployment on a Franka-Emika Panda robot arm for tabletop tasks. Real-world objects were identified using ViLD, an open-vocabulary object detector, to populate the prompt's object list.
Key Results and Insights
The programmatic structure of ProgPrompt significantly improves both the success rate and the executability of generated plans. By presenting robot actions as a library, the LLM is effectively constrained to the robot's functional boundaries. Furthermore, the inclusion of natural language comments acts as a "Chain of Thought," reducing repetitive or incoherent outputs.
As shown in the results table, ProgPrompt (using the Codex backbone) achieved a Success Rate (SR) of 40% in VirtualHome, a stark contrast to the 0% achieved by natural language baselines. Additionally, 90% of the generated actions were executable. Ablation studies confirmed that both comments and state feedback (assertions) are critical; removing comments dropped the Success Rate from 34% to 18% when using GPT-3.
Limitations and Future Work
While ProgPrompt represents a significant step forward, several limitations remain. In simulation, agents occasionally failed due to environment-specific constraints (e.g., inability to interact while sitting) that the LLM did not fully grasp. Token limits in LLMs also pose a challenge for extremely complex tasks, which may result in truncated plans.
Future research will explore incorporating real-valued numbers for precise measurements, nested dictionaries for complex scene graphs, and more sophisticated control flows to handle highly dynamic real-world environments.
Summary updated