WorksComputer Science
MemDuet: Learning Dual-Process Memory for Long-Context Reasoning
Abstract
Reasoning over infinitely long documents is becoming a reality with recurrent memory agents. However, increasing context length exacerbates the trade-off between reasoning performance and inference efficiency. Inspired by Kahneman's account of fast and slow thinking, we propose MemDuet, a dual-process memory framework that learns to coordinate a small language model for fast, parallel evidence selection from raw context chunks (System 1) with a large language model for memory-update verification and memory updates in document order (System 2). We train MemDuet in three stages: supervised fine-tuning of System 1 for evidence selection, Group Relative Policy Optimization (GRPO) of System 2 for verification and memory rewriting, and joint optimization of both policies to coordinate selection and updating for long-context reasoning. Experiments on diverse long-context reasoning benchmarks (RULER-HQA, LongBench v2, and 2WikiMultiHopQA) demonstrate a favorable accuracy-efficiency trade-off as context length grows. Averaged across evaluation settings on the three datasets, MemDuet achieves an end-to-end inference speedup of 9.74x and an output-token reduction of 73.91% relative to RL-MemAgent.
Figure 1. Accuracy–efficiency trade-off on RULER-HQA. Accuracy, inference time, and output tokens are equally averaged over the nine shared length settings (7K–1.75M). Qwen and DS-Distill use the available settings. Circle areas use a square-root-compressed scale for mean output tokens per question; circle labels give actual output-token ratios to MemDuet (1×).
Introduction
Long-context reasoning is essential for large language models (LLMs) to synthesize evidence across documents, understand lengthy reports, and resolve repository-level dependencies in code [2] (Zhang et al. 2023). Existing work primarily extends long-context capability through larger context windows, sparse or linear attention, and retrieval-augmented generation (RAG) [6, 4] (Katharopoulos et al. 2020; Yuan et al. 2025; Lewis et al. 2020). However, these approaches remain bounded by the amount of context that can be directly represented or retrieved, leaving reasoning over unbounded documents unresolved.
MemAgent instead streams documents through a bounded recurrent memory, enabling reasoning over infinitely long documents with a fixed active context (Yu et al., 2026). Building on this paradigm, InfMem and GRU-Mem learn when to retrieve, update, or stop, while LycheeMemory compresses each chunk and invokes the reasoner only for selected memory blocks [7] (Wang et al. 2026; Sheng et al. 2026). These advances make recurrent memory increasingly selective, but expose a common bottleneck: control decisions either remain inside the sequential recurrent loop or operate on representations in which the original evidence has already been compressed. Consequently, as context grows, reasoning performance and inference efficiency remain tightly coupled.
Human reading and memory suggest a different principle: memory formation begins with selective attention. Readers first focus on goal-relevant information and then integrate the attended evidence with prior knowledge into a coherent memory representation [1] (Craik et al. 1996; Kintsch 1988). This process naturally maps onto the dual-process account of cognition: System 1 rapidly identifies potentially useful evidence, whereas System 2 deliberately assesses and consolidates it (Kahneman, 2011; Evans and Stanovich, 2013). Based on this insight, we propose MemDuet, a dual-process recurrent memory framework. A small language model (System 1) scans raw context in parallel to select candidate chunks for memory updating. A large language model (System 2) verifies whether each selected chunk warrants a memory update under the current memory, then rewrites memory. By combining small-model selective attention over raw chunks with large-model verification and memory updating, MemDuet balances reasoning performance and inference efficiency as context grows.
A key challenge is how to train the two systems to cooperate. We develop a progressive three-stage training strategy. First, we supervise System 1 to identify context chunks that are likely to trigger useful memory updates. Next, with System 1 fixed, we optimize System 2 using Group Relative Policy Optimization (GRPO; Shao et al., 2024), training it to verify memory-update decisions and rewrite memory toward successful downstream reasoning. Finally, we jointly optimize both systems with task-level rewards, allowing evidence selection and memory updating to co-adapt.
We evaluate MemDuet on RULER-HQA, LongBench v2, and long-context 2WikiMultihopQA. Results show that MemDuet improves the performance–efficiency trade-off over full-update recurrent memory agents, scaling to 3.5M-token contexts while achieving higher reasoning accuracy with substantially lower inference cost.
Our contributions are summarized as follows:
We propose MemDuet, a cognitively inspired dual-process memory framework for long-context reasoning, which instantiates System 1 as fast, parallel evidence selection with a small language model and System 2 as memory-update verification and memory rewriting with a large language model.
We develop a three-stage training strategy that first establishes the selection and memory-updating capabilities of the two systems through SFT and GRPO, respectively, and then jointly optimizes their cooperation under a shared downstream reasoning objective.
Extensive experiments on long-context reasoning benchmarks demonstrate that MemDuet achieves a favorable balance between reasoning performance and inference efficiency.
Related Work
Recurrent Memory for Long-Context Reasoning
Recurrent-memory methods process documents incrementally while maintaining a bounded state, allowing language models to handle inputs far beyond their context windows. MemAgent sequentially processes text chunks and repeatedly rewrites a textual memory, using end-to-end reinforcement learning to retain task-relevant information and discard distractors based on downstream rewards (Yu et al., 2026). Building on this paradigm, InfMem and GRU-Mem learn retrieval, memory updating, and early-stopping decisions through SFT-to-RL training or behavior-specific rewards (Wang et al., 2026; Sheng et al., 2026). LycheeMemory compresses individual chunks and selectively invokes the reasoner, jointly optimizing its compressor and reasoner through end-to-end reinforcement learning [7]. These studies turn memory management from a fixed procedure into a task-driven policy, but their control decisions remain within the sequential loop or operate on already compressed evidence. MemDuet instead scans raw chunks in parallel before recurrent updating and progressively coordinates evidence selection with memory consolidation.
Cognitively Inspired Language Models and Memory
Cognitive theories have informed both memory design and computational allocation in language-model systems. CoALA organizes language agents around modular memory, decision-making, and action components derived from cognitive architectures (Sumers et al., 2024). MemoryBank adopts an Ebbinghaus-inspired mechanism for dynamically forgetting and reinforcing memories (Zhong et al., 2024), whereas HippoRAG draws on hippocampal indexing theory to support associative knowledge retrieval (Gutiérrez et al., 2024). For reasoning, System 2 Attention deliberately rewrites the context to remove irrelevant information (Weston and Sukhbaatar, 2023), while Dualformer learns switchable fast and slow reasoning modes within a single model (Su et al., 2025). These studies primarily apply cognitive principles to memory organization, retrieval, or the allocation of reasoning effort. MemDuet instead introduces dual-process specialization into recurrent memory: System 1 selects raw candidate chunks in parallel; System 2 verifies whether they warrant memory updates under the current memory and consolidates their evidence.
Methodology
Preliminaries
Problem setup. We consider query-conditioned reasoning over a long document . Given a query , the goal is to generate an answer using evidence from , whose length may exceed the model’s context window. We divide into chunks in their original order, with , where denotes token length and is the chunk-size budget. The query is available throughout document processing.
Recurrent textual memory. Following MemAgent (Yu et al., 2026), an LLM carries information across chunks through bounded textual memory, using the common interface
Here and are the preceding and replacement memories, and is the memory budget. Under the memory prompt, is the autoregressive product of System 2’s next-token policy . The same model answers from and the final memory under the answer prompt. Both and are independent of document length.
MemDuet Workflow
MemDuet alternates parallel raw-chunk selection by System 1 with verification and memory updates in document order by System 2 (Figure 2).
Figure 2. MemDuet’s overall inference workflow. System 1 predicts Skip/Update in parallel for raw chunks under a shared memory state. Candidate chunks retain their original text. System 2 verifies whether a selected chunk warrants a memory update given the current memory, then generates and commits memory from the first accepted chunk in document order. Later chunks are reevaluated under the updated memory.
System 1: Memory-Conditioned Parallel Candidate Selection
Here indexes speculative rounds and document chunks. At round , System 1 independently evaluates a window of up to consecutive chunks in parallel, using the shared query and memory to select candidate chunks for memory updating:
The chunks predicted as Update form the candidate set
which is forwarded to System 2.
System 2: Speculative Verification and Memory Consolidation
Inspired by speculative decoding’s acceptance rule [5] (Leviathan et al. 2023), System 2’s binary policy assesses whether selected chunks warrant memory updates. For candidate indices , the action-level acceptance probability is
Independently draw for each candidate and accept it if .
If any candidate is accepted, commit the first accepted chunk in document order and generate its replacement memory:
where . As a special case, if no candidate is accepted, retain the current memory and advance past the window. Otherwise, discard remaining predictions conditioned on and resume immediately after the committed chunk with . Answering uses the query and final memory; Algorithm 3 in Appendix § 7.§ 4 gives the complete transitions.
Training of MemDuet
Figure 3 summarizes three-stage training. Stage I trains memory-conditioned evidence selection. Stage II freezes System 1 and trains System 2 to verify candidates, rewrite memory, and generate answers. Stage III jointly optimizes both systems with task rewards, coordinating selection with verification and memory updates.
Figure 3. Three-stage training of MemDuet. Stage I trains System 1 with weighted classification and a paired-memory hinge loss. Stage II freezes System 1 and optimizes System 2 with GRPO. Stage III jointly optimizes both systems using task rewards.
Stage I: System 1 Supervised Warm-up
We initialize System 1 on HotpotQA (Yang et al., 2018) by aligning gold supporting facts with document chunks. Evidence-containing chunks are labeled Update, and other chunks Skip.
For each Update example , let be the memory after incorporating the evidence from . We retain the original example and add a post-update negative:
We train on the original examples and post-update negatives using the memory-contrastive objective:
Here, is class-weighted action cross-entropy; contains matched memory pairs, with . The score is the UPDATE-minus-SKIP logit difference, and is the margin. Hyperparameters are reported in Appendix § 7.§ 1.
Stage II: System 2 Reinforcement Learning
We freeze System 1 at and optimize all System 2 parameters by reinforcement learning over complete trajectories. Selections are recomputed online as System 2 updates memory.
For each training instance , sample complete trajectories using the behavior-policy snapshot . From the final-answer rewards , we compute the group-relative advantage:
Here indexes trajectories and is a numerical stability term. We use a clipped GRPO loss with generated-token KL regularization (Shao et al. (2024)):
where contains verification commitment events for nonempty candidate sets and all generated tokens; contains only generated tokens. is a verification commitment event or generated token, and is its current-to-behavior probability ratio. Verification commitment, token generation, and Stage III selection ratios are denoted by , , and , respectively; is the clipping parameter.
For a round- verification event with a committed chunk, let record its index. The ratio is
where is the round- verification commitment event. denotes the distribution of commitment outcomes induced by independent acceptance tests under the given query, window, candidate indices, and memory. For a candidate index , its commitment probability is . As a special case, the no-commitment probability is ; it is one for empty , with no verification-policy loss. The controller’s independent acceptance tests and ordered commitment induce this distribution; selection and verification calls condition on .
For a committed-chunk memory update, let index tokens and denote the generated prefix. Its token-level ratio is
where is the generation event for token and . As a special case, first-chunk initialization tokens and final-answer tokens use the token-level ratio in Eq. (11), conditioned on and , respectively. Here, is the fixed initial-memory marker and is the final memory. Both token types contribute to the policy loss and KL regularizer in Eq. (9).
KL uses full token conditions and , a frozen copy of the initial System 2 model. It applies only to generated tokens (Appendix § 7.§ 2).
Stage III: Joint Policy Optimization
Let denote the complete trajectory distribution induced by selection, verification commitments, and System 2’s memory and answer generation (Appendix § 7.§ 3). With both backbones frozen, we jointly optimize only their LoRA adapters:
using fresh rollout groups under and the Stage-II advantages. The clipped loss adds selection events recording both Skip and Update actions , with ratios
where is the selection event for chunk in round . Commitment ratios follow Eq. (10), replacing with in the numerator and in the denominator, retaining dependence on both systems through Eq. (4). Generation ratios and generation-only KL, including the same frozen reference policy, are retained from Stage II.
Experiments
Experimental Setup
Datasets and evaluation. We follow MemAgent’s RULER-HQA construction (7K–3.5M tokens) (Yu et al. (2026)), reserving its 128-question development set for testing and a disjoint 128-question HotpotQA validation set for checkpoint selection. We further evaluate on LongBench v2 [3] and a long-context variant of 2WikiMultihopQA (Ho et al., 2020). We report option accuracy on LongBench v2 and normalized substring exact match (sub-EM) on RULER-HQA and 2WikiMultihopQA. To assess inference efficiency, we additionally report speedup relative to MemAgent and the number of generated output tokens. Dataset construction, sample sizes, and length groupings are detailed in Appendix § 6.§ 1; evaluation protocols are provided in Appendix § 6.§ 3.
Baselines. We compare MemDuet with Search-R1-7B (Jin et al., 2025a), QwenLong-L1-32B (Wan et al., 2025), DS-Distill-32B (DeepSeek-AI et al., 2025), RL-MemAgent-7B (Yu et al., 2026), LycheeMemory-7B [7], and ReMemR1-7B (Shi et al., 2025).
Implementation. We use Qwen3.5-2B as System 1 for the main results and evaluate Qwen2.5-0.5B, Qwen2.5-1.5B, and Qwen3.5-0.8B in the System 1 backbone comparison (Yang et al., 2025a; Qwen Team, 2026). System 2 uses the same Qwen2.5-7B-Instruct backbone as MemAgent (Yang et al., 2025a; Yu et al., 2026). See Appendix § 7 for training and implementation.
Main Results
Length scaling on RULER-HQA. Table 1 shows that MemDuet achieves an increasingly favorable accuracy–efficiency trade-off as context grows. At 3.5M tokens, it outperforms RL-MemAgent by 3.90 points while achieving a 49.61 speedup and generating 99.14% fewer output tokens. At 7K, the limited number of chunks provides little opportunity to offset the fixed cost of System 1 scanning and cross-system coordination. As the context grows, this overhead is amortized and more unnecessary System 2 processing can be avoided, making the efficiency gains increasingly pronounced without sacrificing accuracy.
| Method | 7K | 14K | 28K | 56K | 112K | 224K | 448K | 896K | 1.75M | 3.5M |
| Accuracy (%, ) | ||||||||||
| Search-R1 7B | 72.66 | 71.88 | 67.71 | 73.96 | 66.67 | 62.50 | 64.58 | 67.71 | 67.19 | — |
| QwenLong-L1 32B | 72.66 | 75.00 | 72.66 | 60.94 | 31.25 | 17.19 | 13.28 | 11.72 | N/A | N/A |
| DS-Distill 32B | 70.31 | 66.41 | 65.62 | 46.88 | 23.44 | 13.28 | 7.81 | 7.03 | N/A | N/A |
| RL-MemAgent 7B | 81.25 | 81.25 | 82.03 | 80.47 | 79.69 | 75.78 | 76.56 | 74.22 | 77.34 | 71.88 |
| LycheeMemory () 7B | 80.47 | 81.25 | 82.03 | 81.25 | 80.47 | 79.69 | 75.00 | 75.78 | 78.12 | — |
| LycheeMemory () 7B | 77.34 | 76.56 | 75.00 | 76.56 | 75.78 | 73.44 | 74.22 | 72.66 | 71.09 | — |
| ReMemR1 7B | 82.03* | 82.81* | 81.25* | 78.91* | 82.81* | 79.69* | 80.47* | 77.34* | 71.09* | 72.66* |
| MemDuet 7B | 87.50 | 83.59 | 89.06 | 79.69 | 87.50 | 85.94 | 82.81 | 82.03 | 79.69 | 75.78 |
| Time speedup (MemAgent = 1, ) | ||||||||||
| LycheeMemory () 7B | 0.191 | 0.206 | 0.233 | 0.305 | 0.377 | 0.445 | 0.393 | 0.515 | 0.411 | 0.399 |
| LycheeMemory () 7B | 0.19 | 0.25 | 0.37 | 0.76 | 1.32 | 2.62 | 3.81 | 9.12 | 11.6 | — |
| ReMemR1 7B | 0.173 | 0.185 | 0.213 | 0.272 | 0.325 | 0.353 | 0.413 | 0.469 | 0.456 | 0.560 |
| MemDuet 7B | 0.983 | 1.445 | 1.588 | 3.541 | 5.885 | 9.885 | 11.913 | 18.688 | 39.085 | 49.613 |
| Output tokens (MemAgent = 1, ) | ||||||||||
| LycheeMemory () 7B | 1.99 | 1.86 | 1.54 | 1.21 | 0.92 | 0.81 | 0.92 | 0.70 | 0.89 | 0.90 |
| ReMemR1 7B | 4.75 | 4.40 | 3.62 | 2.82 | 2.29 | 2.11 | 1.78 | 1.57 | 1.62 | 1.28 |
| MemDuet 7B | 0.9050 | 0.5659 | 0.3671 | 0.2012 | 0.1154 | 0.0607 | 0.0543 | 0.0460 | 0.0117 | 0.0086 |
Table 1. Accuracy and inference efficiency on RULER-HQA across context lengths from 7K to 3.5M tokens. Relative to RL-MemAgent, speedup () is , and the output-token ratio () is , where and denote inference time and generated-token count, respectively. LycheeMemory () disables/enables its native memory gate. * denotes results from our reproduction. Bold and underlined values indicate the best and second-best reported results at each length within each metric block. “N/A” denotes unavailable results; “-” denotes results not reported in the original paper.
Generalization to realistic long-context tasks. Table 2 evaluates MemDuet on LongBench v2, which contains realistic long-context tasks, and on length-controlled 2WikiMultihopQA. MemDuet achieves the highest option accuracy on the Long and Ultra groups of LongBench v2, with and speedups. Its lower option accuracy on the Short and Medium groups is consistent with selective processing occasionally discarding useful evidence when the full input is still manageable. The same transition appears in sub-EM on 2WikiMultihopQA: MemDuet trails at 14K and 56K, but leads at 224K and 896K, indicating that its advantages are concentrated in the long-context regime for which it is designed.
| Metric | Method | Short | Medium | Long | Ultra |
| Option Acc. ↑ | MemAgent | 33.62 | 31.91 | 25.00 | 28.28 |
| LycheeMemory (−G) | 25.86 | 31.91 | 29.00 | 28.28 | |
| MemDuet | 31.03 | 31.38 | 30.00 | 29.29 | |
| Speedup ↑ | LycheeMemory (−G) | 0.45× | 0.54× | 0.55× | 0.59× |
| MemDuet | 1.69× | 1.96× | 3.00× | 8.03× | |
| Tokens ↓ | LycheeMemory (−G) | 1.10× | 0.90× | 0.89× | 0.83× |
| MemDuet | 0.52× | 0.42× | 0.27× | 0.09× | |
| Metric | Method | 14K | 56K | 224K | 896K |
| sub-EM ↑ | MemAgent | 67.97 | 67.19 | 57.81 | 57.03 |
| LycheeMemory (−G) | 64.84 | 64.84 | 59.38 | 52.34 | |
| MemDuet | 64.84 | 61.72 | 61.72 | 59.38 | |
| Speedup ↑ | LycheeMemory (−G) | 0.27× | 0.42× | 0.63× | 0.64× |
| MemDuet | 1.46× | 3.56× | 5.56× | 7.35× | |
| Tokens ↓ | LycheeMemory (−G) | 1.93× | 1.20× | 0.77× | 0.77× |
| MemDuet | 0.60× | 0.21× | 0.14× | 0.11× |
Table 2. LongBench v2 (top; option accuracy, %) and long-context 2WikiMultihopQA (bottom; sub-EM, %) results. LycheeMemory uses no gate (−G); bold marks the best values per length and metric.
Analysis
Efficiency scaling. Figure 4 shows that MemDuet’s latency and output tokens grow more slowly with context length than those of RL-MemAgent. Although MemDuet incurs a small latency overhead at 7K, its runtime advantage becomes increasingly pronounced on longer inputs. The shallower growth in output tokens is consistent with restricting large-model memory updates to selected evidence rather than rewriting memory for every chunk. Latency savings are smaller than token savings, since input processing and System 1 computation remain necessary even when output tokens are substantially reduced.
Figure 4. Efficiency scaling on RULER-HQA from 7K to 3.5M tokens. The upper and lower panels report latency and total output tokens from both systems per example, respectively, on logarithmic axes.
| Framework | Acc. (%) ↑ | 112K | 448K | 896K | Speed ↑ | Tokens ↓ |
| MemDuet | 87.50 | 82.81 | 82.03 | 12.16× | .0719× | |
| Inference Mechanisms | ||||||
| w/o parallel execution | 87.50 | 82.81 | 82.03 | 11.84× | .0661× | |
| w/o draft–verify | 84.38 | 78.91 | 78.13 | 9.89× | .0769× | |
| w/o state reevaluation | 84.38 | 80.47 | 78.13 | 11.58× | .0712× | |
| Three-Stage Training | ||||||
| w/o Stage I | 82.03 | 78.91 | 77.34 | 2.54× | .2107× | |
| w/o Stage II | 38.28 | 25.78 | 29.69 | 28.54× | .0082× | |
| w/o Stage III | 81.25 | 80.47 | 78.91 | 8.81× | .05682× |
Table 3. Ablations of MemDuet’s inference mechanisms and three-stage training on RULER-HQA. Accuracy is reported at 112K, 448K, and 896K tokens. Speed and Tokens equally average per-length ratios relative to RL-MemAgent. W/o Stage I retains Stages II and III; w/o Stage II retains Stages I and III; w/o Stage III retains Stages I and II.
Inference mechanisms. W/o draft–verify retains System 1 selection but removes System 2 verification and acceptance tests: selected Update actions directly trigger memory rewriting, followed by reevaluation of later chunks. W/o state reevaluation reuses selection and verification/acceptance results computed with the window-start memory even after updates, processing chunks in document order; memory generation still uses the latest memory. W/o parallel execution changes to , retaining all other decision rules. The variant preserves accuracy, with speedup changing from 12.16× to 11.84×. Removing draft–verify or state reevaluation reduces accuracy by up to 3.90 points; draft–verify removal also lowers speedup to 9.89×. Verification and state reevaluation thus preserve quality while reducing large-model computation.
Three-stage training. The three training stages play complementary roles. Without Stage I, System 1 tends to propose updates for nearly all chunks, maintaining coverage of supporting evidence and limiting the accuracy drop to 3.90–5.47 points relative to the full configuration. More frequent verification and memory rewriting increase computation, reducing speedup from 12.16× to 2.54× and roughly tripling the mean output-token ratio. Without Stage II, System 2 lacks dedicated reinforcement learning for memory rewriting, substantially weakening evidence consolidation. The retained Stage III joint training partially restores this capability, keeping accuracy above the Qwen2.5-7B-Instruct baseline (112K: 32.81%; 448K: 6.25%; 896K: 1.56%). Stage III aligns the two policies: joint optimization recovers 2.34–6.25 accuracy points over w/o Stage III. The curriculum thus progressively learns when to update, how to update, and how to coordinate the two decisions.
Choice of System 1. System 1 should favor evidence coverage, since missed evidence cannot be recovered, whereas false positives can still be filtered by System 2. Across both Qwen2.5 and Qwen3.5 backbones, MemDuet consistently turns small models into effective proposers, achieving 80.08–83.36% downstream accuracy with mean speedups of 5.69–14.26×. Qwen3.5-0.8B has the highest selection F1 and lowest output-token ratio,
| 112K | 448K | 896K | 1.75M | |
| 1 | 1× | 1× | 1× | 1× |
| 2 | 1.006× | 1.032× | 1.010× | 1.087× |
| 4 | 0.968× | 0.981× | 1.080× | 1.107× |
| 8 | 0.920× | 0.867× | 0.919× | 1.111× |
| 16 | 0.768× | 0.777× | 0.838× | 0.927× |
| 32 | 0.741× | 0.567× | 0.828× | 0.763× |
Table 5. Effect of the parallel chunk window width . Speedups are measured relative to the same-length serial configuration (); values below 1× indicate slower execution. Bold marks the highest speedup at each length, and shading denotes the default .
| API family | Method | Option Acc. (%) ↑ | Latency (s) ↓ | Cost ($) ↓ |
| DeepSeek-V4 | MemAgent | 57.46 | 634.23 | 0.1974 |
| MemDuet | 57.65 | 178.55 | 0.0825 | |
| GPT-5.6 | MemAgent | 61.63 | 438.92 | 0.5978 |
| MemDuet | 61.03 | 128.46 | 0.2398 |
Table 6. Training-free transfer to proprietary models on LongBench v2, reporting option accuracy. MemDuet combines off-the-shelf System 1 and System 2 APIs using binary accept-or-reject verification. Latency and cost include both systems.
while Qwen3.5-2B, used for the main results, attains the highest final accuracy and mean speedup. Selection quality should be evaluated alongside answer quality and inference cost.
Effect of parallelism. Parallel chunk processing provides only modest gains because MemDuet must preserve the document order of memory updates. System 1 evaluates chunks concurrently, but System 2 rewrites memory from the first accepted chunk in document order and reevaluates later chunks under the updated memory. As increases, more speculative computation may therefore be discarded, and synchronization overhead can outweigh the benefit of concurrency. The best speedup is 1.111× at and 1.75M tokens, whereas and show inference at every evaluated length. Moderate parallelism thus provides the best balance between concurrent evidence discovery and memory consolidation in document order.
Transfer to proprietary models. MemDuet can be directly applied to proprietary APIs without additional training: a smaller model serves as System 1 to propose candidate chunks, while a stronger model serves as System 2 to accept or reject each proposal before memory rewriting. This plug-and-play setup reduces latency by 70.7–71.8% and cost by 58.2–59.9%, with option accuracy changing by at most 0.60 points.
Conclusion
MemDuet combines memory-conditioned parallel evidence selection by a small language model with large-model verification and document-order memory updates. Three-stage training teaches both systems when to update memory and how to consolidate evidence and coordinate decisions. Experiments on three long-context reasoning benchmarks show a favorable accuracy–efficiency trade-off, with greater efficiency gains at longer contexts.
Limitations
Our evaluation is limited to three long-context benchmarks and mainly Qwen-family backbones, so generalization to other domains and model families remains uncertain. MemDuet is also less effective on shorter inputs, where selective processing may discard useful evidence; moreover, evidence missed by System 1 cannot be recovered by System 2. Memory updates in document order further limit the practical benefits of parallel execution.
Ethical Considerations
MemDuet studies efficient reasoning over long documents using existing benchmarks and pretrained language models. These resources can contain inaccurate, biased, or sensitive material. Their use and redistribution should respect the applicable licenses and access conditions. Benchmark performance alone does not establish fairness, privacy protection, or suitability for deployment.
Selective processing can omit relevant evidence or minority viewpoints, while repeated memory updates can preserve unsupported claims and discard qualifications. The verifier evaluates memory-update decisions and should not be treated as an independent guarantee of factual correctness. For consequential applications, users should retain access to original documents, inspect supporting evidence, and require human review of outputs. Additional evaluation across languages, domains, and population groups is needed before such use.
Long documents, intermediate memories, and generated answers may expose personal or confidential information. Deployments should minimize sensitive data, restrict access to stored memories and logs, and define appropriate retention and deletion procedures. Users should confirm authorization before transmitting content to proprietary APIs and consider the providers’ data-handling policies.
Lower inference cost may make document analysis more accessible, but can also facilitate large-scale surveillance or unauthorized profiling. Applications should be limited to authorized, legitimate uses. Finally, reduced latency and output-token counts do not directly quantify energy consumption or carbon emissions; environmental benefits require dedicated measurement that also accounts for training and total usage.
Experimental Setup
Dataset Construction
RULER-HQA: We combine the RULER evaluation framework (Hsieh et al., 2024), HotpotQA validation questions (Yang et al., 2018), and MemAgent’s controlled-length document construction (Yu et al., 2026). Supporting documents are combined with distractors. The test sets retain the same 128 questions and supporting evidence across length settings, while additional documents increase the input length. Testing covers ten nominal lengths: 7K, 14K, 28K, 56K, 112K, 224K, 448K, 896K, 1.75M, and 3.5M tokens. Documents are divided into consecutive 5,000-token chunks using the updater tokenizer, preserving their order. We reserve the 128 questions in MemAgent’s released development set exclusively for final testing. A separate set of 128 questions from the remaining HotpotQA validation split is used for training-time validation and checkpoint selection (Appendix § 7.§ 2).
LongBench v2: Table 2 uses our four token-length groups, covering all 503 questions. Let be the source-context token count measured with the fixed Qwen2.5-7B-Instruct tokenizer: Short (; 116 questions), Medium (; 188), Long (; 100), and Ultra (; 99).
2WikiMultihopQA: We use the same evidence-plus-distractor construction strategy as RULER-HQA, following MemAgent (Yu et al., 2026). The data come from FlashRAG (Jin et al., 2025b). We exclude questions missing annotated supporting documents and build a deduplicated title-and-text document pool. Each question retains its reference answers and original context, including all supporting documents. Additional documents are sampled from the pool, excluding that question’s original documents, to reach 100, 400, 1,600, or 6,400 documents. Each context is shuffled and concatenated with numbered document headers. These counts define the nominal 14K, 56K, 224K, and 896K settings in Table 2. All lengths and methods share the same 128 questions: the first 128 of 640 sampled eligible question indices.
Models and Baselines
System 1: We use Qwen2.5-0.5B, Qwen2.5-1.5B, Qwen3.5-0.8B, and Qwen3.5-2B as small-model backbones ((Yang et al., 2025a; Qwen Team, 2026)).
System 2: We use Qwen2.5-7B-Instruct as the large-model backbone ((Yang et al., 2025a)).
We group the baselines in the complete comparison (Table A4) by their long-context processing mechanism:
| Method | 7K | 14K | 28K | 56K | 112K | 224K | 448K | 896K | 1.75M | 3.5M |
| Performance: Accuracy (%, ) | ||||||||||
| RAG | 67.19 | 66.41 | 66.41 | 67.19 | 64.84 | 64.06 | 62.50 | 61.72 | 62.38 | — |
| Search-R1 | 72.66 | 71.88 | 67.71 | 73.96 | 66.67 | 62.50 | 64.58 | 67.71 | 67.19 | — |
| QwenLong-L1 | 72.66 | 75.00 | 72.66 | 60.94 | 31.25 | 17.19 | 13.28 | 11.72 | N/A | N/A |
| QwenLong-L1.5 30B-A3B | 67.97 | 68.75 | 66.41 | 63.28 | 61.72 | 59.38 | 43.75 | 39.06 | 28.13 | — |
| Qwen2.5-Instruct | 69.53 | 64.84 | 60.16 | 51.56 | 44.53 | 21.88 | 14.06 | 7.03 | N/A | N/A |
| Qwen2.5-Instruct | 75.00 | 67.19 | 57.03 | 54.69 | 44.53 | 21.88 | 10.94 | 2.34 | N/A | N/A |
| Qwen2.5-Instruct | 52.34 | 57.03 | 51.56 | 44.53 | 32.81 | 13.28 | 6.25 | 1.56 | N/A | N/A |
| Qwen2.5-1M | 60.16 | 60.94 | 50.00 | 57.03 | 50.00 | 37.50 | 8.59 | 0.00 | N/A | N/A |
| Qwen2.5-1M | 61.72 | 56.25 | 53.91 | 55.47 | 51.56 | 33.59 | 12.50 | 0.00 | N/A | N/A |
| DS-Distill | 70.31 | 66.41 | 65.62 | 46.88 | 23.44 | 13.28 | 7.81 | 7.03 | N/A | N/A |
| DS-Distill | 64.06 | 64.84 | 57.03 | 40.62 | 14.84 | 8.59 | 3.12 | 6.25 | N/A | N/A |
| DS-Distill | 30.47 | 12.50 | 3.12 | 0.00 | 0.00 | 0.78 | 0.00 | 0.00 | N/A | N/A |
| RL-MemAgent | 80.47 | 82.03 | 82.03 | 83.59 | 81.25 | 77.34 | 79.69 | 75.78 | 78.91 | 71.09 |
| RL-MemAgent | 81.25 | 81.25 | 82.03 | 80.47 | 79.69 | 75.78 | 76.56 | 74.22 | 77.34 | 71.88 |
| InfMem | 80.47* | 82.81* | 72.66* | 75.78* | 76.56* | 75.00* | 65.62* | 84.38* | 78.12* | 68.75* |
| Lychee () | 80.47 | 81.25 | 82.03 | 81.25 | 80.47 | 79.69 | 75.00 | 75.78 | 78.12 | — |
| Lychee () | 77.34 | 76.56 | 75.00 | 76.56 | 75.78 | 73.44 | 74.22 | 72.66 | 71.09 | — |
| ReMemR1 | 82.03* | 82.81* | 81.25* | 78.91* | 82.81* | 79.69* | 80.47* | 77.34* | 71.09* | 72.66* |
| MemDuet | 87.50 | 83.59 | 89.06 | 79.69 | 87.50 | 85.94 | 82.81 | 82.03 | 79.69 | 75.78 |
| Efficiency: Time speedup (, ) | ||||||||||
| MemAgent | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 |
| InfMem | 0.14 | 0.15 | 0.21 | 0.51 | 0.74 | 1.16 | 1.83 | 6.68 | 12.6 | 6.11 |
| GRU-Mem | 1.09 | 0.98 | 1.21 | 1.57 | 1.66 | 2.04 | 2.30 | 2.40 | — | — |
| Lychee () | 0.191 | 0.206 | 0.233 | 0.305 | 0.377 | 0.445 | 0.393 | 0.515 | 0.411 | 0.399 |
| Lychee () | 0.19 | 0.25 | 0.37 | 0.76 | 1.32 | 2.62 | 3.81 | 9.12 | 11.6 | — |
| ReMemR1 | 0.173 | 0.185 | 0.213 | 0.272 | 0.325 | 0.353 | 0.413 | 0.469 | 0.456 | 0.560 |
| MemDuet | 0.983 | 1.445 | 1.588 | 3.541 | 5.885 | 9.885 | 11.913 | 18.688 | 39.085 | 49.613 |
| Efficiency: Output tokens (MemAgent = 1, ) | ||||||||||
| MemAgent | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| InfMem | 5.6 | 4.4 | 2.8 | 1.2 | 0.63 | 0.45 | 0.27 | 0.081 | 0.040 | 0.069 |
| Lychee () | 1.99 | 1.86 | 1.54 | 1.21 | 0.92 | 0.81 | 0.92 | 0.70 | 0.89 | 0.90 |
| ReMemR1 | 4.75 | 4.40 | 3.62 | 2.82 | 2.29 | 2.11 | 1.78 | 1.57 | 1.62 | 1.28 |
| MemDuet | 0.9050 | 0.5659 | 0.3671 | 0.2012 | 0.1154 | 0.0607 | 0.0543 | 0.0460 | 0.0117 | 0.0086 |
Table A4. RULER-HQA length scaling. The three panels report accuracy (%; local values use sub-EM), time speedup relative to MemAgent-7B, and relative output tokens (MemAgent = 1). Output tokens include both systems’ outputs. * denotes results from our reproduction. Within each column and panel, bold and _underlined_ values indicate the best and second-best distinct values, respectively. “-” denotes unreported results; N/A denotes unavailable results.
Base-model approaches: Qwen2.5-Instruct (7B, 14B, and 32B) (Yang et al., 2025a), Qwen2.5-1M (7B and 14B) (Yang et al., 2025b), QwenLong-L1 (32B), and DS-Distill (7B, 14B, and 32B) generate answers directly from the supplied context, without an external retrieval or memory-update workflow.
RAG-based approaches: RAG and Search-R1, both using Qwen2.5-7B-Instruct, retrieve relevant documents before or during answer generation.
Agent-based approaches: RL-MemAgent (7B and 14B), InfMem (4B), GRU-Mem (7B), LycheeMemory (7B, and ), ReMemR1 (7B), and QwenLong-L1.5-30B-A3B ((Shen et al., 2025)) maintain and update memory to process long contexts incrementally.
Evaluation Metrics and Protocol
Open-ended question answering. For RULER-HQA and long-context 2WikiMultihopQA, we report normalized substring exact match (sub-EM). We lowercase predictions and reference answers, remove punctuation and English articles, and collapse whitespace. Following the MemAgent scorer, a nonempty extracted prediction receives 1 if either normalized answer is a substring of the other, and 0 otherwise. We take the maximum score over reference-answer aliases and report the mean as a percentage.
Multiple-choice question answering. For LongBench v2, we report option accuracy: the percentage of questions whose extracted prediction in exactly matches the reference option. Missing or unparseable option labels score 0. This compares option labels without the open-ended QA normalization or substring-matching rule. The question-and-options prompt and final-answer format are given in Appendix § 10.§ 5.
Inference time and speedup. Local per-question latency covers initialization, selection, verification, committed rewrites, and answering, excluding model loading, warm-up, and offline input preparation. Rejected or stale requests may still incur processing cost. Within one length setting and the same question cohort, let and denote the inference time of MemAgent and the evaluated method on question . Speedup relative to MemAgent is
MemAgent has a speedup of ; values above indicate faster inference than MemAgent.
Output tokens and reduction. Output tokens include System 1’s output and System 2’s verification, memory generation, and final-answer output. For the same length setting and question cohort, let and denote the respective output-token counts on question . The output-token ratio and percentage reduction relative to MemAgent are
MemAgent has and zero reduction; a positive reduction means fewer output tokens than MemAgent.
Training and Implementation Details
We train MemDuet on NVIDIA A100 (80GB) GPUs. For inference, we use NVIDIA A100 (80GB) GPU and process one example at a time (batch size 1).
Stage I: Memory-Contrastive Supervised Warm-up
Training data. We use 32,758 HotpotQA training questions ((Yang et al., 2018)) with complete RL-MemAgent-7B teacher-memory trajectories. We randomly select 500 questions for validation and use the remaining 32,258 questions for training. All chunks and memory pairs from the same question remain in the same split.
Contexts are divided into consecutive 5,000-token chunks with the teacher tokenizer. The first chunk initializes memory and is excluded from action training examples. Gold supporting facts identify evidence chunks, and the teacher updates memory only at these chunks in document order. Each subsequent chunk is paired with the question and the memory before that chunk: evidence chunks yield UPDATE examples, while other chunks yield natural SKIP examples. For every UPDATE example, replacing only the memory with the teacher’s post-update memory yields an additional SKIP example:
Changing memory alone changes the target to SKIP. The training set contains 195,111 examples: 41,180 UPDATE examples, 112,751 natural SKIP examples, and 41,180 post-update SKIP examples. The validation set contains 2,996 examples: 627 UPDATE examples, 1,742 natural SKIP examples, and 627 post-update SKIP examples.
Configuration. For Stage I, we train a System 1 LoRA adapter ((Hu et al., 2022)) with rank , scaling parameter , and dropout 0.05. We use the AdamW optimizer with learning rate , a cosine annealing schedule, and a warm-up ratio of 0.03. The effective batch size is 64, the precision is bf16, and the training budget is three epochs. The UPDATE and SKIP class weights are 13 and 1, respectively; the paired-memory hinge loss has margin 1 and weight 0.2. The class-weighted action cross-entropy is normalized by the total target-class weight in each batch.
Stage II: Optimizing System 2 with a Fixed Selector
Dataset Construction
We use MemAgent’s released long-context HotpotQA data ((Yu et al., 2026)) for the 32,768 training examples derived from the HotpotQA training split. The 128 questions in MemAgent’s released development set are reserved exclusively for final RULER-HQA testing across context lengths (Appendix § 6.§ 1). For periodic validation and checkpoint selection, we sample 128 additional questions from the remaining HotpotQA validation split with random seed 42. Their long contexts use the same evidence-plus-distractor construction. The resulting validation set is fixed before training, and test results are not used to select checkpoints. Each example pairs a question with its long context and reference answer :
For training, we apply center truncation to each long context and divide it into consecutive 5,000-token chunks in document order, retaining at most eight chunks per question. All chunks of an example share the same question and reference answer. The offline data contain no reference-memory sequence or fixed candidate indices. System 2 generates initialization and replacement memories online. The frozen selector is reevaluated using each generated memory.
Reward Function
We compute answer rewards using normalized exact matching of boxed answers. For each trajectory, we extract the answer inside the last \boxed{...} field in the final 300 output characters as the prediction. We lowercase the prediction and reference answer aliases and apply formatting normalization. The answer reward is 1 if the prediction exactly matches any normalized reference alias; missing, malformed, or unmatched answers receive 0.
For trajectory , let denote the binary score of the final answer . We use this score as the training reward:
For each question, we sample complete trajectories and compute standardized group-relative advantages using Eq. (8). Each trajectory’s advantage is shared by its verification commitment events and all generated tokens for System 2 policy optimization.
Training Configuration
For the full configuration, we initialize System 1 from the Stage I Qwen3.5-2B model and freeze the selector throughout Stage II. System 2 is initialized from Qwen2.5-7B-Instruct, and all its parameters are optimized. For KL regularization, the generation reference policy is a frozen copy of this initial Qwen2.5-7B-Instruct model. It remains fixed throughout Stage II, while the behavior snapshot is refreshed each iteration.
Stage II collects complete trajectories under . System 2 initializes memory from the first chunk, and the frozen selector evaluates a four-chunk window under the current memory. System 2 scores the selected candidates; independent acceptance tests follow Eq. (4). Only the first accepted candidate in document order triggers a memory rewrite. Subsequent decisions under the old memory are discarded, and processing resumes after the committed chunk. If no candidate is accepted, memory is unchanged and the cursor advances past the window. After document processing, System 2 generates the final answer from the question and final memory.
We use AdamW to update all System 2 parameters with a learning rate of . The selector uses a four-chunk window. Table A1 summarizes the configuration.
| Setting | Value |
| Training / validation instances | 32,768 / 128 |
| Questions rollouts | 128 16 = 2,048 |
| Question limit | 1,024 tokens |
| Chunk / memory / answer limits | 5,000 / 1,024 / 1,024 tokens |
| Maximum chunks / selector window | 8 / 4 |
| Trainable parameters | All System 2; System 1 frozen |
| Optimizer / learning rate | AdamW / |
| Weight decay / gradient clipping | 0.01 / 1.0 |
| Warm-up / schedule | 20 steps; then constant |
| PPO question minibatch / passes | 8 / 1 |
| Policy clip | 0.2 |
| Generation KL / entropy coefficient | / 0 |
| Training temperature / top- | 1 / 1 |
| Validation rollouts / temperature / top- | 4 / 1 / 0.7 |
| Training budget | 25 epochs |
| Save / validation interval | 10 / 5 rollout batches |
| Rollout precision | bfloat16 |
Table A1. Stage II training configuration.
With a training budget of 25 epochs, Stage II minimizes Eq. (9). Clipped policy losses are averaged over separately within each trajectory. KL terms are averaged only over generated tokens , with ; verification commitment events receive no KL penalty. Commitment probabilities follow the controller-induced distribution described after Eq. (10). For , the verification event records a global chunk index or 0, conditioned on . This is one verification event per window, marginalizing outcomes after the earliest accepted candidate. An empty candidate set is deterministic and contributes no verification-policy loss. The verification commitment and ordinary memory-update ratios follow Eqs. (10)–(11). Initialization uses to score , and is included among trainable memory-generation tokens. Final answer generation uses the token-level ratio with conditions defined in Stage II; its tokens also contribute to the policy loss and KL regularizer. During replay, we update parameters under the fixed rollout conditions and mask inputs and padding in generation losses. Identical-reward groups have zero policy-advantage contribution, but the KL term remains.
Training Pseudocode
Algorithm 1 details Stage II full-parameter optimization of System 2 with a fixed System 1.
Algorithm 1: Stage II training with a fixed selector
Require: , , initial
Freeze
Fix as a frozen copy of initial System 2
for each training iteration do
Sample question–document pairs
for each pair do
for do
Execute the workflow with
Store inputs, events, behavior probabilities, and
Compute advantages using Eq. (8)
Zero gradients; replay each event under current
Form all event ratios from § 3.3.2
Average clipped event losses per trajectory
Add generated-token KL with
Backpropagate Eq. (9); clip gradients
Update all parameters ; synchronize the rollout policy
Discard rollouts; validate and save on schedule
Stage III: Joint Optimization of Selection and Consolidation
Complete trajectory distribution. For a legal controller trajectory, let denote the recorded commitment outcome. The selection policy, commitment distribution, and System 2 generation processes jointly induce
Products include only actual rounds and generated tokens; without a commitment, .
Verification enters through in the commitment probability from the distribution described after Eq. (10), with no additional factor. Thus is the distribution induced by the complete workflow, not a separate policy.
Dataset Construction
For Stage III, we reuse the Stage II dataset in Eq. (15), with . The training set retains the 32,768 examples, and checkpoint selection uses the same separate 128-question validation set as Stage II. The 128 questions in MemAgent’s released development set remain reserved for final testing. No extra supervised action labels, reference memories, or acceptance-derived correctness labels are introduced. The change is online trajectory generation: both current policies produce the selections, verification outcomes, intermediate memories, and answers.
Reward Function
Both policies reuse the Stage II final-answer reward in Eq. (16). The group-relative advantage follows Eq. (8); a single trajectory’s advantage is assigned to selection, verification, memory-generation, and answer events. Accepting a candidate is not an independent correctness reward, and a Skip decision is not omitted merely because it avoids a large-model generation call.
Training Configuration
For the full configuration, System 1 uses Qwen3.5-2B and continues training the LoRA adapters from the selected Stage I checkpoint. System 2 loads the selected Qwen2.5-7B-Instruct checkpoint from full-parameter Stage II training and adds new LoRA adapters. Both backbones remain frozen; optimization updates only the adapter parameters within and . The two systems use separate AdamW optimizers with independent optimizer states and synchronized behavior snapshots . Optimizer and scheduler states are reset at the start of Stage III, while checkpoint weights are retained. Dropout is disabled during both rollout and policy replay. Table A2 summarizes the configuration.
| Setting | System 1: selector | System 2: verifier / memory updater |
| Backbone | Qwen3.5-2B | Qwen2.5-7B-Instruct |
| Trainable parameters | Existing LoRA adapters; backbone frozen | New LoRA adapters; backbone frozen |
| LoRA rank / scaling () | 32 / 64 | 32 / 32 |
| LoRA target modules | Same as Stage I | All-linear |
| Dropout during joint RL | Disabled in rollout and policy replay | Disabled in rollout and policy replay |
| Training budget | 5 dataset epochs | |
| Global rollout batch | 128 questions; rollouts per question | |
| Optimization minibatch | 8 questions, retaining all 16 rollouts per question | |
| PPO passes | 1 per rollout batch | |
| Training sampling | temperature = 1.0, top- = 1.0 | |
| Validation sampling | , temperature = 1.0, top- = 0.7 | |
| Policy-ratio clip | 0.2 | |
| Optimizer | AdamW; independent state | AdamW; independent state |
| Peak learning rate | ||
| Adam () | (0.9, 0.999, ) | (0.9, 0.999, ) |
| Weight decay | 0.01 | 0.01 |
| Maximum gradient norm | 1.0; clipped separately | 1.0; clipped separately |
| Learning-rate schedule | 20 optimizer steps of warm-up, then constant | 20 optimizer steps of warm-up, then constant |
| Optimizer / scheduler initialization | Reset at Stage III start | Reset at Stage III start |
| Policy-gradient sources | Selection and joint verification commitments | Verification commitments; initialization, memory-update, and answer tokens |
| Generation KL coefficient | Not applicable | |
| Generation reference policy | Not applicable | Same frozen Qwen2.5-7B-Instruct reference as Stage II |
Table A2. Stage III joint LoRA training configuration.
Selection events update only System 1 adapters using the ratio in Eq. (13), with the recorded action and conditions . Verification commitments update both systems’ adapters through
where is the recorded committed chunk index or 0. The full conditions are the recorded query, window, candidate indices, and memory. The commitment probabilities follow the distribution described after Eq. (10); they retain dependence on both systems through the acceptance ratio. Behavior probabilities are fixed. Candidate sets, chunk indices, action labels, and memory strings are replayed as conditioning data, without regenerating them or differentiating through discrete text. Ordinary memory-update tokens use the System 2 ratio in Eq. (11); initialization and final answer generation use the substitutions and full conditions defined in Stage II. Their policy loss and KL regularizer update only System 2 adapters. The complete trajectory factors follow Eq. (17), with no additional verifier-policy factor.
Let contain all four event types. The clipped loss averages events within each trajectory, as in Stage II. Generation-only KL retains and the same frozen reference policy as Stage II: a frozen copy of the initial Qwen2.5-7B-Instruct model. This reference remains fixed across both RL stages. Selection and verification events receive no KL term. Both adapters’ gradients are computed before either optimizer is stepped, and both rollout policies are synchronized before collecting a fresh group.
Training Pseudocode
Algorithm 2 summarizes joint policy optimization.
Algorithm 2: Stage III joint policy optimization
Require: ; Stage II reference
Load both checkpoints; freeze both backbones
Resume System 1 LoRA; add new System 2 LoRA
Retain the frozen reference; disable dropout
Initialize separate AdamW optimizers and schedules
for each joint-training iteration do
Snapshot
Sample question–document pairs
for each pair do
Collect fresh complete rollouts using the snapshots
Record every selection and each nonempty-window verification
Record initialization, memory, and answer tokens
Compute rewards using Eq. (16) and advantages using Eq. (8)
for each 8-question minibatch (all rollouts/question) do
Zero both adapters’ gradients
Replay actions under and tokens under
Score commitments using the distribution after Eq. (10)
Average clipped losses over per trajectory
18: Add System 2 generated-token KL with
19: Backpropagate before stepping either optimizer
20: Clip adapter gradients separately; update both adapters
21: Synchronize both rollout models; discard old rollouts
22: Validate and save the current pair on schedule
Complete MemDuet Inference
Algorithm 3: Complete MemDuet inference
Require: Query , nonempty ordered chunks , window width
Ensure: Final answer
No previous memory
Generate under
;
while do
; fix memory
In parallel, obtain System 1 scores for each ,
Independently sample for
For , obtain System 2 scores for the same
For , set
Record independent for
if no satisfies , then
;
\quad all skipped or rejected
else
Generate under
Discard every later result computed from
Generate autoregressively under
return
Training-Free Transfer to Proprietary APIs
Models and API versions. For DeepSeek, we use DeepSeek-V4.1-Flash as System 1 and DeepSeek-V4-Pro-0813 as System 2. For OpenAI, we use GPT-5.6 Luna as System 1 and GPT-5.6 Sol as System 2. Transfer uses task prompts and workflow control without additional SFT or GRPO.
Differences from the full MemDuet method. The API adaptation differs primarily in training and acceptance. The full method learns the two systems through the three-stage training in § 3.3. Here, we instead use off-the-shelf proprietary models with fixed parameters, adapting their roles through task prompts and an external controller rather than additional SFT or GRPO.
In the full method, the UPDATE probabilities of System 1 and System 2 determine the acceptance probability in Eq. (4), followed by independent random acceptance tests. In the API adaptation, we do not request action log-probabilities. Instead, generated labels drive the decisions: System 1’s skips a chunk, while forwards it to System 2; System 2’s rejects the candidate, while directly accepts it. We therefore replace probability-ratio-based speculative acceptance with text verification, without computing the acceptance ratio or drawing separate acceptance random variables.
Request settings. All calls to both systems use thinking-disabled mode. The output caps are 8,192 tokens for System 1 and 32,768 for System 2. Contexts are split into 5,000-token chunks, with a four-chunk lookahead and a 1,024-token memory budget.
API prices. Table A3 lists prices in USD per million tokens. The DeepSeek entries are off-peak rates; peak rates are twice these values.
| Model | Input | Cached input | Output |
| DeepSeek-V4.1-Flash | 0.15 | 0.003 | 0.60 |
| DeepSeek-V4-Pro-0813 | 0.66 | 0.022 | 1.98 |
| GPT-5.6 Luna | 0.20 | 0.020 | 1.20 |
| GPT-5.6 Sol | 4.00 | 0.400 | 20.00 |
Table A3. API prices in USD per million tokens. DeepSeek prices are off-peak rates.
Complete Experimental Results
RULER-HQA Results
Table A4 presents the complete RULER-HQA results across different context lengths, reporting answer accuracy, time speedup, and relative output-token counts for the compared methods. Both efficiency metrics use MemAgent-7B as the baseline.
System 1 Backbone Comparison
Table A5 gives the complete per-length results underlying Table 4. Accuracy, Speed, and Tokens equally weight the ten context lengths from 7K to 3.5M tokens. For each length, Speed is the ratio of mean RL-MemAgent latency to mean MemDuet latency, and Tokens is the ratio of mean MemDuet output-token count to mean RL-MemAgent output-token count.
| System 1 | F1 (%) ↑ | Acc. (%) ↑ | Speed ↑ | Tokens ↓ |
| Qwen2.5-0.5B | 78.49 | 80.08 | 5.69× | .2690× |
| Qwen2.5-1.5B | 81.68 | 82.89 | 7.28× | .2500× |
| Qwen3.5-0.8B | 86.05 | 82.03 | 14.06× | .2149× |
| Qwen3.5-2B | 84.47 | 83.36 | 14.26× | .2336× |
Table 4. System 1 on RULER-HQA (7K–3.5M tokens). Acc., Speed, and Tokens are ten-length means; the latter two use per-length ratios to RL-MemAgent. F1 measures Update selection. Appendix C.2 gives full results and timing normalization.
| System 1 | 7K | 14K | 28K | 56K | 112K | 224K | 448K | 896K | 1.75M | 3.5M | Mean |
| Acc. (%) ↑ | |||||||||||
| Qwen2.5-0.5B | 86.72 | 77.34 | 88.28 | 78.13 | 79.69 | 83.59 | 77.34 | 77.34 | 75.78 | 76.56 | 80.08 |
| Qwen2.5-1.5B | 86.72 | 84.38 | 89.06 | 82.03 | 85.16 | 82.81 | 82.03 | 79.69 | 78.91 | 78.13 | 82.89 |
| Qwen3.5-0.8B | 87.50 | 82.03 | 89.06 | 82.03 | 80.47 | 81.25 | 77.34 | 83.59 | 78.91 | 78.13 | 82.03 |
| Qwen3.5-2B | 87.50 | 83.59 | 89.06 | 79.69 | 87.50 | 85.94 | 82.81 | 82.03 | 79.69 | 75.78 | 83.36 |
| Speed ↑ | |||||||||||
| Qwen2.5-0.5B | 0.826× | 1.301× | 1.458× | 2.325× | 2.911× | 3.620× | 5.926× | 8.243× | 11.186× | 19.139× | 5.69× |
| Qwen2.5-1.5B | 0.791× | 1.126× | 1.477× | 2.822× | 3.749× | 5.370× | 7.977× | 11.167× | 17.636× | 20.644× | 7.28× |
| Qwen3.5-0.8B | 0.791× | 1.196× | 1.642× | 3.697× | 6.812× | 10.182× | 15.961× | 22.570× | 34.407× | 43.321× | 14.06× |
| Qwen3.5-2B | 0.983× | 1.445× | 1.588× | 3.541× | 5.885× | 9.885× | 11.913× | 18.688× | 39.085× | 49.613× | 14.26× |
| Tokens ↓ | |||||||||||
| Qwen2.5-0.5B | .8645× | .5181× | .4256× | .2554× | .2028× | .1647× | .1001× | .0730× | .0557× | .0304× | .2690× |
| Qwen2.5-1.5B | .9012× | .5840× | .4045× | .1961× | .1452× | .1008× | .0678× | .0480× | .0287× | .0240× | .2500× |
| Qwen3.5-0.8B | .8963× | .5514× | .3658× | .1500× | .0736× | .0480× | .0283× | .0186× | .0100× | .0072× | .2149× |
| Qwen3.5-2B | .9050× | .5659× | .3671× | .2012× | .1154× | .0607× | .0543× | .0460× | .0117× | .0086× | .2336× |
Table A5. Complete System 1 backbone results on RULER-HQA (7K–3.5M tokens). Mean is the arithmetic average of the ten per-length values. Speed and Tokens are ratios relative to RL-MemAgent.
Speculative Acceptance
This section distinguishes the coverage supplied by a high-recall selector from the target-distribution guarantee of speculative decoding.
Difference from Distribution-Preserving Speculative Decoding
Standard speculative decoding combines acceptance with residual resampling after rejection to preserve the target model’s sampling distribution, regardless of draft quality [5] (Leviathan et al. 2023). This is distributional equivalence, not a guarantee that the target answer is correct. MemDuet instead speculates over memory-update actions. A System 1 SKIP bypasses System 2, and a rejected UPDATE does not trigger residual resampling. Thus Eq. (4) alone does not preserve System 2’s standalone action or answer distribution. Write and for the System 1 and System 2 UPDATE probabilities, respectively, at the same . With sampled proposals, the probability of selecting and accepting a chunk is . For and , it is 0.4, below the verifier’s standalone UPDATE probability 0.6.
Quantified Coverage under High Recall
On a specified distribution of live, memory-conditioned states, let denote a reference UPDATE label. Define selector recall and the mean acceptance probability . If and , the independent uniform acceptance test gives
A sufficient condition for the acceptance bound is on selected reference-positive states: for , . The verifier cannot recover a candidate omitted by System 1. As a hypothetical example, recall 0.99 and mean acceptance 0.99 yield reference-positive action coverage 0.9801, not answer accuracy 0.9801.
If these bounds hold conditional on the live prefix at each of at most reference-positive decisions
per question, a union bound gives
where is the probability that at least one such decision is skipped or rejected. No independence between decisions is required. With acceptance probability one on positives, this reduces to . Here, live decisions exclude stale results discarded after an earlier rewrite. A held-out aggregate recall does not by itself establish the required conditional bounds on reached states.
Prompt Templates
The following prompts are used in MemDuet’s training and inference, covering candidate selection and verification, memory initialization and updating, and final answer generation. The placeholders {prompt}, {memory}, and {chunk} denote the question, current memory, and input document chunk, respectively.
Candidate Selection
Use: System 1 inference and memory-conditioned action supervision. Inputs: question, current memory, and one raw chunk. Output: one token, k (SKIP) or u (UPDATE), without a memory draft or explanation. Parallel calls substitute the same committed memory. For before/after supervised pairs, the memory placeholder changes and the target action changes; the task text need not be duplicated.
You are a memory update gate.
Given a question, the current
memory, and a new text section,
decide whether the section contains
new task-relevant information
that requires updating the memory.
Output exactly one token:
k = keep the current memory unchanged
u = update the memory
<problem>
{prompt}
</problem>
<memory>
{memory}
</memory>
<section>
{chunk}
</section>
Decision:
Candidate Verification
Use: System 2 verifies whether a selected chunk warrants a memory update before memory generation. Inputs and task text are identical to Appendix § 10.§ 1, with System 2’s own chat template. Output interface: first-position k/u and both action scores, consumed by the controller in Appendix § 7.§ 4 for open-weight inference. The proprietary API adaptation instead parses generated k/u labels without action scores, as described in Appendix B.5. There is no separate natural-language accept/reject prompt or small-model memory draft.
Memory Initialization and Updating
Use: first-chunk initialization and committed rewrites. Inputs: question, raw chunk, and previous memory, initialized with No previous memory. Output: complete replacement memory, not an append-only patch. The local MemAgent full-update baseline shares this template; controller protocol wrappers are not extra model instructions.
Complete memory-initialization/update task text
You are presented with a problem, a
section of an article that may
contain the answer to the
problem, and a previous memory.
Please read the provided section
carefully and update the memory
with the new information that
helps to answer the problem. Be
sure to retain all relevant
details from the previous memory
while adding any new, useful
information.
<problem>
{prompt}
</problem>
<memory>
{memory}
</memory>
<section>
{chunk}
</section>
Updated memory:
Final Answer Generation
Use: answering after document processing. Inputs: question and final committed memory, without raw documents or discarded candidates. Output: the answer in \boxed{}, as below.
Complete final-answer task text
You are presented with a problem and
a previous memory. Please answer
the problem based on the
previous memory and put the
answer in \boxed{}.
<problem>
{prompt}
</problem>
<memory>
{memory}
</memory>
Your answer:
<memory>
{memory}
</memory>
Your answer:
LongBench v2 Multiple-Choice Prompt
For LongBench v2, the {prompt} placeholder in the preceding templates contains the question, all four options, and the letter-answer instruction shown in the <problem> block below. Candidate selection, verification, and memory updates use this same question text. The final-answer template combines it with the final memory and asks for an option letter in \boxed{}. Option accuracy is defined in Appendix A.3.
Complete LongBench v2 final-answer task text
You are presented with a problem and
a previous memory. Please answer
the problem based on the
previous memory and put the
answer in \boxed{}.
<problem>
What is the correct answer to this
question: {question}
Choices:
(A) {choice_A}
(B) {choice_B}
(C) {choice_C}
(D) {choice_D}
Answer with the letter A, B, C, or D.
</problem>
<memory>
{memory}
</memory>
Your answer:
Case Studies
We present three successful trajectories and one failure. Evidence and memory excerpts below are condensed from recorded states, not verbatim model transcripts. Unshown chunks and intermediate rounds are explicitly omitted. Here and denote the System 1 and System 2 UPDATE probabilities, respectively; is the acceptance probability and is the sampled uniform variate.
Successful Reasoning and Memory Evolution
Successful case: completing a two-hop evidence chain
Question: When was the British author who wrote the novel on which Here We Go Round the Mulberry Bush was based born?
Sample: eval200, ID 112; six chunks. Key evidence: Document 109 identifies the novelist as Hunter Davies; Document 177 gives his birth date, 7 January 1936.
Initialization and current memory
Chunk produces the initial memory: Clive Donner is mentioned as the film director, while the novelist’s identity and birth date remain unresolved. The mandatory initialization is a System 2 memory call.
Chunk / Document 109
Evidence: The film is based on a novel by Hunter Davies.
Current memory: The target author’s identity is unresolved.
System 1: Select UPDATE, .
System 2: , , ; accept.
Updated memory: Novelist = Hunter Davies; birth date unresolved.
Chunk / Document 177
Evidence: Edward Hunter Davies was born on 7 January 1936.
Current memory: Hunter Davies is the novelist.
System 1: Reevaluate after the commit and select UPDATE, .
System 2: , , ; accept.
Updated memory: Hunter Davies is the novelist and was born on 7 January 1936.
Remaining processing and answer
The original prediction under the first snapshot was provisionally accepted but discarded after the earlier commit; it did not generate a memory. Direct SKIP decisions at , , and do not call the verifier. Distractor text and other window details are omitted.
Final answer: 7 January 1936 (matches the reference).
Memory generations: three, including initialization.
The trajectory joins the film–novelist fact in with the birth-date fact in . The small model’s output is a chunk-selection action; all displayed memories were generated by System 2. Provisional acceptance and commitment in document order are separate events.
Successful case: changing selection after a memory update
Question: According to the 2001 census, what was the population of the city in which Kirton End is located?
Sample: eval200, ID 58; six chunks. Key evidence:
Document 81 places Kirton End in the Boston district; Document 96 gives Boston town’s 2001 population as 35,124.
Initialization and current memory
Document 10 in describes Kirton, Suffolk, with a 2011 population of 1,146. The initial memory retains that information but explicitly leaves the requested city’s 2001 population unresolved.
Chunk / Documents 81 and 96
Evidence: Kirton End is in the Boston district of Lincolnshire. Boston town had 35,124 residents in 2001, whereas the borough’s 2015 population was 66,900.
Current memory: The location–population chain is incomplete.
System 1: Select UPDATE, .
System 2: , , ; accept.
Updated memory: Links Kirton End to Boston and records 35,124 as the town’s population for the requested census year.
Same chunk , before and after commitment
Under the earlier memory snapshot, is selected as UPDATE (, , ). This provisional decision is discarded when the earlier update is committed.
Under the new memory, System 1 reevaluates as SKIP (); System 2 is not called for this decision and the memory remains unchanged. The chunk text is unchanged; its full text is omitted.
Remaining processing and answer
Chunks , , and are also skipped in their effective decisions. Other window details are omitted.
Final answer: 35,124 (matches the reference).
Memory generations: two, at and .
The committed memory distinguishes the town from the borough and the 2001 census from later population estimates. The same changes from UPDATE to SKIP after that rewrite, directly illustrating memory-conditioned selection and the invalidation of decisions made under an earlier state. This is an observed trajectory, not a counterfactual intervention.
Successful case: maintaining sufficient memory
Question: Hayden is a singer-songwriter from Canada, but where does Buck-Tick hail from?
Sample: eval1800, ID 31; 23 chunks. Key evidence: Document 1 states that Buck-Tick was formed in Fujioka, Gunma, in 1983.
Initialization and current memory
Chunk contains Document 1. System 2 initializes the memory with the band’s origin, Fujioka, Gunma, already supplying the requested answer.
Later candidate at
Current memory: Buck-Tick hails from Fujioka, Gunma.
System 1: Select UPDATE, . System 2: , , ; reject because . Memory after verification: Unchanged; no memory rewrite is generated. The candidate’s full text is omitted.
Other chunks and final answer
The other 21 chunks after initialization receive direct SKIP decisions and do not call System 2. The final memory is identical to the initial memory.
Final answer: Fujioka, Gunma (matches the reference).
Memory generations: one, for initialization only.
This case shows a different successful path: the necessary evidence is available immediately, and later processing preserves it without further memory generation. The rejection is a sampled acceptance-rule outcome, not evidence that its text is factually false or necessarily irrelevant. The generation count describes this trajectory; it is not a latency measurement or a general efficiency estimate.
Failure Analysis
Failure case: confusing the director with the novelist
Question: When was the author of the novel behind Here We Go Round the Mulberry Bush born?
Sample: eval800, ID 112; 23 chunks. Key evidence: Document 187 gives director Clive Donner’s birth date; Document 366 gives Hunter Davies’s birth date; Document 751 identifies Davies as the novelist.
Current memory before
The initial memory does not identify the target novelist and contains unresolved, partly irrelevant biographical information. Intervening uncommitted candidates and distractor text are omitted.
Chunk / Document 187
Evidence: Clive Donner, a film director, was born on 21 January 1926.
System 1: Select UPDATE, .
System 2: , , ; accept.
Updated memory: Clive Donner is treated as the novel’s author, and his birth date is attached to the target. A later rewrite retains this incorrect role binding; its full text is omitted.
Earlier supporting attribute / Document 366
Evidence: Hunter Davies was born on 7 January 1936.
Recorded outcome: This date never appears in a committed memory. The trace does not independently label which gate decision caused this omission, so it is not counted as a verified false SKIP.
Chunk / Document 751
Current memory: The incorrect Donner–author association and date persist.
Evidence: The novelist is Hunter Davies.
System 1: Select UPDATE, .
System 2: , , ; accept.
Updated memory: Identifies Davies but lacks his birth date, retains Donner’s date, and adds an unsupported ordering of their ages.
Final answer
Prediction: 21 January 1926.
Reference: 7 January 1936.
Memory generations: four, including initialization. Other rounds are omitted.
References
- [1]Mariam Aly and Nicholas B. Turk-Browne. 2016. Attention promotes episodic encoding by stabilizing hippocampal representations. Proceedings of the National Academy of Sciences, 113(4):E420–E429.DOI
- [2]Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. 2024. LongBench: A bilingual, multi-task benchmark for long context understanding. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3119–3137.
- [3]Yushi Bai, Shangqing Tu, Jiajie Zhang, Hao Peng, Xiaozhi Wang, Xin Lv, Shulin Cao, Jiazhen Xu, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. 2025. LongBench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3639–3664.arxiv.org/abs/2412.15204
- [4]Iz Beltagy, Matthew E. Peters, and Arman Cohan. 2020. Longformer: The long-document transformer. Preprint, arXiv:2004.05150.arxiv.org/abs/2004.05150
- [5]Charlie Chen, Sebastian Borgeaud, Geoffrey Irving, Jean-Baptiste Lespiau, Laurent Sifre, and John Jumper. 2023a. Accelerating large language model decoding with speculative sampling. Preprint, arXiv:2302.01318.arxiv.org/abs/2302.01318
- [6]Shouyuan Chen, Sherman Wong, Liangjian Chen, and Yuandong Tian. 2023b. Extending context window of large language models via positional interpolation. Preprint, arXiv:2306.15595.arxiv.org/abs/2306.15595
- [7]Zhuoen Chen, Dongfang Li, Meishan Zhang, Baotian Hu, and Min Zhang. 2026. Dynamic long context reasoning over compressed memory via end-to-end reinforcement learning. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8064–8083.


