When to Memorize and When to Stop: Gated Recurrent Memory for Long-Context Reasoning

TL;DR

Introduces GRU-Mem for long-context reasoning, achieving up to 400% efficiency improvement by addressing memory explosion and lack of exit mechanisms.

cs.CL 🔴 Advanced 2026-02-11 31 views
Leheng Sheng Yongtao Zhang Wenchang Ma Yaorui Shi Ting Huang Xiang Wang An Zhang Ke Shen Tat-Seng Chua
long-context reasoning memory gating reinforcement learning efficiency optimization exit mechanism

Key Findings

Methodology

GRU-Mem incorporates two text-controlled gates (Update Gate and Exit Gate) to stabilize memory updates and enable early termination. Reinforcement learning rewards (rupdate and rexit) train the model to execute correct update and exit behaviors.

Key Results

  • Across tasks, GRU-Mem outperformed MemAgent with up to 400% faster inference, e.g., reducing time by 75% in MK-1.
  • Update Gate mitigated memory explosion, maintaining stable memory sizes during inference.
  • Exit Gate excelled in scenarios with uneven evidence distribution, enabling efficient early termination.

Significance

Addresses critical bottlenecks in long-context reasoning, providing a more efficient solution for processing extended texts in large language models.

Technical Contribution

Introduces a gating-based memory update framework optimized via reinforcement learning, significantly improving inference stability and efficiency compared to prior methods.

Novelty

First to apply text-controlled gating mechanisms to solve memory explosion and redundant computation in long-context reasoning, presenting a novel paradigm compared to MemAgent.

Limitations

  • Exit Gate may struggle in extremely sparse evidence scenarios.
  • Training requires substantial labeled data, limiting generalizability.

Future Work

Future research could explore dynamic gating thresholds and applications in multimodal reasoning.

AI Executive Summary

Reasoning over long contexts is essential for large language models but suffers from performance degradation as context length increases. Existing methods like MemAgent mitigate this by recurrent memory updates but face memory explosion and lack of exit mechanisms.

GRU-Mem introduces two text-controlled gates: Update Gate, which selectively updates memory only on evidence-rich chunks, and Exit Gate, which terminates reasoning once sufficient evidence is collected. Reinforcement learning rewards train the model to execute these behaviors effectively.

Experiments demonstrate GRU-Mem's superiority over MemAgent, achieving up to 400% faster inference while maintaining high accuracy. The gating mechanisms significantly reduce memory explosion risks and improve efficiency in uneven evidence scenarios. This study offers a stable and efficient solution for long-context reasoning tasks.

Deep Analysis

Background

Long-context reasoning enables large language models to process extended texts, such as books or large-scale memory systems. However, performance degrades as context length grows, and existing methods struggle to overcome context window limitations.

Core Problem

MemAgent employs recurrent memory updates but faces two major issues: memory explosion, where irrelevant information accumulates, and lack of exit mechanisms, leading to redundant computation.

Innovation

GRU-Mem addresses these issues with two gating mechanisms: Update Gate selectively updates memory only on critical chunks, avoiding memory explosion; Exit Gate terminates reasoning early once sufficient evidence is collected, reducing computation overhead.

Methodology

  • �� Update Gate: Determines whether to update memory based on chunk relevance.
  • �� Exit Gate: Identifies the last evidence chunk and terminates reasoning.
  • �� Reinforcement Learning: rupdate and rexit rewards train correct gating behaviors.
  • �� Training Optimization: Combines trajectory-level and turn-level advantages for stable training.

Experiments

Evaluated on tasks like HotpotQA, SQuAD, and various NIAH benchmarks, with context lengths ranging from 7K to 896K tokens. Compared against MemAgent as the baseline.

Results

GRU-Mem consistently outperformed MemAgent across tasks, achieving up to 400% faster inference. Update Gate reduced memory explosion risks, while Exit Gate improved efficiency in uneven evidence scenarios.

Applications

Applicable to tasks like legal document analysis and knowledge base QA, offering significant efficiency improvements.

Limitations & Outlook

Struggles in extremely sparse evidence scenarios and relies on extensive labeled data for training. Future work could explore multimodal applications and dynamic gating mechanisms.

Plain Language Accessible to non-experts

Imagine you're organizing a huge library to answer a question. Instead of copying every book, you only note down key facts. GRU-Mem acts like a smart librarian, updating notes only when necessary and stopping once enough information is gathered, saving time and avoiding clutter.

ELI14 Explained like you're 14

Think of playing a treasure hunt game with tons of clues, but only a few are useful. GRU-Mem is like a super-smart teammate who filters out the useless clues and remembers the important ones. When it's sure we've got all we need, it says, 'We're done!' Cool, right?

Glossary

GRU-Mem

A gated recurrent memory framework for long-context reasoning, optimizing updates and exits.

Used to address memory explosion and redundant computation.

Update Gate

A mechanism deciding whether to update memory based on chunk relevance.

Prevents memory overload by skipping irrelevant chunks.

Exit Gate

A mechanism allowing early termination once sufficient evidence is collected.

Reduces unnecessary computation.

Reinforcement Learning

A training method using rewards to optimize specific behaviors.

Trains correct gating actions in GRU-Mem.

Memory Explosion

A problem where irrelevant information accumulates, overloading memory.

Occurs in long-context reasoning tasks.

Open Questions Unanswered questions from this research

  • 1 How to optimize Exit Gate for extremely sparse evidence scenarios?
  • 2 Can gating mechanisms be extended to multimodal data?

Applications

Immediate Applications

Legal Document Analysis

Extracts key clauses efficiently, reducing manual review time.

Knowledge Base QA

Improves efficiency and accuracy in long-text question answering systems.

Long-term Vision

Multimodal Reasoning

Extends gating mechanisms to image and video data for cross-modal applications.

Abstract

While reasoning over long context is crucial for various real-world applications, it remains challenging for large language models (LLMs) as they suffer from performance degradation as the context length grows. Recent work MemAgent has tried to tackle this by processing context chunk-by-chunk in an RNN-like loop and updating a textual memory for final answering. However, this naive recurrent memory update faces two crucial drawbacks: (i) memory can quickly explode because it can update indiscriminately, even on evidence-free chunks; and (ii) the loop lacks an exit mechanism, leading to unnecessary computation after even sufficient evidence is collected. To address these issues, we propose GRU-Mem, which incorporates two text-controlled gates for more stable and efficient long-context reasoning. Specifically, in GRU-Mem, the memory only updates when the update gate is open and the recurrent loop will exit immediately once the exit gate is open. To endow the model with such capabilities, we introduce two reward signals $r^{\text{update}}$ and $r^{\text{exit}}$ within end-to-end RL, rewarding the correct updating and exiting behaviors respectively. Experiments on various long-context reasoning tasks demonstrate the effectiveness and efficiency of GRU-Mem, which generally outperforms the vanilla MemAgent with up to 400\% times inference speed acceleration.

cs.CL cs.AI