Semantic HELM: An Interpretable Memory for Reinforcement Learning

Fabian Paischer, Thomas Adler, Markus Hofmarcher, Sepp Hochreiter

Abstract Reinforcement learning agents deployed in the real world often have to cope with partially observable environments. Therefore, most agents employ memory mechanisms to approximate the state of the environment. Recently, there have been impressive success stories in mastering partially observable environments, mostly in the realm of computer games like Dota 2, StarCraft II, or MineCraft. However, existing methods lack interpretability in the sense that it is not comprehensible for humans what the agent stores in its memory. In this regard, we propose a novel memory mechanism that represents past events in human language. Our method uses CLIP to associate visual inputs with language tokens. Then we feed these tokens to a pretrained language model that serves the agent as memory and provides it with a coherent and human-readable representation of the past. We train our memory mechanism on a set of partially observable environments and find that it excels on tasks that require a memory component, while mostly attaining performance on-par with strong baselines on tasks that do not. On a challenging continuous recognition task, where memorizing the past is crucial, our memory mechanism converges two orders of magnitude faster than prior methods. Since our memory mechanism is human-readable, we can peek at an agent's memory and check whether crucial pieces of information have been stored. This significantly enhances troubleshooting and paves the way toward more interpretable agents.

Introduction

In many complex real-world and virtual scenarios, reinforcement learning (RL) agents face the challenge of partial observability, where they can only perceive a fraction of the environment at any given time. To navigate these settings, agents must maintain a memory of past events. While standard memory architectures like LSTMs or Transformers are effective, they function as "black boxes," storing information in high-dimensional vectors that are unintelligible to humans.

This lack of interpretability makes it difficult to diagnose agent failures: did the agent forget a key item, or did it fail to perceive it correctly? We introduce Semantic HELM (SHELM), which addresses this by using natural language as a common interface between vision, memory, and human understanding.

Overview of the SHELM agent-environment interaction loop. Visual observations are mapped to semantic tokens in memory, which then inform the agent's actions.

The SHELM Architecture

SHELM builds upon the History-Enhanced Language Memory (HELM) framework by adding a critical semantic layer. The architecture consists of three primary components:

  1. Semantic Mapping: The system uses CLIP to bridge the gap between pixels and words. A semantic database $\mathcal{S}$ is created from the intersection of CLIP and Language Model (LM) vocabularies. For every visual observation $o_t$, the system retrieves the $k$ most similar text tokens (e.g., "door," "key," "crab").
  2. Language Model Memory: These retrieved tokens are fed into a pretrained, frozen Language Model (Transformer-XL). Leveraging its pretraining on vast corpora, the LM compresses the sequence of tokens into a coherent history vector $h_t$.
  3. Policy Learning: A standard RL policy (PPO) utilizes both current visual features from a CNN and the compressed history $h_t$ to decide on the next action $a_t$.
Detailed architecture of SHELM: (a) vocabulary intersection, (b) semantic token retrieval via CLIP similarity, and (c) the integration of LM-based memory with a CNN-based policy.

Experimental Evaluation

We evaluated SHELM across a diverse range of environments, including MiniGrid (2D grid worlds), MiniWorld (3D navigation), Avalon (complex 3D survival), and Psychlab (cognitive psychology tasks).

Key Results

  • Psychlab Performance: On the memory-intensive Continuous Recognition (CR) task, SHELM converged two orders of magnitude (100x) faster than prior methods. While baseline agents struggled to exceed random performance within 10 million steps, SHELM mastered the task rapidly.
  • Competitive Benchmarking: In MiniGrid and Avalon, SHELM performed on par with or better than state-of-the-art baselines like Dreamerv3 and HELMv2.
  • The Importance of Semantics: Ablation studies demonstrated that the semantic meaning of the tokens is crucial. Replacing CLIP-mapped tokens with random word assignments led to a significant drop in performance, proving that the agent leverages the inherent meaning of words to organize its memory.

Discussion and Conclusion

SHELM demonstrates that language is a powerful abstraction for memory in RL. By compressing high-dimensional visual data into manageable semantic concepts, agents gain a sophisticated understanding of the world without requiring extensive environment-specific training for basic object recognition.

Crucially, the human-readable nature of the memory serves as a "debugging superpower." Researchers can inspect the memory logs to determine if a failure was due to perception (e.g., mapping a "key" to the wrong token) or logic. While current limitations include the computational cost of running large LMs and the occasional "modality gap" in CLIP's perception of synthetic graphics, SHELM paves the way for more transparent and interpretable AI systems.

Summary updated

BibTeX
@inproceedings{paischer2023semantic,
  author = {Fabian Paischer and Thomas Adler and Markus Hofmarcher and Sepp Hochreiter},
  title = {{Semantic HELM: An Interpretable Memory for Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=ebMPmx5mr7},
}
Figure