Working Memory Graphs

Ricky Loynd, Roland Fernandez, Asli Celikyilmaz, Adith Swaminathan, Matthew J. Hausknecht

TL;DR

Working Memory Graphs (WMG) replace the linear, bottlenecked memory of traditional Recurrent Neural Networks (RNNs) with a Transformer-based architecture that reasons over a dynamic set of "Memos." By combining this "shortcut recurrence" with factored observations, WMG achieves massive gains in sample efficiency and reasoning capability across complex reinforcement learning tasks.

The Problem: The "Telephone" Effect in RL

In Reinforcement Learning (RL), agents often operate in Partially Observable Markov Decision Processes (POMDPs). Because the agent cannot see the entire environment at once, it must remember past observations to make sense of the present.

Traditionally, Gated RNNs (like LSTMs or GRUs) handle this memory. However, RNNs have a fundamental flaw: information must flow through a "linear chain" of hidden states. Imagine a game of "telephone" played across hundreds of timesteps; by the time information reaches the current action, it is often diluted or lost. This sequential compression makes it incredibly difficult for agents to learn long-term dependencies or perform complex reasoning over their own history.

Methods: Introducing Working Memory Graphs

To solve this, the authors introduce the Working Memory Graph (WMG), leveraging the multi-head self-attention of Transformers to break the RNN bottleneck.

Comparison of Gated RNN and WMG architectures alongside a factored gridworld observation.

WMG fundamentally changes how an agent processes its environment and history through several key components:

  • Factored Observations: WMG doesn't just look at raw pixels. It breaks the environment down into "Factors"—vectors representing individual objects (e.g., a green key at specific coordinates).
  • The Transformer Core: All Factors, Memos, and a "Core" vector (containing non-factored info like text instructions) are fed into a standard Transformer. This allows the agent to reason over the relationships between objects and its own memory simultaneously.
  • Memos: Instead of a single hidden state vector, WMG maintains a "rolling buffer" of vectors called Memos. On each timestep, the agent generates one new Memo and overwrites the oldest one.
Temporal unrolling showing the RNN's linear chain versus WMG's persistent Memos.
  • Shortcut Recurrence: Because WMG uses self-attention over these Memos, the agent can create direct "shortcuts" from any past Memo to the current action. It completely bypasses the need to pass information sequentially through every intervening step.

Datasets and Evaluation

The authors evaluated WMG on three distinct environments requiring complex memory and planning:

  1. Pathfinding (New Benchmark): A task designed to test multi-step reasoning. The agent observes pieces of a directed graph over time and must answer questions about whether a path exists between two nodes.
  2. BabyAI: A gridworld where agents must follow natural language instructions (e.g., "put the red ball next to the green box") in partially observable rooms.
  3. Sokoban: A classic puzzle game requiring intense forward planning to push boxes onto targets without getting them stuck.

Key Insights and Results

  • The Transformer-Factoring Synergy: Transformers are inherently designed to process sets of data. By "factoring" the world into objects rather than a flat grid of pixels, the authors found a perfect match for the Transformer's architecture.
  • Bypassing the "Telephone" Effect: In the Pathfinding task, WMG could perform "Depth-3" reasoning (connecting three different past observations) where GRUs struggled to handle Depth-2. This proves direct attention to the past is superior to sequential compression.
  • 10x Sample Efficiency: In BabyAI (Level 3), WMG reached a 99% success rate using 10 times fewer environment interactions than a standard CNN+GRU baseline. Furthermore, WMG was the only agent capable of solving BabyAI Level 5 (PickupLoc) within the 6-million-step training limit.
  • Sokoban Superiority: WMG outperformed DRC (Deep Repeated ConvLSTM), a state-of-the-art architecture specifically designed for planning, showing that general-purpose self-attention can beat specialized spatial recurrence.
  • Zero-Shot Generalization: When trained on 12-step Pathfinding and tested on 24-step versions, WMG maintained high accuracy (93.9%), while GRUs plummeted (84.4%).

Limitations and Future Work

While powerful, WMG has room for improvement:

  • Flexible Memo Lifetimes: Currently, WMG simply deletes the oldest Memo. A more intelligent system might use attention scores to decide which memories are worth keeping.
  • Graph Edges: WMG treats observations as nodes in a graph but doesn't explicitly model the edges (relationships) between them. Incorporating edge-specific data could lead to richer representations.
  • Scaling Memory: The computational cost of Transformers grows quadratically with the number of inputs. Scaling to thousands of Memos remains a challenge for the broader field.

Summary updated

BibTeX
@inproceedings{loynd2020working,
  author = {Ricky Loynd and Roland Fernandez and Asli Celikyilmaz and Adith Swaminathan and Matthew J. Hausknecht},
  title = {{Working Memory Graphs}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
}
Figure