cs.AISep 29, 2026

A neural network that maintains and retrieves memories based on context

Authors: Hayoung Song, JeongJun Park, Qihong Lu, Giacomo Vedovati, Monica D. Rosenberg, Zachariah M. Reagh, ShiNung Ching

Organizations: Department of Psychology, University of Texas at Austin · Center for Theoretical and Computational Neuroscience, Washington University in St. Louis · Department of Neuroscience, University of Texas at Austin · Department of Neuroscience, City University of Hong Kong · Department of Electrical and Systems Engineering, Washington University in St. Louis · Department of Psychology, University of Chicago · Neuroscience Institute, University of Chicago · Institute for Mind and Biology, University of Chicago · Department of Psychology, Washington University in St. Louis

Abstract

Every day, people continuously infer situational context and adjust the way they understand and remember the world. Context, signaled by the prefrontal cortex, is known to modulate working memory and episodic memory, but the algorithmic understanding of this modulation remains limited. Here, we train a recurrent neural network (RNN), augmented with an episodic memory buffer, to infer context using Bayesian inference as it continuously makes predictions of upcoming scenes while watching naturalistic movies. When the inferred context modulates the RNN's recurrent connectivity (the basis of working memory) in a low-rank manner, the model's activity patterns best match neural responses in human participants who watched the same movies during fMRI. Context also modulates episodic memory retrieval, such that the model retrieves memories based on not only content similarity but also context similarity. This is implemented as a key-value system with self-attention, designed to additionally encode context and retrieve context-congruent memories. The resulting model not only better resembles human brain representations but also learns to retrieve memories like humans much faster than a model without context modulation. Together, our findings suggest a computational mechanism by which context modulates information maintenance and long-term memory retrieval in naturalistic environments.

Figures & tables

Appendix figures & tables3 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. RaMem: Contextual Reinstatement for Long-term Agentic Memory

    Jun 22, 2026Wei Yang, Bryce Kan, Shixuan Li +5Agentic MemoryLong-Term

  2. Joint sparse coding and temporal dynamics support context reconfiguration

    May 11, 2026Qianqian Shi, Yue Che, Faqiang Liu +6Synaptic PlasticityCatastrophic Forgetting

  3. AnchorMem: Anchored Facts with Associative Contexts for Building Memory in Large Language Models

    Apr 19, 2026Zhanyu Shen, Sijie Cheng, Zhicheng Guo +3Large Language Model Memory