Reinforcement Learning with Structured Hierarchical Grammar Representations of Actions

Petros Christodoulou, Robert Tjarko Lange, Ali Shafti, A. Aldo FaisalarXiv 2019

Introduction

Deep Reinforcement Learning (RL) has achieved significant milestones in complex environments but remains notoriously data-hungry. This limitation often prevents its application in real-world domains like robotics, where data collection is expensive and time-consuming. Hierarchical Reinforcement Learning (HRL) attempts to mitigate this by organizing primitive actions into higher-level "macro-actions." However, automatically discovering the most effective hierarchical structures remains a significant challenge.

This paper introduces Action Grammar Reinforcement Learning (AG-RL), a framework inspired by computational linguistics. Just as humans use grammatical rules to combine words into complex sentences, AG-RL uses grammar inference algorithms to automatically extract "action grammars" from an agent's successful trajectories. These grammars create temporal abstractions that significantly accelerate training and improve sample efficiency.

The AG-RL Framework

The AG-RL framework alternates between gathering experience and identifying action grammars. It is designed to be algorithm-agnostic and can be wrapped around standard off-policy RL algorithms such as DDQN or Soft Actor-Critic (SAC).

The AG-RL framework overview, illustrating the iterative process of gathering experience, grammar induction, and action space expansion.

The process follows three main stages:

  1. Gather Experience: The base RL agent interacts with the environment. Periodically, exploration is disabled to collect high-quality "clean" trajectories from successful episodes.
  2. Identify Action Grammar: These trajectories are processed by a grammar calculator using a regularized version of the Sequitur algorithm. Sequitur identifies frequently repeating sub-sequences and replaces them with new macro-action symbols.
  3. Update Action Space: These new macro-actions are appended to the agent's action space. Transfer learning is employed by adding new nodes to the network's final layer, initialized with the weights of their constituent primitive actions.

Key Innovations: HAR and Abandon Ship

To ensure stability and efficiency when training with an expanding action space, the authors introduce two critical mechanisms:

  • Hindsight Action Replay (HAR): A novel adaptation of Hindsight Experience Replay. HAR ensures the replay buffer contains experiences for both macro-actions and their underlying primitive sequences. If an agent executes a macro-action, it is stored as both the macro and the primitives. Conversely, if a sequence of primitives matches a known macro-action, it is also recorded as a macro-action experience. Ablation studies show HAR is essential for performance.
  • Abandon Ship: To prevent agents from being "locked" into long, suboptimal macro-actions, this mechanism allows the agent to evaluate the expected value of continuing a sequence versus aborting it at every timestep. If a primitive action offers significantly higher value, the agent breaks the sequence to maintain flexibility.

Evaluation and Results

The framework was evaluated on the Atari 2600 benchmark and a toy Towers of Hanoi environment to illustrate grammar extraction in sparse-reward settings.

A sequence of states in the Towers of Hanoi environment, used as a toy example to demonstrate grammar extraction in sparse-reward settings.

In Atari experiments, AG-RL demonstrated massive improvements in sample efficiency over standard baselines:

  • AG-DDQN: Improved performance in all 8 tested games, with a median improvement of +31%.
  • AG-SAC: Outperformed standard SAC in 19 out of 20 games, with a median improvement of +96% and a peak of +3,756%.
  • Comparison to State-of-the-Art: AG-SAC outperformed the Rainbow baseline—the previous state-of-the-art for Atari sample efficiency—in 17 out of 20 games. It achieved a median improvement of +62% without the extensive hyperparameter tuning required by Rainbow.

Conclusion

AG-RL demonstrates that treating action sequences as linguistic strings allows RL agents to leverage unsupervised grammar induction for building effective temporal abstractions. The results suggest that action grammars are a powerful tool for improving the sample efficiency and interpretability of deep RL agents. Future work will explore more diverse grammar induction methods and applications in physical robotics, where data efficiency is paramount.

Summary updated

BibTeX
@misc{christodoulou2019reinforcement,
  author = {Petros Christodoulou and Robert Tjarko Lange and Ali Shafti and A. Aldo Faisal},
  title = {{Reinforcement Learning with Structured Hierarchical Grammar Representations of Actions}},
  year = {2019},
  eprint = {1910.02876},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.02876},
}
Figure