Brain-Like Replay Naturally Emerges in Reinforcement Learning Agents

Jiyi Wang, Likai Tang, Huimiao Chen, Marcelo G Mattar, Sen Song

TL;DR

Researchers have developed a modular reinforcement learning (RL) agent where brain-like "replay"—the reactivation of past experiences during rest—emerges naturally as a result of task optimization. By mimicking the communication between the brain's hippocampus and prefrontal cortex, this model demonstrates that replay is not just a biological quirk but a functional necessity for flexible navigation and rapid adaptation to new environments.

What Problem Does This Paper Address?

In artificial intelligence, "experience replay" is a standard trick used to improve sample efficiency by shuffling past data and feeding it back into a model. However, in AI, this is usually a hard-coded, brute-force mechanism. In contrast, biological brains perform replay during sleep or quiet rest, reactivating specific sequences of "place cells" that represent recently traveled paths.

The gap between these two fields is significant: Why does the brain do this? What are the minimal conditions required for replay to emerge? And most importantly, does it actually help an agent learn better in a dynamic world? This paper seeks to bridge this gap by creating an agent where replay isn't forced by a programmer but emerges because it helps the agent win.

Methods

The authors designed a modular Artificial Neural Network (ANN) inspired by two key brain regions:

  • Hippocampal Formation (HF): Modeled as a Gated Recurrent Unit (GRU), this acts as the "world model." It learns to predict the next location (path integration) and remembers reward history.
  • Prefrontal Cortex (PFC): Modeled as a recurrent network, this acts as the "policy maker." It estimates values and selects actions to maximize rewards.

The secret sauce is an information passage between the two. Crucially, this passage is closed while the agent is moving but opens when the agent stops to consume a reward. The system is trained using Proximal Policy Optimization (PPO). Replay emerges as the HF sends "virtual trajectories" to the PFC during these rest periods, allowing the PFC to update its internal "map" and plan future moves without physical movement.

Figure 1: A-C. Model structure. A The HF GRU module completes the task of path integration and episodic memory. The PFC RNN module is responsible for decision-making. The information passage between the PFC and HF only opens at rest. B. During mobility, the information passage remains closed, and the HF and PFC modules operate independently. The place cell activation reflects the real present locations. C. During immobility, the information passage opens. The HF and PFC modules start to communicate with each other. The activated place cell output constituted a replay sequence. D-F. Task setting. D. The agent should start from S, first get to checkpoint C, consume a small amount of reward (0.5), and then arrive at goal G to get a large reward (1.0). Directly moving to G will cause no rewards. E. A representative trajectory generated by the trained RL agent. First, it reaches C and gets the small reward. The replay happens at this time. F. The replay event in E.

Datasets

The model was tested in a simulated $5 \times 5$ open arena grid world. The task was a "flexible navigation" challenge inspired by real-world rodent experiments:

  1. The agent starts at point S.
  2. It must first reach a checkpoint C1 for a small reward.
  3. Then it must reach goal G for a large reward.
  4. Mid-way through the experiment, the checkpoint is moved from C1 to C2, forcing the agent to find a new optimal path (S-C2-G).

Key Insights and Ideas

  • Natural Emergence: Replay wasn't programmed in; it emerged because the agent was optimized to maximize rewards. The communication between the "world model" (HF) and "policy" (PFC) naturally favored the exchange of spatial sequences.
  • Biological Fidelity: The model's behavior closely mirrored rodents. As the agent learned the new shortcut (S-C2), the replay of the old path (S-C1) decayed, while replay of the new path increased—even before the agent fully adopted the new route.
  • Bridging Contexts: Using Principal Component Analysis (PCA), the authors visualized the PFC's hidden states. They found that replay acts as a "bridge" in high-dimensional space, helping the agent's internal state jump from the "old reward location" orbit to the "new reward location" orbit.
Manifold analysis shows how PFC hidden states form "orbits" for different reward contexts, with replay serving as the bridge between them.

Key Results

  • Functional Importance: Through ablation studies, the researchers found that replacing the HF-to-PFC signal with random noise significantly impaired the agent's ability to find the new reward location.
  • Exploration Efficiency: Agents with replay were significantly faster at adapting to the relocated checkpoint compared to agents without it.
  • Sequence vs. Packages: Interestingly, shuffling the order of messages during a replay event only slightly hurt performance. This suggests that the brain might send information in "independent packages" of data rather than requiring a perfectly ordered movie-like sequence.

Limitations and Future Work

The authors acknowledge a few biological simplifications:

  • Strict Segregation: In the model, HF and PFC are entirely segregated during movement. In real brains, they communicate via "theta waves" even during activity.
  • PFC Replay: The study focused on HF-generated replay being sent to the PFC, but the PFC is also known to generate its own replay, which wasn't explicitly modeled here.

Future work could involve adding these biological layers to see if they further enhance learning efficiency or explain more complex cognitive behaviors like "pre-play" (planning paths to never-before-visited goals).

Summary updated

BibTeX
@misc{wang2024brain,
  author = {Jiyi Wang and Likai Tang and Huimiao Chen and Marcelo G Mattar and Sen Song},
  title = {{Brain-Like Replay Naturally Emerges in Reinforcement Learning Agents}},
  year = {2024},
  eprint = {2402.01467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.01467},
}
Figure