Learning of Generalizable and Interpretable Knowledge in Grid-Based Reinforcement Learning Environments

Manuel Eberhardinger, Johannes Maucher, Setareh Maghsudi

Introduction

Deep Reinforcement Learning (RL) has demonstrated exceptional performance across diverse domains, from complex strategy games to autonomous systems. However, these models typically operate as "black boxes," where decision-making logic is buried within millions of neural network weights. This lack of transparency poses significant risks in safety-critical applications and hinders our ability to verify or debug agent behavior.

This research addresses the challenge of Explainable Reinforcement Learning (XRL) by proposing a framework that distills opaque neural policies into human-readable symbolic programs. By converting neural trajectories into a Domain-Specific Language (DSL), the framework aims to bridge the gap between high-performance neural agents and the need for interpretable, verifiable logic.

Methodology: Program Synthesis and Library Learning

The core of the proposed approach is a program synthesis framework designed to imitate a pre-trained RL "oracle." Rather than learning directly from environmental rewards, the system observes state-action pairs (trajectories) and searches for a symbolic program that replicates the oracle's behavior.

Key Components

  • DreamCoder Integration: The framework adapts the DreamCoder system, which employs an iterative process of searching for programs and refactoring common code patterns into a "library" of reusable, higher-level functions. This allows the system to build increasingly complex concepts from basic primitives.
  • LibT5 (Neural-Guided Synthesis): A significant contribution of this work is the introduction of LibT5. This component replaces traditional enumerative search with CodeT5—a large language model fine-tuned on code—to guide the synthesis process, potentially allowing the system to navigate larger search spaces more efficiently.
  • Domain-Agnostic Curriculum: To manage the complexity of long-horizon tasks, the researchers implemented a curriculum that begins by imitating short sub-trajectories (e.g., 3 steps) and incrementally increases the sequence length as the synthesizer achieves success.
  • Symbolic Verification: A dedicated symbolic component filters synthesized programs, checking them for functional correctness against the original RL agent's data to ensure high-fidelity imitation.

Experimental Setup

The framework was evaluated on two distinct grid-based environments designed to test navigation and reactive logic:

  1. Gridworld Maze: A 5x5 navigation task with partial observability, requiring the agent to find a path through a maze.
  2. MinAtar: Simplified 10x10 versions of classic Atari games, specifically Asterix (a resource collection and obstacle avoidance task) and Space Invaders (a combat and movement task).

Training data consisted of trajectories generated by high-performing neural agents trained via standard deep RL algorithms.

Key Insights and Results

Programs as Visual Explanations

Unlike neural weights, symbolic programs provide a clear reasoning process. The researchers developed a method to visualize which specific grid cells a program queries to make a decision. This provides a direct spatial explanation of the agent's focus, such as identifying a wall to the left or an enemy in a specific column.

Concept Discovery through Library Learning

As the system solves more tasks, it builds a hierarchical library of functions. In the Maze environment, for instance, the system discovered complex functions built upon multiple simpler primitives. These discovered functions often map directly to environmental concepts, effectively performing automated feature engineering that is human-interpretable.

The Complexity Paradox

While LibT5 was able to extract a higher volume of functions (27 for Maze and 23 for Space Invaders) compared to the base DreamCoder, more was not always better. The researchers observed a "complexity paradox" where an overly large library led to "catastrophic forgetting." In these instances, the model struggled to solve simple tasks it had previously mastered because the search space became cluttered with overly specific or complex functions.

Performance Trade-offs

Quantitative results showed that for smaller observation spaces like the Maze, traditional search-based methods outperformed neural-guided ones, solving sub-trajectories nearly twice as long. However, neural synthesizers like CodeT5 showed greater potential for scaling as the complexity of the observation space increased.

Limitations and Future Work

While this work marks a significant step toward interpretable RL, several challenges remain:

  • Scaling to Full Policies: Currently, the system imitates sub-trajectories of approximately 50 steps. Future work aims to synthesize a single, unified program capable of managing an entire episode (1,000+ steps).
  • Direct Learning: The current reliance on a pre-trained neural oracle is a limitation. Future iterations may attempt to synthesize programs directly from environmental rewards, bypassing the neural agent entirely.
  • Continuous Environments: Transitioning from discrete grid worlds to continuous spaces (like robotics) will require an intermediate perception layer to translate raw pixels or sensor data into symbolic inputs.

Conclusion

By combining program synthesis with library learning, this research demonstrates a viable path toward turning "black-box" RL into transparent, symbolic code. While managing library complexity remains a hurdle, the ability to extract reusable, human-readable concepts from agent behavior is a crucial advancement for the development of verifiable and trustworthy AI systems.

Summary updated

BibTeX
@inproceedings{eberhardinger2023learning,
  author = {Manuel Eberhardinger and Johannes Maucher and Setareh Maghsudi},
  title = {{Learning of Generalizable and Interpretable Knowledge in Grid-Based Reinforcement Learning Environments}},
  booktitle = {AIIDE},
  year = {2023},
  doi = {10.1609/aiide.v19i1.27516},
}
Figure