TL;DR
This paper introduces InfMem, a novel agent designed for question answering over extremely long documents. InfMem uses a "System-2" cognitive control approach, actively planning and retrieving evidence to overcome the limitations of passive memory updates in existing models, leading to significant accuracy gains and reduced inference time.
What Problem Does This Paper Address?
As documents grow longer (up to 1 million tokens), answering questions becomes challenging because crucial evidence is often sparse, scattered across distant segments, and low-salience. Existing streaming agents, while scalable, tend to passively update their memory, often losing these vital "bridging" pieces of information needed for multi-hop reasoning. This leads to a "fidelity dilemma": aggressive compression erases important links, while simply expanding context dilutes attention and buries key facts. InfMem aims to solve this by implementing a more deliberate, task-conditioned control mechanism for managing memory and evidence.
Methods
InfMem employs a PRETHINK-RETRIEVE-WRITE protocol, inspired by System-2 cognitive control.
- PRETHINK: This component acts as a cognitive controller. At each step, it monitors the current memory to assess if enough evidence exists to answer the question. If not, it plans a retrieval query and decides how many units to fetch.
- RETRIEVE: This module performs targeted, global in-document retrieval, fetching relevant segments that might have been missed by the sequential reading process.
- WRITE: This component integrates the newly retrieved evidence with the current document chunk and the existing memory, performing "joint compression" to update the bounded memory. It prioritizes evidence crucial for downstream composition.
- Early Stopping: InfMem can terminate the process early once sufficient evidence is gathered, significantly reducing redundant computation.
To train InfMem, the authors propose a practical SFT→RL (Supervised Fine-Tuning followed by Reinforcement Learning) pipeline. SFT first trains the agent to adhere to the protocol, and then RL aligns the agent's decisions (retrieval, writing, stopping) with end-task correctness and efficiency.
Datasets
The paper uses several datasets for training and evaluation:
- SQuAD, HotpotQA, 2WikiMultihopQA, MuSiQue: These are used to construct synthetic long-context QA instances by mixing gold evidence with distractor documents to create documents up to 1M tokens.
- LongBench: Used for evaluating performance on natural distributions of long-context QA tasks.
- RULER-QA: Another benchmark used for evaluation.
Key Insights and Ideas
- System-2 Cognitive Control for Agents: The core idea is that for complex, long-horizon tasks, agents need a more deliberate, "thinking" process (System-2) rather than just reactive heuristics (System-1). InfMem's PRETHINK module embodies this.
- Decoupling Planning from Writing: By separating the decision-making (PRETHINK) from the memory update (WRITE), InfMem can more effectively prioritize and integrate evidence, avoiding the memory drift seen in passive agents.
- Active Retrieval is Crucial: Simply increasing context window size isn't enough. Agents need to actively seek out and consolidate sparse, low-salience evidence, especially for multi-hop reasoning.
- Early Stopping is Key for Efficiency: The ability to confidently stop retrieving and answering once sufficient evidence is found is critical for making these long-context agents practical and efficient.
- SFT→RL for Robust Control: A two-stage training process is essential for aligning discrete, multi-step decisions with long-term rewards, ensuring both protocol adherence and task success.
Key Results
- Accuracy Gains: InfMem consistently outperforms MemAgent (a strong baseline) by a significant margin. For example, it achieves average absolute accuracy improvements of +10.17, +11.84, and +8.23 points on Qwen3-1.7B, Qwen3-4B, and Qwen2.5-7B models, respectively, on ultra-long QA benchmarks (up to 1M tokens).
- Inference Efficiency: InfMem reduces inference time by an average of 3.9× (up to 5.1×) due to its adaptive early stopping mechanism.
- Robustness: InfMem demonstrates remarkable robustness in long-context scaling, maintaining accuracy on benchmarks up to 1M tokens without significant degradation.
- Qualitative Improvements: Case studies show InfMem's ability to avoid processing irrelevant information, identify decisive evidence chains, and compose answers more accurately compared to baselines.
Limitations and Future Work
- Computational Cost: While InfMem is more efficient than simply expanding context, it still involves a recurrent process. Further optimizations for extremely long contexts might be explored.
- Dataset Construction: The paper relies on synthetic long-context datasets. While effective for controlled evaluation, real-world long-document scenarios might present different challenges.
- Future Work: The authors suggest that as context windows continue to scale, the bottleneck shifts from raw capacity to cognitive control—the ability to effectively discern and "know what is known." This highlights the importance of further research into sophisticated agent control mechanisms.
Summary updated