TL;DR
This paper introduces Procedures as Programs (PaP), a framework that represents complex, hierarchical tasks for situated agents as high-level Python programs instead of flat action sequences. By combining a neural planner with environment-aware "reactors" to handle control flow, their Hierarchical Modular Network (HMN) dramatically improves data efficiency and success rates on long-horizon instruction-following tasks.
What Problem Does This Paper Address?
When humans plan a task like "cooking a pizza," we naturally break it down into a hierarchy of sub-tasks: buying ingredients, preheating the oven, and preparing the dough. However, most modern AI agents designed to follow natural language instructions operate on a purely reactive level. They attempt to map abstract human commands directly to a flat sequence of low-level atomic actions (e.g., MoveAhead, RotateLeft, Pickup).
This creates a massive semantic gap. A simple instruction like "reheat the bread" implies multiple unspoken steps and conditional checks (e.g., Is the microwave closed? If so, open it first.). Reactive agents struggle with these long-horizon tasks due to compounding errors, require massive amounts of labeled data to learn basic routines, and fail to generalize when environment dynamics change slightly.
Methods
The authors propose a paradigm shift: representing procedural knowledge as executable code using a general-purpose programming language (Python).
To execute these programs, they introduce Hierarchical Modular Networks (HMN), which consist of two core components:
- HMN-Planner: A sequence-to-sequence neural network that translates the user's high-level natural language intent into an executable program structure (a series of procedural or atomic function calls).
- HMN-Reactors: Environment-aware neural classifiers that act as perception APIs. When a program hits a conditional statement (like an
ifbranch or aforloop), it calls a reactor to probe the environment (e.g., checking if an object is openable or finding where an item is hidden) and returns the context-sensitive feedback needed to guide the program's execution trace.
Datasets
The framework was evaluated on two prominent embodied AI benchmarks based on the high-fidelity THOR simulator:
- IQA (Interactive Question Answering): Requires the agent to navigate and interact with the environment to answer questions about object existence, counting, or containment.
- ALFRED: A challenging benchmark where agents must map natural language to household tasks. The authors evaluated their model using only the abstract high-level intents (e.g., "Put a chilled egg in the sink") rather than step-by-step instructions.
Key Insights and Ideas
- Code as the Ultimate Abstraction: High-level programming languages are inherently modular and hierarchical. Leveraging built-in control-flow operators (
if/else,loops) allows a single high-level procedure to dynamically adapt to diverse environments without losing abstraction. - Decoupling Planning from Perception: By separating the structural logic of a task (the program) from the perceptual grounding (the reactors), the architecture becomes highly modular. You can update or fix the procedure library manually without retraining the neural networks.
- Structural Data Efficiency: Imposing a programmatic hierarchy drastically reduces the search space for the neural planner. The model doesn't have to learn how to open a microwave from scratch every time; it just learns when to call the
udp_heat_objectfunction.
Key Results
The PaP-HMN framework significantly outperformed reactive baselines across both datasets, demonstrating remarkable robustness in long-horizon and low-data scenarios.
- Massive Performance Gains on Unseen Splits: On the IQA dataset, PaP-HMN achieved 83.8% accuracy on existence questions in unseen environments, compared to a meager 18.9% from the reactive baseline.
- Conquering Long Horizons: On ALFRED tasks requiring more than 21 atomic actions, the reactive baseline's success rate dropped to near 0%. In contrast, PaP-HMN maintained a ~30% success rate on unseen environments.
- Extreme Data Efficiency: As shown in the evaluation metrics, PaP-HMN trained on just 20% of the dataset outperformed the reactive baseline trained on 100% of the data by a wide margin.
Limitations and Future Work
Despite its success, the authors note a few key limitations:
- Manual Library Curation: The high-level Python functions currently require human engineering. While the authors show that a programmer unfamiliar with the dataset can write a functional library in under two hours, it remains a bottleneck for scaling to open domains.
- Rigid Control Flows: Real-world environments feature endless variations. Exhaustively enumerating every edge case in static code blocks is impractical.
Future Directions: The authors suggest automating library creation by mining structured procedural knowledge from the web or using unsupervised learning (like minimum description length encoding) to automatically extract high-level sub-routines from raw action traces. They also propose designing hybrid systems that fall back to reactive atomic control when a predefined program fails.
Summary updated