Abstract
Forming an episodic memory requires binding together disparate elements that co-occur in a single experience. One model of this process is that neurons representing different components of a memory bind to an “index” — a subset of neurons unique to that memory. Evidence for this model has recently been found in chickadees, which use hippocampal memory to store and recall locations of cached food. Chickadee hippocampus produces sparse, high-dimensional patterns (“barcodes”) that uniquely specify each caching event. Unexpectedly, the same neurons that participate in barcodes also exhibit conventional place tuning. It is unknown how barcode activity is generated, and what role it plays in memory formation and retrieval. It is also unclear how a memory index (e.g. barcodes) could function in the same neural population that represents memory content (e.g. place). Here, we design a biologically plausible model that generates barcodes and uses them to bind experiential content. Our model generates barcodes from place inputs through the chaotic dynamics of a recurrent neural network and uses Hebbian plasticity to store barcodes as attractor states. The model matches experimental observations that memory indices (barcodes) and content signals (place tuning) are randomly intermixed in the activity of single neurons. We demonstrate that barcodes reduce memory interference between correlated experiences. We also show that place tuning plays a complementary role to barcodes, enabling flexible, contextually-appropriate memory retrieval. Finally, our model is compatible with previous models of the hippocampus as generating a predictive map. Distinct predictive and indexing functions of the network are achieved via an adjustment of global recurrent gain. Our results suggest how the hippocampus may use barcodes to resolve fundamental tensions between memory specificity (pattern separation) and flexible recall (pattern completion) in general memory systems.
1 Introduction
Humans and other animals draw upon memories to shape their behaviors in the world. Memories of specific personal experiences — called episodic memories (Tulving et al., 1972) — are particularly important for livelihood. In animals, episodic-like memory is operationally defined as the binding of the “where”, “what”, and “when” components that comprise a single experience. This information can later be retrieved from memory to affect behavior flexibly, depending on context (Clayton and Dickinson, 1998). The binding of memory contents into a discrete memory is thought to occur in hippocampus. Previous work proposed that hippocampus supports memory by generating an “index”, that is, a signal distinct from the contents of a memory (Teyler and DiScenna, 1986; Teyler and Rudy, 2007). In this scheme, during memory formation, plasticity links the neurons that represent memory contents with the neurons that generate this index. Later reactivation of the index drives recall of the memory contents.
Indexing theory was originally articulated at an abstract level, without reference to particular neural representations(Teyler and DiScenna, 1986). More recently, signatures of index signals were identified in neural activity through experiments in food-caching chickadees (Poecile atricapillus), an influential animal model of episodic memory (Sherry, 1984). Chettih et al. (2024) identified “barcode”-like activity in the chickadee hippocampus during memory formation and suggested that barcodes function as memory indices. Barcodes are sparse, high-dimensional patterns of hippocampal activity that occur transiently during caching. They are unique to each cache and are uncorrelated between cache sites, even for nearby sites with similar place tuning. Barcodes are then reactivated when a bird retrieves the cached item. Chickadee hippocampus also encodes the bird’s location — as expected, given the presence of place cells — as well as the presence of a cached sunflower seed, irrespective of location. Thus, Chettih et al. (2024) found that hippocampal activity contains both putative memory indices (in the form of barcodes) and putative memory content (in the form of place and seed-related activity).
These findings raise several critical questions. How are barcodes generated and associated with place and seed-related activity during caching? How can hippocampal dynamics subsequently recall these same patterns during retrieval? Critically, neurons participate in both barcodes and place codes with near random overlap, in contrast with theoretical models where content and indexing functions occur in separate neurons (Krotov and Hopfield, 2016; Bricken and Pehlevan, 2021; Tyulmankov et al., 2021; Whittington et al., 2021; Kozachkov et al., 2023). It is unclear at a computational level how memory index and content signals can be functionally distinct when they coexist in the same network and even in the activities of single neurons.
In this paper, we use the findings of Chettih et al. (2024) to guide the design of a biologically-plausible recurrent neural network (RNN) for cache memory formation and recall. The model generates barcodes and associates them with memory content in the same neural population. At recall time, the model can flexibly adjust the spatial scale of its memory retrieval, ranging from site-specific information to search of an extended area, depending on contextual demands. Using this model, we demonstrate the computational advantages of barcode-mediated memory by showing that it reduces interference between similar memories. We also show that place and barcode activities in the model play complementary roles in enabling memory specificity and flexible recall.
2 Results
2.1 Barcode representations in the hippocampus are observed during caching
We first review the key experimental results in Chettih et al. (2024). Black-capped chickadees were placed in a laboratory arena comprised of a grid of identical sites. Each site had a perch to land on and a hidden compartment, covered by a flap, where a seed could be hidden. Chickadees were allowed to behave freelyin this environment and collect sunflower seeds from feeders. A chickadee often visited sites without interacting with the hidden compartment (Figure 1A) but, at other times, the chickadee cached a seed into the compartment, or retrieved a previously cached seed (Figure 1B). Previous experiments demonstrated that chickadees remember the precise sites of their caches in this behavioral paradigm (Applegate and Aronov, 2022).
Chettih et al. (2024) recorded hippocampal population activity during these behaviors. When chickadees visited sites, place cells were observed, similar to those previously found in birds and mammals(Payne et al., 2021) (Figure 1C). Place cells did not change their spatial tuning after a cache. Instead, during caching and retrieval, neurons transiently displayed memory-related activity. During caching, neurons fired sparsely, with individual neurons producing large activity bursts for a small subset of caches at seemingly random locations (Figure 1D). These bursts occurred in both place cells and non-place cells, with the location of cache bursts unrelated to a neuron’s place tuning. At the population level, activity during a cache consisted of both typical place activity and a cache-specific component orthogonal to the place code, termed a “barcode”. Strikingly, barcode activity for a particular cache reactivated during later retrieval of that cache. These findings were evident when examining the correlation between population activity vectors for visits, caches and retrievals at different sites. When comparing two visits, the correlation profile decayed smoothly with distance, as expected from place tuning (Figure 1E). When comparing caching with retrieval, a similar smooth decay was observed for most distances, indicating the presence of place tuning. However, there was a substantial boost in correlation for caches and retrievals at the exact same site (Figure 1F). This site-specific boost resulted from reactivation of the cache barcode during subsequent retrieval.
Barcode activity during caching and retrieval, which are moments of memory formation and recall, suggests a mechanism supporting episodic memory. We hypothesize that the hippocampus generates a sparse, high-dimensional pattern of activity transiently during the formation of each memory, and that this serves as a unique index to which the contents of the memory are bound. Reactivation of the barcode at a later time drives the recall of the associated memory contents. In the food caching behavior studied by Chettih et al. (2024), the contents of memory include the location (“where”) and presence of a seed (“what”). Below, we implement this hypothesis in a computational model.
2.2 Generating barcode activity with random recurrent dynamics
We model the hippocampus as a recurrent neural network (RNN) (Alvarez and Squire, 1994; Tsodyks, 1999; Hopfield, 1982) and propose that recurrent dynamics can generate barcodes from place inputs (Figure 2A). Place inputs into the network are termed , and are spatially correlated as follows. Each neuron in the RNN receives inputs that are maximal at one location in the environment and decay with distance from that location, causing the neuron to have a single place field centered at that location. Across neurons, place fields uniformly span the environment. The firing rate activity of RNN units is denoted as . The recurrent weights of the model are given by J, and the RNN activity follows standard dynamics equations:
where is the voltage signal of the RNN units and g(·) is a leak rate that depends on the average activity of the full network, representing a form of global shunting inhibition that controls overall network activity. In our simulations, we simplify the task by using a 1D circular environment binned into 100 discrete spatial “states”. We set the spatial correlation length scale of place inputs such that the smallest distance between cache sites in the experiments of Chettih et al. (2024) is equal to 8 of these states (see Methods for more details).
We initialize the recurrent weights from a random Gaussian distribution , where μ < 0, reflecting global subtractive inhibition, and Nx is the number of RNN neurons). We first consider network activity before any learning-related changes. For the range of parameters we use, the network is in a chaotic state with a roughly constant overall level of activity but fluctuations in the activities of individual units. From an initial state of 0, we run recurrent dynamics until this steady-state level of overall activity has been achieved (Figure S1A,B). The chaotic recurrent dynamics induced by the random weights (Sompolinsky et al., 1988) effectively scrambles incoming place inputs. We demonstrate this by measuring the correlation of RNN activity across different locations and plotting this correlation as a function of distance (Figure 2B). Place inputs show a smoothly decaying correlation curve. At low values of σ, the network is primarily input driven, showing a smoothly decaying correlation matching inputs. At high values of σ, recurrence is so strong that it entirely eliminates the spatial correlation of nearby sites: activity at each state is decorrelated from activity at all other states.
Interestingly, at an intermediate level of σ = 7, the network retains elements from both high and low recurrence regimes (Figure 2B). The network exhibits a smoothly decaying correlation curve reflecting its inputs, but each state’s activity also contains a strong decorrelated component, apparent in the large drop in correlations for nearby but non-identical sites. This intermediate network regime closely resembles spatial correlation profiles observed during caching (Chettih et al., 2024) (Figure 1F). The smoothly decaying component is caused by the place code, whereas the sharp peak at zero distance – reflecting barcode activity – is caused by the recurrent dynamics. We thus construct networks using intermediate σ values, which allow for the coexistence of place code and barcode components in population activity.
A key result from Chettih et al. (2024) is that the hippocampus exhibits both place code and barcode activity during caching and retrieval, but only place activity during visits. We propose that this effect can result from a network in which recurrent strength is flexibly modulated. In a low-recurrence condition, the network produces the place code, whereas in a high-recurrence condition the same network produces a combination of place code and barcode activity. To simulate this in our model, we modify equation 2 to
where the newly included r ∈ {0, 1} scales recurrent strength such that the network may be in a feedforward (r = 0) or recurrent regime (r = 1). During visits, we assume the network is operating with low recurrent strength (r = 0). As a result, the activity in the RNN exhibits the spatial profile of its place inputs. We verify this is the case by visualizing early and late RNN activity given a place input (Figure 2C). With low recurrence, early and late RNN activity have similar spatial profiles, and late activity patterns for nearby states are highly correlated (Figure 2E). In contrast, when recurrence is enabled (r = 1), network activity is sparse with a heavy tail of a few strongly active neurons, and is decorrelated between nearby states (Figure 2D,F). These changes match experimental observations of excitatory neurons during food caching (Chettih et al., 2024).
We visualized neural activity during visits (r = 0) and caches (r = 1). During visits, RNN units display ordinary place tuning (Figure 2G, S1C). We also simulated spikes for all units at each location, and visualized this as a matrix where units were sorted by the preferred location of their inputs (Figure 2H). This matrix exhibits a diagonal structure reflecting strong spatial correlations. During caches, single neurons develop sparse, scrambled spatial responses relative to their place tuning (Figure 2I, S1C). Accordingly, simulated spikes across the population have greater random, off-diagonal components during caching than during visits. Thus, recurrence in a randomly connected RNN is a simple and effective mechanism to generate barcode signals from spatially correlated inputs. We alternatively considered a feedforward mechanism to generate barcodes, in which barcodes are computed by a separate feedforward pathway (Figure S2). We found the feedforward mechanism required an unreasonably large number of neurons and sparsity levels to match the decorrelation level of the recurrent mechanism.
2.3 Storing memories by binding content inputs with a barcode
Having suggested a mechanism for the generation of barcode representations, we next propose how such a representation can be leveraged for memory storage in a network model. In our food-caching task, we assume that the contents of a memory include the location of the cache and the identity of a food item within the cache. Thus, we add an additional input source besides spatial location into our model – an input s representing the presence of a seed (Figure 3A). The “seed” input projects randomly onto the RNN neurons. During caching, both place inputs and seed inputs arrive into the RNN, matching experimental findings (Chettih et al., 2024). This causes a mixed response in the network: one component of the response (place activity) is spatially tuned, another component (seed activity) indicates the presence of a seed and does not vary with location, and the third component (barcode activity) is generated by recurrent dynamics interacting with these inputs.
To store memories, we assume the RNN undergoes Hebbian learning after some fixed time point during the r = 1 recurrent dynamics (Figure 3A). At this time, the synapse j → i changes by an amount
where β > 0 provides an overall inhibition of the stored pattern. This term helps to prevent network activity from collapsing to previously stored attractors. Memory storage works as follows, following the experimentally observed sequence in Chettih et al. (2024): place inputs arrive into the RNN, recurrent dynamics form a barcode representation, seed inputs are activated, and then Hebbian learning binds a particular pattern of barcode activity to place- and seed-related activity. In this way, fixed-point attractors are formed corresponding to a conjunction of a barcode and memory content.
Memory recall in our network follows typical pattern completion dynamics, with recurrence strength set to r = 1 as for caches. As an example, consider a scenario in which an animal has already formed a memory at some location l, resulting in the storage of an attractor into the RNN. Later, the animal returns to the same location and attempts recall (i.e. sets r = 1, Figure 3B). The RNN receives inputs representing location l, which are partially correlated with , and recurrent attractor dynamics cause network activity to converge onto . This results in a reactivation of barcode activity, along with the place and seed components stored in the attractor state. The seed input can also affect recall, as discussed in the following section.
As an initial test of memory function in our model, we analyzed the activity patterns that are stored and recalled in the model. We simulated caching at different sites in the arena and extracted the population activity that is stored via Hebbian learning (Figure 3C, left). We then simulated retrieval as an event in which the animal returns to the same site and runs memory recall dynamics (r = 1) in the RNN. Population activity during retrieval closely matches activity during caching, and is substantially decorrelated from activity during visits (Figure 3C). We find that population activity in the RNN is more strongly correlated between caches and retrievals at the same site than two visits to a site that are not seed related (r = 0; Figure 3D). In addition, cache-retrieval correlations for non-identical sites rapidly drop to the level of visit-visit correlations because barcodes are orthogonal even for nearby sites. These correlation profiles closely resemble those observed in Chettih et al. (2024) (compare Figures 3D and 1E,F).
2.4 Barcode-mediated memory supports precise and flexible context-based memory recall
What are the computational benefits of barcode-mediated memory storage? We designed two behavioral tasks for our model that quantify complementary aspects of memory performance. In both tasks, we simulate a sequence of three caches in the circular arena. We then test the model’s performance during memory recall (i.e. r = 1) using two distinct tasks. The “Cache Presence” task requires the network to identify the presence or absence of a cached seed at the current location (Figure 4A). By evaluating the model on this task using different spacings between caches, we can measure the spatial precision of memory, i,e. how far apart two caches must be to prevent interference between their associated memories. The “Cache Location” task requires the network to identify the cache nearest to the current location by reactivating place activity corresponding to that cache location (Figure 4B). This task measures the robustness of recall and requires attractor dynamics to accurately retrieve memories from potentially distant locations. Together, these questions probe the ability of the memory system to be both specific (pattern separation) and searchable (pattern completion).
To enable readout from the model, we add an output layer containing place and seed units. During memory formation, these units receive a copy of place and seed inputs, respectively, and undergo Hebbian plasticity (equation 4 with β = 0) with RNN units. This enables the RNN to reactivate a copy of the inputs that were provided during memory formation. We measure the activity of the seed output to determine cache presence, and we measure place outputs to determine cache location. We note that other readout mechanisms would likely function similarly – for example, plastic feedback connectivity from recurrent onto inputs units. The output layer used here is not intended to correspond to a specific brain region, but simply to provide a window into what could be read out easily from network activity by downstream neural circuits.
We first show model performance on a single example of the Cache Presence and Cache Location tasks, where caches are made at the locations 20%, 35%, and 70% of the way around the circular track. For the Cache Presence task, we evaluate the model at each spatial location and plot the activity of the seed output (Figure 4C). After the first cache, we see that the seed output is only high at states around the vicinity of the first cache (Figure 4C, top). The false positive rate is not zero since the states around the cache also have high output. However, the width of this false positive area is less than the distance between two sites in the arena used in Chettih et al. (2024), indicating that the model is able to identify caches at the spatial resolution observed in chickadee behavior in these experiments. After a second cache, the seed output correctly reports seeds in the areas around the two caches (Figure 4C, middle). Importantly, the network separates the caches from each other, correctly identifying the absence of a seed at a position between the two caches. This behavior is maintained after the addition of the final third cache (Figure 4C, bottom).
For the Cache Location task, we examine the place outputs (Figure 4D, “Narrow Search”). When the current position is near a cache, the network correctly outputs a place field for the location of the nearest cache. However, an animal relying on memory to guide behavior may need to recall cache locations even when far away from a cache. To enable increased search radius, we make use of the seed input, which can bias network activity towards all memory patterns previously associated with this input. Activating the seed input greatly increases the range of current positions over which cache memories are retrieved (Figure 4D, “Broad Search”). Critically, this does not cause interference between memories. For example, as current position moves from the location of cache 1 to cache 2, place outputs discretely jump from one cache location to the other, corresponding to correct selection of the nearest cache location. The search radius during recall can thus be flexibly adjusted according to task demands, allowing the trade-off between pattern completion and pattern separation to be dynamically regulated by simple scaling of a network input.
We next systematically quantified model performance on these tasks. For these analyses, we binarized the seed output as being above or below a threshold (Figure S3AB). When caches are sufficiently spaced, memory recall is near perfect (Figure S3AB). This led us to evaluate the resolution of the model’s memory as caches become more closely spaced. We decreased the distance between cache 1 and 2 to identify the minimum distance where caches are separable, i.e. where the model correctly indicates the absence of a cache at a midpoint between caches 1 and 2. Figure 4E shows this correct reject rate as a function of the distance from each cache and the seed input strength. With low seed input (e.g. s = 0), the correct reject rate is high when the current location is one site distance away from caches 1 and 2. In other words, if a cache is made at site 1 and site 3, our model recognizes that site 2 remains empty. This precision matches the single-site resolution measured by behavioral experiments in this arena (Applegate and Aronov, 2022). As expected, performance on the Cache Presence task decreases with greater seed input strengths, as these are suited to searching over a broad spatial range.
For the Cache Location task, we measure the probability that the model outputs the location of the nearest cache. We plot this probability as a function of distance from the current location to the nearest cache (Figure 4F). The model is able to correctly recall cache locations with almost perfect accuracy when it is near a cache. Performance drops sharply with distance when the seed input is low, but is substantially recovered by increasing the seed input strength. Critically, even when the search radius is broad enough to include multiple caches, attractor dynamics encourage selection of the single closest cache location rather than blending memories. Thus the seed input strength provides a flexible search radius during the recall process. Low values of s are more suitable for detecting the presence or absence of a seed near the current location, while high values of s are more suitable for finding remote caches. The complementary demands of the Cache Presence and Cache Location tasks demonstrate the utility of a flexible search radius within one memory system.
We further examined how model hyperparameters affected performance on these tasks. We find that the plasticity bias β is needed to prevent erroneous memory recall at sites without caches (Figure S3E-H). Without this, recall specificity is poor and model performance suffers on the Cache Presence task. We also verified that our model is robust to the order in which caches were made (Figure S3CD). Finally, we extended our model to work with random, spatially correlated inputs, rather than receiving place cell-like inputs (Figure S4). This shows that our results apply regardless of the specific format of spatial inputs, which are experimentally undetermined.
2.5 Place activity and barcode activity play complementary roles in memory
We have shown that a barcode-mediated memory system is precise yet allows flexible, content-based retrieval. Below we identify the specific contributions of place and of barcode activity by ablating either of these components in our model. To ablate barcodes (“Place Code Only” in Figure 5), we initialize our model without the random recurrent weights that produce chaotic dynamics. This is akin to running caching dynamics in “visit mode”, i.e. r = 0 in Figure To ablate place activity (“Barcode Only” in Figure 5), we eliminate spatial correlations in the networks inputs. This is akin to having place fields with extremely narrow precision, rather than a spatially smooth place code. We test both ablated models on the three-cache tasks from above and compare their performance to our full model.
The Place Code Only model directly binds memory contents of place and seed. This causes cache memories for nearby locations, where the place code is correlated, to interfere with each other. Interference is clearly visible in the performance on the Cache Presence task (Figure 5A, left). The seed output of the place code only network is high across a wide area including caches 1 and 2 and the empty locations between them. Indeed this network is unable to identify the absence of a cache at locations between caches 1 and 2, even with a substantial distance between them (Figure 5C). Furthermore, the memories for caches 1 and 2 sometimes appears to suppress memory for a distant cache Further evidence of interference is apparent in the Cache Location task, where the network merges caches 1 and 2, and entirely fails to signal the cache at location 3 (Figure 5B, left). This network has a low true negative rate, and often a single cache dominates the output (Figure S5A-D). Accordingly, the network is able to signal the location of a cache, but this location is often not the nearest cache (Figure 5D). Intuitively, without barcodes the network is unable to distinguish individual memories at nearby spatial locations. Without this barcode-mediated competition, it forms a single agglomerated memory that is inflexibly recalled.
If correlations in inputs cause memory interference, why not do away with them entirely? The Barcode Only model shows that this is not a good option. This model performs well on the Cache Presence task (Figure 5A, right, Figure S5E-G), correctly identifying the presence of all three caches, and the absence of caches in other locations (Figure 5C). However, the Barcode Only model fails on the Cache Location task. The model is unable to recall place fields that are not precisely at its current location (Figure 5B,D). With greater seed input, the model can sometimes recall memories at remote locations, but these are selected randomly with no preference for nearby caches (Figure 5D, Figure S5H). Intuitively, the model cannot distinguish nearby and distant caches because it lacks input correlations, which establish the measure of proximity.
In summary, place and barcode activity play complementary roles in our model. Barcode activity functions like an index for individual memories. This function supports discriminability of memories even when memory contents overlap – for example, for two nearby caches with correlated place activity. Barcodes also support selective recall of individual memories in our model via competitive attractor dynamics. However the discriminability advantage of barcodes is only useful if they can be reactivated during memory recall. Spatially correlated place inputs (and the seed input) allow efficient memory retrieval by defining a measure of proximity in memory contents, and support remote memory recall. The presence of both index and content signals in our model allows all of these functions to be performed by the same network, and for the trade-offs between them to be adjusted flexibly.
2.6 Modulating recurrent strength allows the RNN to incorporate both predictive maps and barcode memory
We have constructed a model of a simple episodic memory, taking inspiration from hippocampal data (Chettih et al., 2024). However, the hippocampus has also been suggested to support functions beyond episodic memory. An especially influential line of prior work proposes that the hippocampus plays a role in generating predictive maps, with evidence from both experiments (including in food-caching birds) (Muller and Kubie, 1989; Mehta et al., 2000; Payne et al., 2021; Applegate et al., 2023) and theory (Blum and Abbott, 1996; Stachenfeld et al., 2017; Whittington et al., 2020). This raises the question – is our model consistent with predictive map theories? And if so, how might predictive maps influence episodic memory recall?
Interestingly, prior work has shown that biologically realistic RNNs can generate predictive maps with structured recurrent weights (Fang et al., 2023). Specifically, if recurrent weights encode the transition statistics of an animal’s experience, then predictive map-like activity will arise from the RNN dynamics, and can be controlled by recurrent strength (analogous to the value of r in equation 3). This prediction via structured recurrent weights invites comparison to the use of random recurrent weights in our model to generate barcodes. Inspired by this connection, we considered whether a single model could generate both predictive and barcode activity via recurrent dynamics. We constructed a hybrid model, in which recurrent weights are a blend of random weights, as above, and structured, predictive weights as in Fang et al. (2023) (Figure S6AB). We hypothesize that network activity changes from a predictive to a chaotic regime (supporting barcodes) with increasing recurrent strength, i.e. as we adjust r in the range 0 < r < 1.
We use the same circular arena for our simulations, but with the assumption that animal behavior is biased, i.e., the animal only moves clockwise (Figure 6A). We visualize population activity at each site, with units sorted by their place field. When recurrent strength is at its lowest (r = 0, Figure 6B) network activity is place-like and reflects the current location of the animal provided in its inputs. When recurrent strength is slightly increased (r = 0.3, Figure 6C), the network exhibits predictive activity. That is, neural activity of recurrent units is shifted to reflect an expected future position, relative to the current spatial position encoded in inputs. This is consistent with observations from experimental data collected from hippocampus of animals with biased movements in a linear track (Wilson and McNaughton, 1993; Mehta et al., 1997, 2000; Lisman and Redish, 2009). Finally, when recurrent strength is maximal (r = 1.0, Figure 6D) we observe barcodes, i.e. sparse activity at random positions relative to inputs. We plot spatial tuning curves of a few example RNN units under low, intermediate, and high recurrent strengths (Figure 6E, S6C). Individual units can display typical place fields (blue), skewed predictive place fields (orange), and barcode activity (purple).
These results suggest that the structured and random components of recurrent connectivity can act somewhat independently of each other, with their relative contributions determined by recurrent strength. We quantify this by measuring the magnitude of the projection of population activity onto the place code, the predictive code, and barcodes as a function of recurrent strength (Figure 6F). At the lowest recurrent strength (r = 0), the population activity is solely concentrated on the place code. As recurrent strength is increased, place coding decreases and predictive activity increases with a peak around r = 0.4. Beyond this, both place and predictive activity decrease as barcode activity rises to a peak when r = 1.0.
Finally, we explore the functional implications of including predictive maps into our memory model. We first verify that model performance in the previous three-cache tasks is not disrupted by including predictive weights in the model (Figure S7). We then examine memory recall of a single cache for a predictive model, assuming a clockwise behavioral bias (Figure 6G). The model exhibits a profound skew: the cache is recalled much earlier on the path leading up to the cache location, at further distance from the cache than on the path after the cache location. This indicates that knowledge of the environment and prior experience, as reflected in predictive place activity, can shape memory recall in our model.
3 Discussion
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, 2014), and proposed to control the recurrent gain of hippocampal processing (Hasselmo, 1999, 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öldiak, 1990; Olshausen and Field, 1996; Sacouto and Wichert, 2023; Muscinelli et al., 2023). A separate possibility is that barcodes are generated in a circuit upstream of where memories are stored, and supplied as inputs to the hippocampal population. 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, 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 content-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). Our work suggests that the hippocampus may use principles similar to those of key-value memory structures to store episodic memories.
Episodic memory is often studied at a behavioral level in humans performing free or cued recall of remembered word lists (Kahana, 1984; 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).
Acknowledgements
We thank Kim Stachenfeld, Ashok Litwin-Kumar, and members of the Aronov, Stachenfeld, and Abbott labs for feedback on this work. This research was supported by the Gatsby Charitable Foundation and the Kavli Foundation and by NSF award DBI-1707398, NIH Director’s New Innovator Award (DP2-AG071918), NIH Pathway to Independence Award (SC, 1K99NS136846), NSF GRFP (CF), and DOE CSGF (JL, DE–SC0020347).
Contributions
All authors contributed to conceptualization of this project. CF, JL, and SC designed the network and experiments. CF and JL performed formal analysis, with supervision by SC, DA and LA. CF, SC and DA prepared the manuscript with feedback from all authors.
Methods
Caching Task
We simulate a caching task in a circular track, similar to Chettih et al. (2024). The track consists of Ns connected states. The goal of this task is to test how well an agent equipped with a memory model can precisely recall the locations where a cache (or memory) has been stored. Specifically, for each simulation we first choose a set of states C that will be the location where caches are made. For each state c ∈ C we assume the agent is currently at state c and allow the model to store a memory at that state. We then simulate what the output of the model is if the agent is at any of the other Ns states. We continue this procedure for the remaining states in the list.
In the three-cache task, C = {0, m, Ns ∗ 0.7}. We sweep over different values of 0 < m < Ns ∗ 0.7 to test the effects of site spacing. In the main figures, these three caches are made in increasing order of their location. However, we also randomly shuffle the order of caching in a supplementary figure (Figure S3CD) and do not find any effects on model performance.
Barcode model
Architecture
Place inputs into the model arrive from an input layer . The input layer feeds into a recurrent neural network with activity , where Nx = Np. Place input units connect to recurrent units with one-to-one connections (that is, the weight matrix Jxi from the place input layer to the recurrent network is the size Nx identity matrix). Recurrent weights are encoded in the matrix . At initialization, where μ, σ are tunable hyperparameters controlling the mean and standard deviation of the distribution.
The input representing seeds arrives from a single unit s. The connections from s to recurrent units are encoded in the vector . Each value of is sampled from the standard normal distribution.
Recurrent dynamics
Recurrent dynamics are run over T timesteps. Let be the preactivations of the recurrent population at time t and be the activations of the recurrent population at time t. That is, . The recurrent dynamics are defined over :
where r ∈ {0, 1} is a modulatory factor that controls whether the network operates with recurrent dynamics or is purely feedforward driven. The first term in the equation corresponds to a voltage leak term where the leak at each neuron is proportional to global population activity. This effectively implements a form of divisive normalization, and helps keep network activity stable even as weights are updated during the caching task. The second term in the equation represents recurrent inputs, while the last two terms represent feedforward inputs into the network.
Input structure and timing
Place is encoded in such that, at location k, each input neuron l has activity where d is the shortest distance between k and l as a percentage of the circular arena size. We consider 100 evenly sampled states in this state space. Seed input s may be any nonnegative scalar value.
Place mode: Input is active over all T timesteps. Recurrence is turned off (r = 0), as is the seed input (s = 0).
Caching mode: Input is active over all T timesteps and input s is active over timesteps [T − ts, T] with strength λ. Recurrence is on (r = 1).
Recall mode: Input and input s are both active over all T timesteps. Recurrence is on (r = 1). The value of s is flexibly modulated to adjust the search strength (s ≥ 0).
Update rule
Let be the activations of the recurrent network at the end of recurrent dynamics (in our case, at time T). At each cache event the update rule carried out is
where η controls the learning rate. The weight update contains a Hebbian update through and an inhibitory update through , where β is a negative scalar. This inhibitory term causes the connections between neurons which are not co-active during caching to weaken. The update rule can also be stated in terms of the synapse j → i:
This is the form shown in equation 4.
Network readout
To detect cache presence, we define a seed output signal. The output ys is read out from the recurrent network activity through weights . At initialization, . Every time a cache is made, the following update rule is run: . Thus, seed output is read out as .
To recall cache location, we define a place field readout layer. The output is read out from the recurrent network through weights . At initialization, Jyx = 0. Every time a cache is made, the following update rule is run: . Thus, recalled cache locations are read out as .
Ablations
To construct a place code only model, we ablate barcode generation by setting J = 0 at initialization. To construct a barcode only model, we ablate the presence of place-correlations in the input by setting the place input spatial scale parameter ν to a very small value 10−3 in the place encoding equation.
Defining site distance in our simulation
To allow comparisons to data in Chettih et al. (2024), we first determine the number of states in our simulation that’s equivalent to the distance between adjacent cache sites in Chettih et al. (2024). To do so, we note that the spatial correlation between population activity at two adjacent cache sites is around 0.75 (when spatial correlation profile is normalized to [0, 1]). We identify the number of states in our simulation such that the normalized correlation between visit activity is also around 0.75. We find that this is around 8 states. Thus, we define 8 states in our simulation as equivalent to the distance between adjacent cache sites.
Simulating and visualizing spikes
We simulate Poisson spikes from our rate network in Figure 2HJ. Specifically, for a unit with rate r, we draw spikes from a Poisson distribution with mean and variance r + K. We set K = 0.2 to visually match observations from data.
Spatial correlation of RNN activity at different sites
To calculate correlation values as in Figure 3D, we average over the correlations across multiple samples of Poisson-generated population spikes. Specifically, for RNN activity at location i, we first generate a sample vector of spikes Poisson . We choose k to be 0.2 to match experimental spatial correlation profiles in the “visit-visit” condition. To get the correlation of population activity at locations i, j, we calculate the population Pearson correlation coefficient between and . To generate Figure 3D, we collect correlation values between sites with caches in an experiment where 5 caches are made in randomly chosen site locations. All values are normalized by the “visit-visit” correlation value at a site distance of 0. This is repeated over 20 random seeds.
Barcode model with predictive map
The barcode model with prediction differs from the default model in the initialized weight matrix. Specifically, the weight matrix J = B + M, where B is the random Gaussian matrix of the default model. M is a successor representation-like matrix (Stachenfeld et al., 2017) defined as
where T is the transition probability matrix and γ = 0.99 is a temporal discount factor. We also add a scaling factor ρ = 0.075 and an inhibitory offset δ = −0.015. M is a 5000-dimensional square matrix, and we truncate the summation at D = 300 steps. T is defined as
Alternative model: feedforward barcode generation
We will construct a feedforward model to generate sparse, decorrelated barcodes (Figure S2A). Place inputs to the model are fed through a hidden expansion layer before being compressed again by an output layer to generate the barcode. We first define these layers via the random matrices and where and . We make the hidden layer very large: M = 20000. The activity of the model in the hidden layer is described as:
where Cθ is a constant chosen such that the proportion of units in that are active is θ. In other words, θ is a hyperparameter of the model that sets how sparse the hidden layer activity is.
The hidden layer activity is then passed through the output weights to form the barcode activity generated by the feedforward model:
where C is a constant chosen such that the sparsity of matches the sparsity of barcodes generated in the default RNN barcode model.
Alternative model: place encoding with Gaussian input weights
We simulate a version of the model with more realistic and complex place inputs. We generated the input currents to the RNN units according to a 0-mean multivariate Gaussian process. The statistics of the Gaussian process are chosen such that the covariance of the inputs to RNN unit i and unit j is an exponentially decaying function of their minimum spatial distance d around the circular arena: . All other details of this alternative model is the same as in the default.
Code
Code is publicly available on https://github.com/chingf/barcodes.
Parameter values
Supplementary Figures
References
- Memory consolidation and the medial temporal lobe: a simple network modelProceedings of the national academy of sciences 91:7041–7045
- Flexible use of memory by food-caching birdsElife 11
- An entorhinal-like region in food-caching birdsCurrent Biology 33:2465–2477
- Sparseness and expansion in sensory representationsNeuron 83:1213–1226
- Memo: A deep network for flexible combination of episodic memoriesarXiv
- Prediction and memory: A predictive coding accountProgress in neurobiology 192
- A model of spatial map formation in the hippocampus of the ratNeural Computation 8:85–93
- Attention approximates sparse distributed memoryAdvances in Neural Information Processing Systems 34:15301–15315
- Barcoding of episodic memories in the hippocampus of a food-caching birdCell 187:1922–1935
- Episodic-like memory during cache recovery by scrub jaysNature 395:272–274
- Memory as a computational resourceTrends in cognitive sciences 25:240–251
- Neural learning rules for generating flexible predictions and computing the successor representationelife 12
- Forming sparse representations by local anti-hebbian learningBiological cybernetics 64:165–170
- The recall of events through the learning of associations between their partsProceedings of the Royal Society of London. Series B. Biological Sciences 194:375–402
- Neural turing machinesarXiv
- Hybrid computing using a neural network with dynamic external memoryNature 538:471–476
- Neuromodulation: acetylcholine and memory consolidationTrends in cognitive sciences 3:351–359
- The role of acetylcholine in learning and memoryCurrent opinion in neurobiology 16:710–715
- Neural networks and physical systems with emergent collective computational abilitiesProceedings of the national academy of sciences 79:2554–2558
- The temporal context model in spatial navigation and relational learning: toward a common explanation of medial temporal lobe function across domainsPsychological review 112
- A distributed representation of temporal contextJournal of mathematical psychology 46:269–299
- Computational models of memory searchAnnual Review of Psychology 71:107–138
- Associative retrieval processes in free recallMemory & cognition 24:103–109
- Sparse distributed memoryMIT press
- Building transformers from neurons and astrocytesProceedings of the National Academy of Sciences 120
- Large associative memory problem in neurobiology and machine learningarXiv
- Dense associative memory for pattern recognitionAdvances in neural information processing systems 29
- Neural stored-program memoryarXiv
- Prediction, sequences and the hippocampusPhilosophical Transactions of the Royal Society B: Biological Sciences 364:1193–1201
- Dendritic inhibition in the hippocampus supports fear learningScience 343:857–863
- Simple memory: a theory for archicortexFrom the Retina to the Neocortex Springer :59–128
- Hippocampal synaptic enhancement and information storage within a distributed memory systemTrends in neurosciences 10:408–415
- Experience-dependent, asymmetric expansion of hippocampal place fieldsProceedings of the National Academy of Sciences 94:8918–8921
- Experience-dependent asymmetric shape of hippocampal receptive fieldsNeuron 25:707–715
- The firing of hippocampal place cells predicts the future position of freely moving ratsJournal of Neuroscience 9:4101–4110
- Optimal routing to cerebellum-like structuresNature neuroscience 26:1630–1641
- Fundamental law of memory recallPhysical Reveiw Letters 124
- Emergence of simple-cell receptive field properties by learning a sparse code for natural imagesNature 381:607–609
- Neural representations of space in the hippocampus of a food-caching birdScience 373:343–348
- Hopfield networks is all you needarXiv
- Competitive learning to generate sparse representations for associative memoryNeural Networks 168:32–43
- Complementary learning systems within the hippocampus: a neural network modelling approach to reconciling episodic memory with statistical learningPhilosophical Transactions of the Royal Society B: Biological Sciences 372
- A context-based theory of recency and contiguity in free recallPsychological review 115
- Food storage by black-capped chickadees: Memory for the location and contents of cachesAnimal Behaviour 32:451–464
- Chaos in random neural networksPhys. Rev. Lett 61:259–262
- The hippocampus as a predictive mapNature Neuroscience
- End-to-end memory networksAdvances in neural information processing systems 28
- Can semantic relatedness explain the enhancement of memory for emotional words?Memory & cognition 32:742–751
- The hippocampal memory indexing theoryBehavioral neuroscience 100
- The hippocampal indexing theory and episodic memory: updating the indexHippocampus 17:1158–1169
- Attractor neural network models of spatial maps in hippocampusHippocampus 9:481–489
- Episodic and semantic memoryOrganization of memory 1
- Biological learning in key-value memory networksAdvances in Neural Information Processing Systems 34:22247–22258
- The tolmaneichenbaum machine: unifying space and relational memory through generalization in the hippocampal formationCell 183:1249–1263
- Relating transformers to models and neural representations of the hippocampal formationarXiv
- Dynamics of the hippocampal ensemble code for spaceScience 261:1055–1058
- Cholinergic switching within neocortical inhibitory networksScience 281:985–988
- Task-dependent optimal representations for cerebellar learningElife 12
Article and author information
Author information
Version history
- Preprint posted:
- Sent for peer review:
- Reviewed Preprint version 1:
Copyright
© 2025, Fang et al.
This article is distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use and redistribution provided that the original author and source are credited.