Large Language Models Are Semi-Parametric Reinforcement Learning Agents

Danyang Zhang, Lu Chen, Situo Zhang, Hongshen Xu, Zihan Zhao, Kai Yu

TL;DR

REMEMBERER is a novel framework that transforms Large Language Models (LLMs) into "semi-parametric" reinforcement learning agents by equipping them with a persistent, long-term experience memory. Instead of relying on expensive model fine-tuning, it uses a technique called Reinforcement Learning with Experience Memory (RLEM) to update this external memory with both successes and failures. This allows the agent to evolve and improve across different tasks without altering its underlying weights.

The Challenge of LLM Memory

While LLMs are impressive reasoners, they inherently struggle to "learn" from their own interaction history during sequential decision-making tasks. Currently, researchers use two main approaches to address this:

  1. Fine-tuning: Updating the model's internal weights via Reinforcement Learning (RL). This is computationally expensive, difficult to deploy, and often leads to catastrophic forgetting of general capabilities.
  2. Working Memory: Providing the agent with a short-term history of the current episode within its prompt. This memory is transient; once the task concludes, the history is wiped, preventing the agent from applying those lessons to different but related future goals.
Comparison of LLM agents with short-term working memory versus long-term cross-goal experience memory.

The authors address this gap by asking: How can we give an LLM a permanent "episodic memory" that allows it to learn from past experiences—both good and bad—without changing the model's underlying parameters?

The REMEMBERER Framework

To solve this, the authors introduce REMEMBERER, a semi-parametric approach consisting of a fixed LLM and an external, evolvable memory module.

The REMEMBERER framework illustrating the interaction between the environment, the LLM, and the Experience Memory.
  • Experience Memory: A structured database that stores past interactions as tuples of (Task, Observation, Action, Q-value). The Q-value represents the expected future reward for taking a specific action in a specific state.
  • Reinforcement Learning with Experience Memory (RLEM): This is the core update mechanism. Instead of updating neural network weights, RLEM updates the Q-values in the memory table using the Bellman equation and n-step bootstrapping. When the agent interacts with an environment, it records the outcome and updates the "value" of that experience.
  • Retrieval & Action Advice: When faced with a new situation, the agent uses a similarity function to pull the most relevant past experiences from its memory. These are injected into the LLM's prompt as "Action Advice," categorized into Encouraged actions (high Q-values) and Discouraged actions (low Q-values).

Key Insights and Performance

Drawing from cognitive science, the authors argue that human decision-making relies heavily on recollecting past episodes. By treating memory as a retrievable database, LLMs can "learn" instantly.

One of the most effective parts of the framework is the use of Discouraged actions. Most LLM agents only look at successful examples. REMEMBERER explicitly tells the LLM what not to do based on past failures, significantly preventing the agent from repeating mistakes.

The framework was evaluated on two challenging RL benchmarks:

  • WebShop: A simulated e-commerce website with over 1 million products. REMEMBERER achieved a success rate of 39% (a 3% absolute improvement over the SOTA ReAct method) and a higher average score (0.68 vs 0.66).
  • WikiHow (Mobile-Env): A multi-step mobile app navigation task where REMEMBERER achieved a success rate of 93%, surpassing the previous SOTA of 89%.

Furthermore, REMEMBERER is remarkably sample-efficient. While traditional RL might require hundreds of thousands of steps to reach a certain performance level, REMEMBERER achieved superior results with just 74 steps of training on 10 tasks. Because the memory is persistent and retrieved based on state similarity, the agent successfully demonstrates cross-goal transfer, using an experience gained while chasing one goal to help it solve another.

Limitations and Future Work

The authors note that performance might eventually saturate because there is a limit to how many past experiences can fit into an LLM's prompt window. Additionally, while this work used relatively simple RL techniques (Q-learning), integrating more sophisticated RL algorithms into the memory update process is a promising next step. Finally, scaling this memory-based approach to environments with very long-term dependencies or highly visual observations remains an open challenge.

Summary updated

BibTeX
@inproceedings{zhang2023large,
  author = {Danyang Zhang and Lu Chen and Situo Zhang and Hongshen Xu and Zihan Zhao and Kai Yu},
  title = {{Large Language Models Are Semi-Parametric Reinforcement Learning Agents}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=ZcJa1R6j3v},
}
Figure