Tongji University's InfoMem Teaches AI to Remember What Actually Matters
InfoMem introduces an information-theoretic reward that teaches LLMs to build better memory summaries while reading long documents chunk by chunk
Takeaways
- InfoMem introduces an answer-conditioned information-gain reward for training chunk-wise long-context memory agents, measuring how much a model's final memory increases the log-likelihood of the correct answer.
- The reward is applied only to successful rollouts, normalized within each group, and conditioned on the ground-truth answer rather than the query, each choice validated by ablation.
- On four out-of-distribution benchmarks, InfoMem outperforms both outcome-only GRPO and ReMemR1, and is the only method that improves over the base model on all four tasks.
- A synthetic diagnostic using hallucinated SQuAD contexts shows
r_gainachieves MRR 0.977 and SNR 2.96, nearly 5x the signal stability of embedding-based alternatives. - Outcome-only GRPO degrades on multi-needle retrieval (MRCR-8needle) from 0.26 to 0.06; InfoMem recovers to 0.28, showing the memory-specific reward prevents retrieval collapse.
- Code is publicly available; the method is a drop-in reward shaping module for any GRPO-based chunk-wise memory agent.
Getting an LLM to read a 200-document corpus and remember the right things is harder than it sounds. The model has to decide, chunk by chunk, what to keep in a fixed-size memory buffer and what to discard. Train it with only a final-answer reward and it learns to get answers right, but it has no signal for why a particular memory was good or bad. A new paper from Tongji University and Shanghai AI Laboratory introduces InfoMem, a reward mechanism that directly grades the quality of the memory a model builds, not just whether it gets the final answer correct.
The memory problem hiding inside long-context RL
The chunk-wise memory agent paradigm works like this: split a long document into chunks, have the model read each one and update a compact text-based memory, then generate a final answer from that accumulated memory alone. Chunk-wise memory agents address the long-context challenge by sequentially reading document chunks, updating a compact memory, and generating the final answer from the accumulated memory. It is a clean, scalable design that sidesteps the quadratic cost of full-context attention.
The training problem, however, is subtle. Training these agents using reinforcement learning typically relies on a single reward signal, such as the correctness of the final answer. This sparse reward, provided only at the end of the reasoning process, offers limited guidance for the long sequence of intermediate memory updates, leading to inefficient optimization and suboptimal memory management strategies.
The gap is especially sharp when you look at successful rollouts. Multiple attempts may all produce the correct answer, so they all get the same reward of 1. But one memory might contain only the critical supporting sentence, while another is bloated with distractors. The binary outcome reward cannot tell the difference. Existing RL-based chunk-wise agents either rely on sparse final-answer rewards or use lexical intermediate rewards for memory and retrieval actions. These signals supervise task success or local overlap, but do not directly evaluate whether the final memory supports the ground-truth answer.
Measuring memory quality with information gain
InfoMem reframes the question: how much does the final memory actually help the model predict the correct answer? The answer is measured with a simple log-likelihood comparison. The model scores the ground-truth answer twice, once with the final memory in context and once without. The difference in per-token average log-probability is the information-gain reward.

Formally, if the model assigns probability P(y* | x, M) to the ground-truth answer given memory M, and P(y* | x, ∅) without any memory, the reward is:
r_gain(x, M, y*) = (1/|y*|) * log P(y* | x, M)
- (1/|y*|) * log P(y* | x, ∅)
Higher values mean the memory genuinely increases the model's confidence in the right answer. This is computed under teacher forcing, meaning the ground-truth tokens are fed one by one and the model scores each one, rather than generating freely. No extra model is needed; the training model scores itself.
Three design choices that make it work
The raw information-gain signal is useful but unstable on its own. The paper identifies three properties that effective final-memory rewards must have:
- Success-side only. InfoMem applies the information-gain signal only to successful trajectories and normalizes it before reward composition. Applying it to failed rollouts is counterproductive: a wrong answer means the memory was probably built around incorrect evidence, so the gain signal becomes noisy and misleading. Ablations show that applying the reward to failed trajectories causes training to collapse mid-way.
- Pre-composition normalization. Raw log-likelihood gains vary wildly across questions. Easy questions already have high answer probability without memory, so the gain is small. Hard questions can produce large gains. Mixing these raw values with a binary outcome reward creates severe scale imbalance. InfoMem z-scores the gain values within each rollout group's successful subset before adding them to the outcome reward.
- Answer conditioning, not query conditioning. An intuitive alternative is to reward memories that make the query easier to predict from memory. The paper tests this variant (called QueryPMI) and finds it backfires: the model learns to copy the query verbatim into the memory, which trivially increases query likelihood without preserving any answer-supporting evidence. Analyses show that effective final-memory rewards should operate on successful trajectories, be normalized before reward composition, and be conditioned on the answer rather than the query.

