16 min read3 days ago
–
Press enter or click to view image in full size
Abstract
This paper presents a spiking semantic neural network augmented with a hippocampus-inspired memory model. Together, these components implement a Turing-machine–like computational system with internal memory represented directly within the neural substrate.
Unlike previous neural approaches to Turing machine emulation, where the memory tape is implemented as an external structure or using single neurons, the proposed model stores memory internally using neural clusters. This design increases behavioral flexibility and enables direct control over memory traversal and execution during inference.
The paper focuses exclusively on inference-time computation; training mechanisms are intentionally exclud…
16 min read3 days ago
–
Press enter or click to view image in full size
Abstract
This paper presents a spiking semantic neural network augmented with a hippocampus-inspired memory model. Together, these components implement a Turing-machine–like computational system with internal memory represented directly within the neural substrate.
Unlike previous neural approaches to Turing machine emulation, where the memory tape is implemented as an external structure or using single neurons, the proposed model stores memory internally using neural clusters. This design increases behavioral flexibility and enables direct control over memory traversal and execution during inference.
The paper focuses exclusively on inference-time computation; training mechanisms are intentionally excluded and left for future work.
Introduction
Previous works [1–7] describe attempts to emulate a Turing machine using neural networks; however, in these approaches the memory tape is implemented as an external device.
A more closely related approach is presented in [9], where each new tape cell is translated into the creation of a new neuron with the required parameters.
The present work extends this line of research, and instead of representing a tape cell by a single neuron, the hippocampus stores information in a group of neurons (a neural cluster within the hippocampus). This approach makes it possible to increase the behavioral flexibility of such representations and provides a more convenient way to control their dynamics.
Results
The source code is published in [10] (see also the Chess Neural Network section below). The demonstration neural network implements both a simple and a complex algorithm.
The simple algorithm memorizes the input sequence. Upon receiving a query such as "count a" or "count b", the network traverses the stored memory backward, counts occurrences of the specified symbol using an internal counter, and outputs the result in decimal form.
The complex algorithm interprets inputs such as "e2 e4" as chess move notation. Based on the sequence of moves, the network constructs the current state of a chessboard. Optionally, it outputs the current board state as ASCII graphics. Upon request, the network enumerates all possible legal chess moves for either White or Black pieces, depending on whose turn it is according to the move notation.
Optional reminder of hippocampal function
Both artificial and biological neural networks require multiple repetitions of the same training samples in order to learn.
In artificial models, this requirement is dictated by the need for mathematical convergence. If a neural network adjusts its weights using small incremental updates, a single exposure is insufficient to form a stable memory. Conversely, if the network performs large updates, a single adjustment may destabilize and overwrite other, weakly related memories.
In biological neural networks, these considerations are further constrained by biological limitations: protein structures require time for activation and consolidation of changes, and neural connectivity itself is limited. As a result, an additional mechanism — the hippocampus — was required to enable one-shot learning of events.
There exist highly detailed mathematical models of the hippocampus that describe its various subregions (Parahippocampal cortex, Dentate Gyrus, CA1, CA3, Subiculum, Entorhinal Cortex) and are sufficiently accurate to support the development of biological neural prostheses. However, for the purposes of this work, we consider the most simplified model possible.
One hippocampal region receives inputs from other brain structures. The overall activity of the brain is projected onto this region with limited precision, forming a large embedding. (Here, the term “embedding” is used to denote a neural activity pattern representing the current global brain state). This embedding is then transmitted to another region which, due to its internal topology, expands the dimensionality of the embedding and brings different parts of the original embedding closer together in various combinations.
Another hippocampal region periodically stores active embeddings into an internal cache. The hippocampus then operates in several distinct modes. In addition to embedding memorization, there exists a learning mode: during slow-wave sleep phases at night, the hippocampus unpacks these embeddings and projects them back onto the global neural network.
This “embedding cache” retains information for durations ranging from days to several tens of days, depending on importance, and during this time it periodically retransmits stored information back to the global network. In response to these repetitions, the neural network strengthens synapses between the corresponding neurons and gradually restructures itself to incorporate the new information. In this mode, the hippocampus can be interpreted as functionally equivalent to sending training batches to the neural network.
As an additional mechanism, the neural network also exhibits plasticity in the form of slow growth of new connections, which become stabilized if suitable target neurons are found.
Another important operational mode is the emulation of a network state in which the required neurons and connections already exist. If the brain had to wait for sleep in order to repeatedly strengthen connections, then once attention shifted away from the current situation, we would only be able to recall it after sleep — on the following day or even later. Instead, the embedding cache can retrieve the required sequences of activations as if the neural network had already been trained.
Simplified hippocampus model
In artificial neural networks, we are not constrained by biological topology. As a result, there is no strict need for dedicated regions responsible for compression and expansion of embeddings of different dimensionalities. When working with semantic neural networks — where the connectivity topology is not fixed but can be reorganized arbitrarily — we can directly assemble the required memories “on demand”.
A brief clarification of terminology is required. In a semantic neural network, connections encode explicit semantic relationships rather than purely statistical correlations.
Throughout this work, the term Neural Network is used to refer to conventional architectures. When biologically inspired functional subsystems — such as a hippocampus — are incorporated, the corresponding classes include the suffix Brain to reflect their extended role.
We begin with pseudocode and then present the chain of reasoning that leads to the final implementation described in [10].
Let us assume a semantic neural network of the following form:
struct Neuron { float activation; float threshold; std::vector<Link*> outputLinks;};
In this case, we can immediately create a neuron that stores connections or pointers to currently active neurons. This approach resembles the mechanism described in [9].
However, in order to implement additional operational modes of the hippocampus, we introduce a more complex structure. Instead of creating a single neuron to store an embedding, we construct the following neural cluster:
struct HippocampusCluster { Neuron input; Neuron output; Neuron emotionsLevel; // importance / storage duration Neuron attentionFlag; Neuron management[...];};
A single such cluster stores one embedding. Code such as
HippocampusCluster* cluster = new HippocampusCluster();
corresponds to the biological analogy of “finding an unused cluster within the hippocampal cache, or a cluster whose data have already been processed in previous days and are ready to be overwritten with new information”.
Let us now consider pseudocode for memory formation during wakefulness:
std::vector<Neuron*> embeddingToMemorize = getActiveNeuronsExceptHippocampus();HippocampusCluster* cluster = new HippocampusCluster();for (Neuron* nrn : embeddingToMemorize) { createLink(nrn, cluster->input); createLink(cluster->output, nrn); cluster->emotionsLevel.activation = ... ...}
The attentionFlag neuron and the management neurons are responsible for controlling the operational modes of the cluster: memorization of information, recall during nighttime training of the main neural network, recognition of information during wakefulness, and its projection back to the main network.
The input neuron enables recognition of similar embeddings and can signal “yes, this has been processed recently; such information exists”. The output neuron allows this information to be retransmitted back to the main network either upon request or during nocturnal replay.
Normalization (compression) of cluster connections
Regardless of how the system operates further, we can observe that connection information for the input and output neurons is duplicated: the same links are stored twice, differing only in direction. Instead of wasting memory, we can merge the link arrays of different neurons within a single cluster. This process is analogous to database normalization, where duplicated relational data are factored into a shared representation. To achieve this, links must be bidirectional (described below). We therefore separate neuron state from connectivity. To reflect this separation, we introduce a lightweight NeuronBody structure that contains only neuron state, while connectivity is stored at the cluster level.
using Links = std::vector<Link*>;struct NeuronBody { float activation; float threshold; bool isActive() const; // depends on activation function};struct HippocampusCluster { Links embedding; // shared by both input and output NeuronBody input; NeuronBody output; NeuronBody emotionsLevel; NeuronBody attentionFlag; Neuron management[];};
The management[] neurons, which regulate mode switching (memorization, recognition, learning), are identical for all clusters, and the connection weights between them are also identical. Thus, these neurons represent control logic rather than learned state. As a result, their behavior can be directly expressed as C++ code that modifies neuron activations.
Therefore, the management neuron array can be removed from the cluster.
Homogenizing the neural network and hippocampal clusters
Let us enumerate which connections are required. We need: connections between neurons of the main network (the cortex), connections between neurons and hippocampal clusters, and connections between hippocampal clusters to preserve their ordering. To avoid introducing three different link types, it is convenient — at least for simplified models — to replace ordinary neurons with the same kind of neural clusters.
This replacement becomes particularly useful once more complex algorithms are introduced: such algorithms will no longer need to distinguish whether information is stored in the hippocampus or has already been transferred into the main neural network. The cortical recognition loop will include the hippocampus as an integral component, and clusters created by the hippocampus become functionally equivalent to consolidated cortical clusters, without requiring immediate weight adaptation elsewhere. In this sense, such clusters also begin to resemble cortical columns.
We introduce a new structure. We use the abbreviation NC (NeuroCluster). Depending on the context, it may be interpreted as a cortical column-like unit or as a hippocampal cache unit.
struct NC; // NeuroClusterstruct Link { NC& _from; NC& _to; float k; float bias; ...};// input and output linksusing LinksI = std::vector<Link*>;using LinksO = std::vector<Link*>;struct NC { LinksI properties; LinksO out; NeuronBody input; NeuronBody output; ...};
Instead of the term embedding, we will use the broader semantic term *properties. *Here, properties denotes the set of incoming links that define the cluster’s semantic attributes (i.e., the “property graph” of the cluster), which is suitable both for storing cortical features/attributes and for storing hippocampal embeddings.
Introducing time-aware connections
In biological neural networks, information about the sequence of embedding activations can be implicitly encoded within the set of active features itself. However, nothing prevents us from embedding such information explicitly into the hippocampus and into the general cluster structure. Doing so significantly simplifies the model.
We therefore divide connections into two types:
- Connections that encode feature hierarchy. These are analogous to inter-layer connections in classical neural network models.
- Connections that encode temporal activation. These are analogous to feeding the previous output of a neural network back into itself in the next computation cycle.
These two connection types represent orthogonal dimensions of computation: structural abstraction and temporal dynamics. For the simplified model considered here, we propagate temporal information for only a single previous timestep. This restriction is sufficient for the algorithms demonstrated in this work and keeps the model analytically tractable. To achieve this, we introduce a new neuron inside each cluster that becomes active only if the cluster itself was active during the previous cycle: NeuronBody nPrev;
Get neurocod’s stories in your inbox
Join Medium for free to get updates from this writer.
Functionally, nPrev acts as a one-step recurrent state variable.
We then introduce new link containers responsible for propagating temporal information from this neuron:
struct NC { NeuronBody nPrev; // NC was active in the previous cycle // links encoding temporal information LinksI lTIn; LinksO lTOut; // links encoding feature hierarchy LinksI lUpIn; // properties or low-level features LinksO lUpOut; // higher-level features NeuronBody nIn; // input NeuronBody nOut; // output};
To support these containers, we extend the link class to explicitly store references to the specific containers in which the link is registered:
class Link {public: NC& _from; NC& _to; LinksO& _lFrom; LinksI& _lTo; ... Link(NC& from, NC& to, LinksO& lFrom, LinksI& lTo);};// Helper functions for creating links along the selected dimensionsLink* linkTime(NC* from, NC* to) { return new Link(*from, *to, from->lTOut, to->lTIn);}Link* linkUp(NC* from, NC* to) { return new Link(*from, *to, from->lUpOut, to->lUpIn);}
This design allows links to be treated uniformly while still encoding their semantic role.
Virtual layers of the neural network
Let us consider a basic activation propagation cycle
std::vector<NC*> _clusters;...for (NC* nc : _clusters) { if (nc->input.isActive()) { for (Link* link : nc->lUpOut) { link->_to.nIn.activation += link->b; } }}
This is analogous to activation propagation in a single-layer neural network, and such a network is highly limited in expressive power.
In our model, there is no explicit separation into physical layers. Instead, we introduce the concept of virtual layers. Virtual layers correspond to a dynamic topological ordering of active clusters rather than to fixed architectural layers. For this purpose, we add a boolean variable bool _sent to each cluster. Before the propagation cycle, it is initialized to false:
for (NC* nc : _clusters) { nc->_sent = false;}
The _sent flag acts as an execution marker, ensuring that each cluster propagates its activation at most once per cycle. We then perform activation propagation across virtual layers:
for (int virtualLayer = 0; ; ++virtualLayer) { bool sentAny = false; for (NC* nc : _clusters) { if (!nc->nIn.isActive() || nc->_sent) continue; nc->_sent = true; sentAny = true; for (Link* link : nc->lUpOut) { link->_to.nIn.activation += link->b; } } if (!sentAny) break;}
This neural network cannot enter an infinite loop, because during each iteration at least one cluster must propagate its activation and be marked as already processed. If no such cluster exists, the loop terminates. This guarantees termination even in the presence of recurrent structural connections, as long as temporal links are not traversed during hierarchical propagation.
The maximum number of virtual layers is reached in the case of a network where all clusters are connected into a single chain. In practice, however, the number of virtual layers is typically much smaller and reflects the effective depth of the feature hierarchy. This mechanism allows the network to behave as a multi-layer system without committing to a fixed layered architecture.
Loading sensory information
The neural network autonomously determines when sensory information (for example, input read from the console) should be loaded into sensory clusters. This is achieved via activation of a dedicated system cluster _askLoadSensors.
In cases where the neural network operates without an active neural program (and therefore no activation reaches this cluster and no explicit input request is generated), or when such a program terminates, sensory input is requested automatically. This automatic request is triggered when neural activity comes to a halt — that is, when two consecutive cycles of the neural network do not change neuron activations:
if (_askLoadSensors->nIn.isActive() || !_activeChanged) { loadSensors(); // time for new input}// after cycle_activeChanged = false;for (NC* nc : _clusters) { _activeChanged |= (nc->nIn.isActive() != nc->nPrev.isActive());}
This approach allows the “brain” to pause for internal reasoning and then return to sensory input once a response to the current query has been produced.
Attention Control
Universal attention can be viewed as inherently three-component. It may take the form of a Query–Key–Value triple in transformer-like attention mechanisms, an object–property–value triple in semantic networks, or a call–variable–value stack in function call paradigms. The interaction between full-fledged attention mechanisms and the hippocampus has its own subtleties and lies beyond the scope of this paper.
For the task of traversing a chessboard, however, single-component attention is sufficient. Here, “single-component attention” refers to a scalar persistent activation rather than a structured attention tuple.
To implement this, we use an analogue of LSTM (Long Short-Term Memory): certain clusters do not lose their activation in the next computation cycle. This effect could be achieved by introducing self-links within clusters. However, for memory efficiency — given the large proportion of such clusters — it is preferable to introduce a cluster type variable instead.
In this work, we are primarily interested in the TypePermanent cluster type:
struct NC { enum Type { TypeSensor, TypePermanent, // the only type processed differently (LSTM-like) TypeTemp, // other types serve mainly for debugging / clarification TypeCmd, TypeHippo, TypeEffector, TypeSystem // _askLoadSensors and other };};
Before each virtual-layer propagation pass and before loading sensory input, all clusters except those of type TypePermanent are reset. Such clusters preserve their activation unless explicitly deactivated.
Deactivation can occur in two ways: either other clusters send negative activation through their connections, or the neural network explicitly resets attention, as described in the following section.
Operating modes
The first and most obvious operating mode is memorization of information into a new hippocampal cluster. This mode is activated either when sensory information is loaded, or when a special system cluster _memorizeCurrentState becomes active. The latter allows the network to memorize internally generated activation states in the absence of external sensory input:
if (_memorizeCurrentState->nIn.isActive() || _askLoadSensors->nIn.isActive()){ memorizeCurrentState();}
Conceptually, system clusters such as _memorizeCurrentState are responsible for hippocampal operation, are considered part of the hippocampal subsystem, and are not included in the recorded embedding. For this purpose, the network defines a dedicated cluster type TypeSystem.
NC* systemClusters[] = { _askLoadSensors, _return, _memorizeCurrentState};
System clusters participate in control flow but are explicitly excluded from episodic memory content. The second operating mode is navigation along the memory chain, either to the left or to the right. Leftward traversal is sufficient for the demonstrated chess-search algorithm; however, bidirectional movement is required for full Turing-complete behavior.
For full correspondence with a Turing machine, an additional command for rightward movement is required.
Tape traversal and attention control
At this point, we move away from biological emulation. Instead of controlling the current hippocampal cluster via a neural attentionFlag, we manage it through an explicit pointer - unique for the entire neural network - that references the currently active cluster:
NC* Brain::_hippo;
The _hippo pointer therefore plays the role of a tape head in the Turing-machine analogy. After attention is shifted to another cluster, that cluster activates its associated properties:
for (Link* link : _hippo->lUpIn) { link->_from.nIn.activate();}
From the variable names, it may appear that signals are propagated “in the reverse direction,” back to the source. This, however, is merely a naming convention resulting from the use of bidirectional links. In any sufficiently general mode of operation, one of the directions will inevitably appear atypical with respect to naming.
This operation — activating the properties of the current cluster — can be referred to as a context switch.
In addition to activating the new context, the model allows different policies regarding the remaining attention — namely, neurons that were active prior to the context switch. The context can either be cleared entirely or partially preserved by keeping LSTM-like clusters active. Both modes are supported by the model.
When counting characters a or b, LSTM clusters representing the corresponding counters retain their activation. In the demonstration network, the counters are optimized for ASCII output: 30 LSTM neurons store three decimal digits, while non-LSTM control neurons handle counter reset, increment operations, and console output.
Leftward traversal along the tape is performed via the shiftLeft() command and an associated cluster whose activation triggers this operation:
// before virtual layersif (_shiftLeft->nPrev.isActive()) shiftLeft();
If the “tape ends” (or a “zero symbol” is encountered), a special flag cluster _hippoLeftEnd is activated:
void Brain::shiftLeft() { if (!_hippo) { _hippoLeftEnd->nIn.activate(); return; } NC* left = _hippo->prevNC(); // obtained from temporal links (lTIn) if (!left) { _hippoLeftEnd->nIn.activate(); return; } _hippo = left; _activateMemory->nIn.activate();}
For the task of enumerating possible chess moves, however, traversal with context reset is more convenient.
For example, suppose the current board state has been memorized. Piece positions are stored in LSTM clusters as combinations of “square index — piece type” and are included in the memory record. We then move a piece, process and store the new board state, and subsequently want to return to the initial position in order to enumerate alternative moves. In this case, it is simplest to completely reset the current context and reactivate the original one.
Conceptually, this resembles returning from a function call and restoring the call stack. Accordingly, this variant of leftward traversal with context reset is called the return** operation**, invoked by the corresponding cluster:
if (_return->nIn.isActive()) { callReturn();}
This mechanism effectively implements a stack-based control flow on top of the hippocampal tape.
The callReturn() function is similar to shiftLeft(), except for the differences described above.
After the neural network resets the context and restores the previous one, that restored context also contains the neurons responsible for executing the traversal program. As a result, program execution continues from exactly the step at which the “stack was saved” (i.e., when memorizeCurrentState was invoked).
To prevent the network from looping along the same execution path, it is necessary to distinguish a function return from an initial invocation. This can be achieved by checking whether the _return cluster was active during the previous cycle:
_return->nPrev.isActive()
This serves as a simple branching condition distinguishing first-time execution from return paths. Other neurons can link to this cluster via temporal connections (linkTime) and adjust execution flow accordingly.
Chess neural network
The source code of the neural network also includes weights responsible for evaluating valid chess moves. This work continues the series of articles about Fully-Neural Chess Engine [11], [12].
Existing neural chess engines such as Leela Chess Zero use neural networks only to evaluate a single chess position. The enumeration of chess positions (generation of legal moves and construction of the move graph) is still performed by conventional C++ code.
The present work represents a step toward transferring this remaining C++ logic into the neural network itself. Subsequently, within the hybrid neural network approach, this model is intended to be combined with the neural network used by Lc0.
Under these assumptions, and in order to preserve computational efficiency, the enumeration of chess positions is currently somewhat restricted. For example, the detection of whether a king is left in check is planned to be delegated to Lc0. Only if this proves insufficient will such functionality be incorporated directly into the proposed neural network.
References
1) Graves et al. (2014) — Neural Turing Machines. Introduces a neural network controller with an external memory tape accessed by attentional read/write heads. https://arxiv.org/pdf/1410.5401 2) Graves et al. (2016) — Hybrid computing using a neural network with dynamic external memory (Differentiable Neural Computer). Extends the NTM with a larger external memory and more sophisticated read/write mechanisms (published in Nature). https://web.stanford.edu/class/psych209/Readings/GravesWayne16DNC.pdf 3) Weston et al. (2015) — Memory Networks. Proposes combining neural inference with a long-term external memory module for QA tasks (ICLR 2015). https://arxiv.org/pdf/1410.3916 4) Joulin & Mikolov (2015) — Inferring Algorithmic Patterns with Stack-Augmented RNNs. Uses an RNN augmented with a differentiable external stack (push/pop operations) to learn simple algorithms (NeurIPS 2015). https://arxiv.org/pdf/1503.01007 5) Grefenstette et al. (2015) — Learning to Transduce with Unbounded Memory. Introduces RNNs with differentiable stack, queue, and deque structures as external memory, improving generalization on formal language tasks (NeurIPS 2015). https://arxiv.org/abs/1506.02516 6) Kurach et al. (2016) — Neural Random-Access Machines. Investigates a neural model that manipulates pointers to an external random-access memory (tape) for algorithmic tasks (ICLR 2016). https://arxiv.org/abs/1511.06392 7) Das et al. (1992) — Learning Context-Free Grammars with an External Stack Memory. An early Neural Network Pushdown Automaton model: an RNN coupled to an external stack tape (Cognitive Science Society 1992). https://arxiv.org/pdf/2004.07623 8) Siegelmann & Sontag (1995) — On the Computational Power of Neural Nets. Theoretical result proving that a properly structured analog RNN can simulate a Universal Turing Machine (tape effectively encoded in network connectivity). https://binds.cs.umass.edu/papers/1995_Siegelmann_JComSysSci.pdf 9) Chung & Siegelmann (2021) — Turing Completeness of Bounded-Precision RNNs with Dynamic Memory. Demonstrates a growing-memory RNN that integrates the Turing machine tape as a stack of neurons inside the network (NeurIPS 2021). https://proceedings.neurips.cc/paper_files/paper/2021/file/ef452c63f81d0105dd4486f775adec81-Paper.pdf 10) Kozachuk (2026) — source code for this article with hippocampus model https://github.com/neurocod/hippocampus-Turing-machine 11) Kozachuk (2025) — “Hybrid Neural Networks Inside LLMs” https://www.linkedin.com/pulse/hybrid-neural-networks-inside-llms-konstantine-kozachuk-xquze/ and source code for it https://github.com/neurocod/ChessBoardNN/ 12) Kozachuk (2025) — “Hybrid neural networks, part 2” https://www.linkedin.com/pulse/hybrid-neural-networks-part-2-konstantine-kozachuk-omwwe/ and source code for it https://github.com/neurocod/llm-chess-hybrid