Neural Task Programming: Learning to Generalize Across Hierarchical Tasks

Danfei Xu

Abstract

Neural Task Programming (NTP) is a hierarchical learning framework designed to enable robots to perform complex, long-horizon tasks by interpreting a single demonstration. By combining the modularity of symbolic programs with the flexibility of neural networks, NTP generalizes learned skills to novel scenarios with varying object counts, task orders, and goal conditions.

Introduction

Teaching robots to perform long-term tasks—such as warehouse sorting or table clearing—remains a significant challenge in robotics. Traditional "flat" policies, which map observations directly to actions, often fail when environmental conditions shift, such as when the number of objects increases or the required sequence of operations changes.

While Learning from Demonstration (LfD) allows robots to acquire skills from human examples, most LfD methods struggle with generalization, often memorizing specific trajectories. Conversely, Neural Program Induction can learn complex logic but typically requires fixed task definitions. Neural Task Programming (NTP) bridges this gap by enabling a robot to interpret a new task specification (e.g., a video of a human stacking blocks) and translate it into a structured, hierarchical plan that adapts to the current workspace.

Methods: The NTP Architecture

NTP treats a task as a recursive program. The architecture consists of three primary components:

  1. Task Specification Encoder: Transforms the demonstration (e.g., a video or object trajectory) into a mathematical embedding.
  2. Core Network: A neural controller that evaluates the current environment and task embedding to decide whether to call a sub-program or signal the "End of Program" (EOP).
  3. Task Specification Interpreter (The "Scoper"): This mechanism identifies the specific segment of the original demonstration relevant to a called sub-task. This "scoping" enforces information hiding, ensuring lower-level actions are not distracted by irrelevant parts of the long-term goal.
Figure 1: Overview of the Neural Task Programming (NTP) framework, showing the transition from a task demonstration to a task-conditional policy.

NTP does not output raw motor torques. Instead, it interfaces with Robot APIs (e.g., move_to, grip, release), allowing the model to reason at a high level while standard motion planners handle low-level physics.

Experimental Evaluation

The researchers evaluated NTP on three manipulation tasks in a 3D Bullet Physics simulator and a real-world 7-DoF Sawyer robot: Object Sorting, Block Stacking, and Table Clean-up. The models were trained on "execution traces"—step-by-step logs of correct task performance.

Key Insights and Results

A critical finding is that "scoping" the demonstration is essential for generalization. By forcing sub-programs to focus only on their relevant demonstration segments, NTP learns modular, reusable skills.

Generalization Across Dimensions

NTP demonstrates robustness across three key variations:

  • Task Length: If trained on sorting 4 objects, the model can scale to 40 objects.
  • Topology: It handles sub-tasks performed in different orders than seen during training.
  • Semantics: It can achieve unseen goal configurations by following the logic of a new demonstration.
Figure 5: Success rate of NTP vs. baseline models as the number of objects increases in the sorting task.

In the Object Sorting task, NTP maintained a success rate above 90% as the number of objects increased from 4 to 40. In contrast, "flat" baseline models saw performance drop to approximately 25%. Furthermore, NTP transferred to a physical Sawyer robot with a 90% success rate on block stacking and 80% on object sorting.

Limitations and Future Work

Despite its strengths, NTP relies on a pre-defined set of symbolic APIs; adding new actions requires manual expansion. Additionally, training requires detailed "program traces," which are more difficult to collect than simple videos. Future work aims to improve the perception bottleneck, as cascading errors in object detection can still lead to task failure.

Summary updated

BibTeX
@inproceedings{xu2018neural,
  author = {Danfei Xu},
  title = {{Neural Task Programming: Learning to Generalize Across Hierarchical Tasks}},
  booktitle = {IEEE International Conference on Robotics and Automation},
  year = {2018},
  doi = {10.1109/icra.2018.8460689},
}
Figure