Does information gain actually measure what we think it does?
Before using it as a training reward, the authors run a diagnostic to check whether r_gain can distinguish genuinely helpful context from plausible-sounding but factually wrong context. They take SQuAD question-answer pairs, generate two hallucinated contexts per question using Gemini 3 Flash (contexts that look topically similar but have the key facts swapped out), and ask: does the score rank the real context first?
The results are striking. InfoMem's r_gain score achieves the highest MRR and Z-score SNR among all compared scores. Embedding similarity (BGE-M3, E5, Qwen3-Embedding) achieves MRR around 0.72 with SNR around 0.32. Attention-based scores do better on ranking but still lag far behind. The information-gain score hits MRR 0.977 and SNR 2.960, nearly 5x the signal-to-noise ratio of the next best method. This means the reward signal is not just accurate but also stable across samples, which matters for RL training.
Benchmark results
Under the same GRPO framework and training budget, InfoMem improves long-context memory-agent performance over comparable memory-agent RL baselines. The base model is Qwen2.5-1.5B-Instruct, trained on 512 examples from RULER-HotpotQA (a long-context QA dataset where each example contains 200 documents), for 120 steps using 16 NVIDIA H20 GPUs at roughly 440 GPU-hours per run.
Evaluation covers four out-of-distribution benchmarks:
- MRCR-8needle: multi-needle retrieval across contexts ranging from 4K to 1M tokens
- RULER synthetic QA: sparse retrieval-style QA at 262K tokens
- CorpusQA: corpus-level evidence aggregation at 128K tokens
- LongMemEval: long-horizon dialogue memory at 115K tokens
| Model | CorpusQA | LongMemEval | MRCR-8needle | RULER QA |
|---|---|---|---|---|
| Qwen2.5-1.5B-Instruct (base) | 14.59 | 5.60 | 0.26 | 13.31 |
| + Outcome-only GRPO | 16.41 | 10.00 | 0.06 | 34.74 |
| + ReMemR1 | 1.52 | 6.20 | 0.09 | 28.92 |
| + InfoMem (ours) | 19.45 | 12.80 | 0.28 | 36.85 |
The outcome-only GRPO baseline actually degrades on MRCR-8needle relative to the base model, falling from 0.26 to 0.06. InfoMem avoids this regression and is the only method that improves across all four benchmarks. The comparison with ReMemR1 (a recent baseline that adds callback retrieval and word-level recall rewards) is particularly notable: ReMemR1 fails to match InfoMem under the sample-aligned evaluation, possibly because its intermediate reward design is primarily based on word-level recall against the ground-truth answer, which may encourage lexical overlap rather than preserving semantically supporting evidence.
What this means in practice
InfoMem is a reward shaping method, not a new architecture or a new base model. It plugs into an existing GRPO training loop and changes only how rollout rewards are computed. The code is publicly available, and the approach is compatible with any chunk-wise memory agent framework that produces an explicit final memory state.
The most immediate use case is any application where an LLM needs to read and summarize long documents while retaining specific facts: legal document review, long-form research synthesis, multi-document question answering, and conversational agents that need to track information across long interaction histories. The key requirement is that the task has a verifiable ground-truth answer, since the reward depends on scoring the correct answer's likelihood.
There are real limitations worth noting. The experiments use a 1.5B parameter model and only 512 training examples, so scaling behavior to larger models and datasets remains an open question. The reward is also defined only at the final memory step; intermediate memory states do not receive direct supervision. And because the reward explicitly reinforces memories that support a target answer, erroneous ground-truth labels or biased source documents could cause the model to amplify misleading evidence rather than correct it.
The deeper contribution here is the framing itself: memory quality is measurable through the lens of information theory, and that measurement can be turned into a training signal without any additional labeled data or auxiliary models. The same principle could extend to other settings where an agent maintains a compressed state across a long horizon and needs to be rewarded for what it remembers, not just what it ultimately produces.