Table of Contents
Fetching ...

MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning

Qianhao Yuan, Jie Lou, Zichao Li, Jiawei Chen, Yaojie Lu, Hongyu Lin, Le Sun, Debing Zhang, Xianpei Han

TL;DR

MemSearcher tackles the inefficiency of history-heavy context in conversational search agents by maintaining a compact, iteratively updated memory and pairing it with the current query. It replaces full-history concatenation with a memory-management step, and trains end-to-end using an extended RL algorithm, multi-context GRPO, that optimizes reasoning, search actions, and memory updates across multiple conversations. Empirical results on seven public benchmarks show MemSearcher achieving substantial gains over strong baselines, with a smaller 3B model sometimes outperforming larger baselines and maintaining far more stable token usage than ReAct-based approaches. The work advances practical, scalable knowledge acquisition by LLMs, enabling efficient multi-turn reasoning with external retrieval while preserving essential information.

Abstract

Typical search agents concatenate the entire interaction history into the LLM context, preserving information integrity but producing long, noisy contexts, resulting in high computation and memory costs. In contrast, using only the current turn avoids this overhead but discards essential information. This trade-off limits the scalability of search agents. To address this challenge, we propose MemSearcher, an agent workflow that iteratively maintains a compact memory and combines the current turn with it. At each turn, MemSearcher fuses the user's question with the memory to generate reasoning traces, perform search actions, and update memory to retain only information essential for solving the task. This design stabilizes context length across multi-turn interactions, improving efficiency without sacrificing accuracy. To optimize this workflow, we introduce multi-context GRPO, an end-to-end RL framework that jointly optimize reasoning, search strategies, and memory management of MemSearcher Agents. Specifically, multi-context GRPO samples groups of trajectories under different contexts and propagates trajectory-level advantages across all conversations within them. Trained on the same dataset as Search-R1, MemSearcher achieves significant improvements over strong baselines on seven public benchmarks: +11% on Qwen2.5-3B-Instruct and +12% on Qwen2.5-7B-Instruct relative average gains. Notably, the 3B-based MemSearcher even outperforms 7B-based baselines, demonstrating that striking a balance between information integrity and efficiency yields both higher accuracy and lower computational overhead. The code and models will be publicly available at https://github.com/icip-cas/MemSearcher

MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning

TL;DR

MemSearcher tackles the inefficiency of history-heavy context in conversational search agents by maintaining a compact, iteratively updated memory and pairing it with the current query. It replaces full-history concatenation with a memory-management step, and trains end-to-end using an extended RL algorithm, multi-context GRPO, that optimizes reasoning, search actions, and memory updates across multiple conversations. Empirical results on seven public benchmarks show MemSearcher achieving substantial gains over strong baselines, with a smaller 3B model sometimes outperforming larger baselines and maintaining far more stable token usage than ReAct-based approaches. The work advances practical, scalable knowledge acquisition by LLMs, enabling efficient multi-turn reasoning with external retrieval while preserving essential information.

Abstract

Typical search agents concatenate the entire interaction history into the LLM context, preserving information integrity but producing long, noisy contexts, resulting in high computation and memory costs. In contrast, using only the current turn avoids this overhead but discards essential information. This trade-off limits the scalability of search agents. To address this challenge, we propose MemSearcher, an agent workflow that iteratively maintains a compact memory and combines the current turn with it. At each turn, MemSearcher fuses the user's question with the memory to generate reasoning traces, perform search actions, and update memory to retain only information essential for solving the task. This design stabilizes context length across multi-turn interactions, improving efficiency without sacrificing accuracy. To optimize this workflow, we introduce multi-context GRPO, an end-to-end RL framework that jointly optimize reasoning, search strategies, and memory management of MemSearcher Agents. Specifically, multi-context GRPO samples groups of trajectories under different contexts and propagates trajectory-level advantages across all conversations within them. Trained on the same dataset as Search-R1, MemSearcher achieves significant improvements over strong baselines on seven public benchmarks: +11% on Qwen2.5-3B-Instruct and +12% on Qwen2.5-7B-Instruct relative average gains. Notably, the 3B-based MemSearcher even outperforms 7B-based baselines, demonstrating that striking a balance between information integrity and efficiency yields both higher accuracy and lower computational overhead. The code and models will be publicly available at https://github.com/icip-cas/MemSearcher

Paper Structure

This paper contains 25 sections, 9 equations, 5 figures, 4 tables.

Figures (5)

  • Figure 1: Comparison between ReAct (Top) and MemSearcher (Bottom). The dashed box illustrates the content in the LLM context. While ReAct continuously appends all interaction history into the context, MemSearcher iteratively updates a compact memory that retains only essential information.
  • Figure 2: Multi-context GRPO. In rollout, we sample a group of trajectories $\{T_i\}_{i=1}^G$ for question $q$. The $i$-th trajectory $T_i$ consists of multiple conversations $\{T_{i,j}\}_{j=1}^{n_i}$ under different contexts. Then, we compute rewards $\{R_i\}_{i=1}^G$, and derive the trajectory-level advantages $\{A_i\}_{i=1}^G$ from these rewards. We propagate trajectory-level advantages to each conversation within them, i.e.$A_{i,j}=A_i$, and treat each conversation as an independent optimization target to update the policy LLM.
  • Figure 3: Comparison of the average token number in the LLM context between MemSearcher and ReAct-based ReSearch.
  • Figure 4: Peak GPU memory usage (GB) comparison between MemSearcher and ReSearch.
  • Figure 5: Training and validation reward during training. The validation is conducted on a part of development set of HotpotQA with 100 randomly selected samples, and conducted every 20 steps during training. The curves are smoothed for clarity.