We have proposed a biologically realistic model for a simple form of episodic memory using barcodes. Our work is related to previous auto-associative memory models of the hippocampus such as Hopfield networks (Gardner-Medwin, 1976; McNaughton and Morris, 1987; Marr et al., 1991; Alvarez and Squire, 1994; Tsodyks, 1999), but diverges in a few critical areas. Building on ideas from hippocampal indexing theory (Teyler and DiScenna, 1986; Teyler and Rudy, 2007), and following the discovery of barcodes (Chettih et al., 2024), we show how recurrent computation can implement memory indexing. Our model is further noteworthy in randomly intermixing representations of memory index and memory content in the activity of single neurons, matching experimental findings. This intermixing implies that single neurons cannot be definitively identified as ‘place cells’ or ‘barcode cells’, despite clear differentiation between the place code and the barcode at the population level. A further innovation of our model is the ability to control the trade-off between pattern completion and pattern separation during memory recall, by simply turning up or down the strength of a memory content input (‘search strength’ in Figure 4). In this work, we considered only place and a single ‘seed’ input, but it is straightforward to generalize this to naturalistic cases where different food types are stored, or to memory contents beyond cached food. In principle, our approach would allow independent control of search strength for each potential element of memory content.
To generate barcodes during caching and retrieval without affecting place activity during visits, our model changes recurrent strength in an RNN between different behaviors. A major question is how the brain could implement such gain changes in recurrence. One possible mechanism is a change in recurrent inhibition, which is consistent with dramatic changes in the activity of inhibitory neurons observed during caching (Chettih et al., 2024). Neuromodulators like acetylcholine have been shown to bidirectionally modulate different inhibitory neuron subtypes (Xiang et al., 1998; Lovett-Barron et al., 2014), and proposed to control the recurrent gain of hippocampal processing (Hasselmo, 1999; Hasselmo, 2006). However, our model uses generic RNN units, and it is unclear precisely how units in the model should be mapped to real excitatory and inhibitory hippocampal neurons in the brain. Our model predicts a state change in hippocampal activity during memory formation and recall, allowing recurrent computation to generate or reactivate memory barcodes. Detailed modeling of realistic E-I networks is needed to further clarify its specific biological implementation.
Alternatively, other mechanisms may be involved in generating barcodes. We demonstrated that conventional feed-forward sparsification (Babadi and Sompolinsky, 2014; Xie et al., 2023) was highly inefficient, but more specialized computations may improve this (Földiák, 1990; Olshausen and Field, 1996; Sacouto and Wichert, 2023; Muscinelli et al., 2023). Another possibility is that barcodes are generated in a separate recurrent network upstream of the recurrent network where memories are stored. In this two-network scenario, the downstream network receives both spatial tuning and barcodes as inputs. This would not obviate the need for modulating recurrent strength in the downstream network to switch between input-driven modes and attractor dynamics. We suspect separating barcode generation and memory storage in separate networks would not fundamentally affect our conclusions.
We showed that barcodes allow for precise memory retrieval despite the presence of other correlated memories. This sharpened memory retrieval is similar to mechanisms used in key-value memory structures that are often embedded in machine learning architectures (Graves et al., 2014; Graves et al., 2016; Sukhbaatar et al., 2015; Le et al., 2019; Banino et al., 2020). At their simplest, these key-value memory structures consist of memory slots. Each slot consists of a memory that can be addressed via ‘keys’ such that their stored memory is returned as ‘values’. In machine learning, key-value memory has been connected to the dot-product attention mechanism used in transformers (Krotov and Hopfield, 2016; Ramsauer et al., 2020). Interestingly, prior theoretical work has suggested neural implementations for both key-value memory and attention mechanisms, arguing for their usefulness in neural systems such as long-term memory (Kanerva, 1988; Tyulmankov et al., 2021; Bricken and Pehlevan, 2021; Whittington et al., 2021; Kozachkov et al., 2023; Krotov and Hopfield, 2020; Gershman et al., 2025). In this framework, the address where a memory is stored (the key) may be optimized independently of the value or content of the memory. In our model, barcodes improve memory performance by providing a content-independent scaffold that binds to memory content, preventing memories with overlapping content from blurring together. Thus, barcodes can be considered as a change in memory address, and our model suggests important connections between recurrent neural activity and key generation mechanisms. However, we note that barcodes should not be literally equated with keys in key-value systems as our model’s memory is ‘content-addressable’—it can be queried by place and seed inputs.
Episodic memory is often studied at a behavioral level in humans performing free or cued recall of remembered word lists (Kahana, 2020; Naim et al., 2020). Temporal context models (TCM) of episodic memory have been highly successful in accounting for the sequential order effects observed reliably in this experimental setting (Howard and Kahana, 2002; Howard et al., 2005; Sederberg et al., 2008), and the idea of a ‘context vector’ in TCM is closely related to use of barcodes as a memory index in our model. However, experiments have shown that chickadee cache retrieval does not exhibit temporal order effects (Applegate and Aronov, 2022), suggesting that caches at different locations are likely not linked by a temporal context as in TCM. Interestingly, caches at the same location were found to have distinct but correlated barcodes (Chettih et al., 2024), which could be related to caches sharing a ‘spatial context’ analogous to TCM. In the present study, we did not consider memory for different caches at the same location, since it requires a mechanism for forgetting or overwriting cache memory following retrieval. Although such ‘directed forgetting’ is observed in chickadee behavior (Sherry, 1984), there is no definitive solution for Hopfield-like networks, and it is thus beyond the scope of our current work.
Our hippocampal model focused on the implementation of episodic memory. Importantly, the proposed barcode mechanism is capable of coexisting with other hippocampal functions, such as predictive coding as formalized by the successor representation (SR; Stachenfeld et al., 2017). Surprisingly, we found that a hybrid network can switch between SR-generating and barcode-generating modes of operation by adjusting the gain of recurrent connectivity. Further work is needed to characterize the general conditions under which barcode and SR functions do or do not mutually interfere. It is also unclear if these are separate functions of the same circuit, or if they are complementary in certain scenarios (Schapiro et al., 2017; Barron et al., 2020). For example, we found that the SR could bias barcode-mediated memory recall. In a complex environment, the Euclidean distance between two points may not correspond to its proximity in a practical sense, which the SR better captures. In this case, experience-dependent biases in memory recall can be functionally advantageous (Dasgupta and Gershman, 2021) and would be consistent with behavioral results (Kahana, 1996; Talmi and Moscovitch, 2004).