Hierarchical Programmatic Option Framework

Yu-An Lin, Chen-Tao Lee, Chih-Han Yang, Guan-Ting Liu, Shao-Hua Sun

TL;DR

HIPO is a novel reinforcement learning framework designed to solve complex, long-horizon tasks by utilizing human-readable programs as reusable "options" (sub-policies). By combining the interpretability of code with the structural advantages of hierarchical reinforcement learning, HIPO achieves superior performance and remarkable zero-shot generalization on repetitive tasks compared to traditional "black-box" neural networks.

The Challenge: Trust and Generalization in DRL

Deep Reinforcement Learning (DRL) has mastered everything from board games to complex robotics, but it suffers from two major vulnerabilities:

  1. Interpretability: Neural network policies act as black boxes. Understanding why an agent made a specific decision is incredibly difficult, which is a dealbreaker for safety-critical applications.
  2. Generalization: A DRL agent trained on a small environment (e.g., a $10 \times 10$ grid) often fails catastrophically when deployed in a larger version of the same environment (e.g., a $20 \times 20$ grid).

Programmatic RL attempts to resolve this by representing policies as human-readable code (e.g., while(frontIsClear): move()). Code is inherently interpretable and generalizes perfectly across scales. However, searching for a single, massive program to solve a long, complex task is computationally intractable due to the exploding search space. HIPO addresses this bottleneck by breaking the problem down: instead of searching for one giant program, it searches for a library of small, reusable "programmatic options."

Methods: The HIPO Framework

Overview of the HIPO framework

The HIPO framework operates in three distinct stages to build its hierarchical policy:

  1. Constructing a Program Embedding Space: The authors utilize a Variational Autoencoder (VAE) to map discrete, non-differentiable code into a smooth, continuous latent space. This transformation allows the system to "search" for programs using standard continuous optimization techniques.
  2. Retrieving Programmatic Options: This is the core innovation. HIPO uses the Cross-Entropy Method (CEM) to find effective programs, augmenting the fitness function with two critical multipliers:
  3. Diversity Multiplier: Ensures the retrieved programs represent distinct skills. It penalizes new programs that are too close in the latent space to previously discovered ones.
  4. Compatibility Multiplier: Evaluates how well a program functions when executed in sequence with others. A skill is only valuable if it leaves the environment in a state where another skill can successfully take over.
  5. Learning a High-Level Policy: Once a library of programmatic options (typically 3–5) is established, a high-level neural network (trained via PPO) learns to observe the environment and select which program to execute next.

To maximize interpretability, the authors further extract a Finite State Machine (FSM) from the high-level neural policy, rendering the entire decision-making hierarchy human-understandable.

Datasets and Evaluation

The researchers evaluated HIPO in the Karel domain, a classic educational programming environment where an agent navigates a grid, manipulates markers, and avoids obstacles.

  • KAREL & KAREL-HARD: Standard benchmarks consisting of short-horizon tasks (e.g., climbing stairs, finding a maze exit).
  • KAREL-LONG: A newly introduced benchmark designed to test endurance. These tasks (such as INF-HARVESTER or SEESAW) require the agent to perform repetitive subtasks over thousands of steps, far exceeding the 200–500 step limits of previous benchmarks.

Key Insights

  • Hierarchy Tames Complexity: By treating programs as modular "options," HIPO sidesteps the "curse of dimensionality" inherent in program synthesis. Finding several short, focused programs is vastly more efficient than synthesizing one monolithic script.
  • Inductive Generalization: Because the low-level options are actual programs containing control flow structures like loops (while) and conditionals (if), they are inherently scale-invariant. A program that learns to "clear a row" will succeed whether that row is 10 or 100 units long.
  • Compatibility is King: In hierarchical RL, sub-policies frequently fail because they do not "hand off" the state correctly to the next policy. HIPO’s compatibility search explicitly selects programs that sequence well together, leading to highly robust execution.

Key Results

  • Performance: On the demanding KAREL-LONG tasks, HIPO significantly outperformed both standard DRL (which struggled with sparse rewards over long horizons) and prior programmatic RL methods.
  • Zero-Shot Generalization: In the FARMER task, HIPO was trained on a specific environment size. When tested on environments 16 times longer, HIPO’s performance remained nearly perfect. In contrast, all baselines—including other programmatic methods—experienced severe performance drops of 40–80%.
  • Sample Efficiency: HIPO reached peak performance requiring significantly fewer environment interactions than "flat" programmatic search methods like LEAPS.

Limitations and Future Work

While HIPO represents a significant step forward, it has limitations:

  • DSL Dependency: The framework requires a predefined Domain Specific Language (DSL), which still relies on human expertise to design.
  • Search Bottleneck: The CEM search for latent programs remains computationally expensive, particularly as the complexity of the required skills scales up.
  • High-Level "Black Box": Although the low-level options are readable code, the high-level selector is initially a neural network. While FSM extraction helps, achieving a natively symbolic high-level policy remains an open challenge.

Future Direction: The authors propose integrating Large Language Models (LLMs) to assist in retrieving or explaining these programmatic options, which could eventually eliminate the need for strict, hand-coded DSLs and further accelerate the search process.

Summary updated

BibTeX
@inproceedings{lin2024hierarchical,
  author = {Yu-An Lin and Chen-Tao Lee and Chih-Han Yang and Guan-Ting Liu and Shao-Hua Sun},
  title = {{Hierarchical Programmatic Option Framework}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=FeCWZviCeP},
}
Figure