A Theory of Retrieval with Incremental Memory: Causal Influence of Writes and Predictive Gains

Hiroyuki KasaiNeurIPS 2026

TL;DR

When an AI system writes a piece of information to its long-term memory, deleting that entry later isn't as simple as erasing a line on a chalkboard—that single memory may have quietly altered every query and memory write that came after it. This paper introduces TRIM (Theory of Retrieval with Incremental Memory), a mathematical framework that untangles the exact causal ripple effects of omitting a memory write. Surprisingly, even when an old memory's retrieval attention weight shrinks to zero over time, its ghost can still heavily influence current predictions through the later memories it helped shape.

What Problem Does This Paper Address?

Modern AI architectures—like memory-augmented language models, associative memories, and Memory Mosaics—build up an external memory bank incrementally as they process inputs. We already know that raw attention weights don't reliably tell us how important a stored input actually is for a prediction.

If we want to know how much a specific memory write really matters, we have to ask a counterfactual, causal question: What happens to our prediction loss down the road if we had never written that entry in the first place? Because these systems operate in a continuous loop—reading old memories to update states, form new queries, and write new memories—omitting one write creates a butterfly effect. The author tackles two core questions: How does omitting a single write change expected prediction loss later on, and how much predictive value does the entire memory bank actually provide compared to a fixed baseline predictor?

Methods

The author models incremental-memory predictors as a causal Query–Read–Update–Write (Q–R–U–W) loop using an append-only memory (composed of keys, values, and query-independent biases) and bounded softmax retrieval.

To isolate the causal effect of a single write at step $j$, the paper sets up counterfactual trajectories that omit the append at step $j$ while keeping external inputs, randomness, and surviving biases identical:

  • Regenerated-write comparison: Recomputes all subsequent states, queries, and new key–value writes naturally from step $j$ onward.
  • Frozen-write comparison: An auxiliary mathematical stepping stone that omits entry $j$ from memory, rather than regenerating subsequent key–value entries, retaining the original surviving entries.

By algebraically comparing readouts across the original, frozen, and regenerated runs, TRIM achieves an exact three-term decomposition of a single write's influence on squared prediction loss:

  1. Direct-deletion contribution: The immediate impact of missing entry $j$ at retrieval time.
  2. Regeneration contribution: The impact caused by subsequent memory writes having different keys and values because entry $j$ wasn't there when they were created.
  3. Query-change contribution: The impact of looking up the memory bank using a slightly altered evaluation query.

Finally, to measure whole-memory predictive gains even when queries adaptively depend on noisy stored values, the author decomposes readouts into clean "conditional-mean aggregates" and noisy "value residuals," bounding the approximation errors between them.

Datasets

Not discussed in the paper. Because this is a foundational theory paper, there are no standard training or benchmark datasets. Instead, the author illustrates the math using two setups: a controlled synthetic Q–R–U–W model (with a scalar latent variable and conditionally i.i.d. binary observations) and selected sample trajectories from a pretrained Memory Mosaics model.

Key Insights and Ideas

  • Vanishing attention weights don't mean vanishing influence: As memory grows over time ($T$), the direct-deletion effect decays neatly at a rate of $O(T^{-1})$ because softmax weights dilute. However, the regeneration contribution does not automatically vanish! If omitting one early write shifts every subsequent write by a tiny, persistent amount, that early write maintains a permanent grip on future predictions—even as its own attention weight drops to zero.
  • When the butterfly effect does fade: For the regeneration effect to actually die out in long contexts, the average perturbation across all subsequent key–value pairs must shrink toward zero.
  • Components can mask each other: Because single-write influence is signed (omitting a bad write can improve loss; omitting a good one hurts it), direct deletion, regeneration, and query-change effects can point in opposite directions and cancel each other out.
  • More memory isn't guaranteed to help: Neither whole-memory gain nor regenerated-memory gain is guaranteed to be positive, especially at short horizons where residual noise can outweigh the signal.

Key Results

  • Theoretical Persistence vs. Decay: In a constructed mathematical example (Example 4.5), as evaluation time $T \to \infty$, the omitted write's softmax weight drops to $\frac{1}{T-1} \to 0$, yet its regeneration contribution converges to $1$. Conversely, if the number of altered future writes is bounded by a finite constant, regeneration decays at $O(T^{-1})$.
  • Strong Cancellation in Practice: In the synthetic numerical model at $T = 7$, direct-deletion effects across write indices $j = 1, \dots, 6$ stay nearly flat ($0.03036$ to $0.03129$). However, for $j = 1$, regeneration pushes back in the opposite direction, offsetting about 71% of the direct-deletion impact and dropping net influence down to $0.00879$.
  • Negative Early Gains & Conservative Bounds: In the synthetic setup (fixing $j=1$), whole-memory and regenerated-memory gains are both negative at $T=3$ before turning positive at $T=5$ and $T=6$, respectively. Furthermore, the theoretical worst-case bounds are quite loose compared to specific instances: at $T=8$, the actual whole-memory gain approximation error is $0.134$, well beneath the theoretical upper bound of $14.11$.
  • Pretrained Model Echoes: In selected trajectories of a pretrained Memory Mosaics model, indirect readout changes (from regeneration and query shifts) were observed to exceed the direct-deletion effect while partially canceling each other out.

Limitations and Future Work

  • Unresolved Query-Change Decay: While the paper establishes sufficient conditions for direct-deletion and regeneration effects to vanish over long contexts, those conditions do not guarantee that the query-change contribution will decay. Characterizing query-change decay and persistence is left for future work.
  • Architectural Constraints: TRIM assumes an append-only memory, bounded norms (keys, values, queries, states), squared-error loss, and bounded softmax retrieval. Full, real-world architectures (like the complete Memory Mosaics model) are not claimed to satisfy every base assumption out of the box and require separate verification.
  • Next Steps: Beyond tackling query-change dynamics, the author plans to extend TRIM to systems that overwrite or edit existing memory slots rather than just appending, as well as to alternative retrieval mechanisms beyond standard softmax.

Summary updated

BibTeX
@inproceedings{kasai2026theory,
  author = {Hiroyuki Kasai},
  title = {{A Theory of Retrieval with Incremental Memory: Causal Influence of Writes and Predictive Gains}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=CBUP6r6rLR},
}
Figure