TL;DR
MemDuet is a dual-process memory framework for long-context reasoning that mimics human "fast and slow" thinking. By coordinating a small, fast model for parallel evidence selection (System 1) with a large, deliberate model for memory consolidation (System 2), it achieves a 9.74× inference speedup and a 73.91% reduction in output tokens compared to previous state-of-the-art memory agents, all while maintaining or improving accuracy on contexts up to 3.5 million tokens.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly expected to reason over "infinite" contexts—think entire code repositories or massive legal documents. However, we face a brutal trade-off:
- Standard Attention: Becomes prohibitively expensive as context grows.
- Recurrent Memory Agents: Process documents chunk-by-chunk to maintain a fixed memory, but sequential processing is slow, and updating memory for every chunk is computationally wasteful.
The authors identify a bottleneck in existing memory agents: control decisions (like whether to update memory) either happen inside a slow sequential loop or operate on already-compressed data. MemDuet aims to break this coupling between context length and inference cost by introducing a cognitively inspired "dual-process" architecture.
Methods
Inspired by Daniel Kahneman’s account of cognition, MemDuet splits the reasoning task into two systems:
- System 1 (Fast/Parallel): A Small Language Model (SLM) scans raw context chunks in parallel. Its job is "selective attention"—rapidly identifying which chunks are likely to contain goal-relevant information.
- System 2 (Slow/Deliberate): A Large Language Model (LLM) verifies the candidates flagged by System 1. If a chunk is truly useful, System 2 rewrites the textual memory in document order.
The training process is a sophisticated three-stage pipeline:
- Supervised Warm-up: System 1 is trained via supervised fine-tuning (SFT) to align its selections with gold-standard supporting facts.
- System 2 RL: System 1 is frozen, and System 2 is optimized using Group Relative Policy Optimization (GRPO). This teaches the LLM how to verify candidates and rewrite memory to maximize downstream reasoning rewards.
- Joint Optimization: Both systems are fine-tuned together using task-level rewards, allowing the "selector" and the "consolidator" to co-adapt.
Datasets
The authors evaluated MemDuet on three diverse long-context benchmarks:
- RULER-HQA: A benchmark testing multi-hop reasoning across contexts ranging from 7K to 3.5M tokens.
- LongBench v2: A collection of realistic long-context tasks categorized by length (Short to Ultra).
- 2WikiMultiHopQA: A length-controlled dataset requiring complex evidence synthesis.
- HotpotQA: Used primarily for the initial supervised training stage.
Key Insights and Ideas
- Speculative Verification: MemDuet borrows the logic of speculative decoding. System 1 "speculates" which chunks are important, and System 2 "verifies" them. This allows the system to skip the expensive memory-rewriting step for the vast majority of irrelevant "distractor" text.
- Parallel Scanning, Sequential Updating: While System 1 can look at many chunks at once, memory must be updated in document order to maintain a coherent narrative. MemDuet manages this by processing windows of chunks and only committing the earliest accepted update before re-evaluating the rest.
- Efficiency through Sparsity: Most long documents are mostly noise. By using a cheap SLM as a gatekeeper, MemDuet ensures the expensive LLM only "thinks" when it sees something potentially useful.
- Joint RL is Crucial: The authors found that joint optimization (Stage 3) significantly recovers accuracy lost during the initial stages, as System 1 learns exactly what kind of evidence System 2 finds most useful for the final answer.
Key Results
MemDuet demonstrates a superior accuracy-efficiency trade-off compared to baselines like MemAgent, InfMem, and long-context models like Qwen2.5-1M.
- Massive Speedups: On RULER-HQA at 3.5M tokens, MemDuet achieved a 49.61× speedup over the standard RL-MemAgent.
- Token Savings: It generated 99.14% fewer output tokens at the 3.5M token mark, drastically reducing the cost of inference.
- Scaling Gracefully: As shown in the figure below, while other models' latency and token counts explode with context length, MemDuet’s growth is much flatter.
- Proprietary Transfer: The framework is "plug-and-play." Using it with proprietary APIs (like GPT-4 or DeepSeek) reduced latency by over 70% and costs by nearly 60% without needing additional training.
Limitations and Future Work
- System 1 Recall: The biggest risk is a "false negative." If System 1 skips a crucial piece of evidence, System 2 never sees it, and the information is lost forever.
- Short Context Overhead: On shorter documents (e.g., 7K tokens), the overhead of coordinating two models can actually make MemDuet slightly slower than a single-model approach.
- Sequential Bottleneck: Even with parallel scanning, the requirement to update memory in document order limits the theoretical maximum speedup. Future work might explore non-linear memory structures.
- Domain Generalization: The study primarily used Qwen-family backbones; testing on a wider variety of model architectures remains for future research.
Summary updated