Abstract
Multiple extensions of Recurrent Neural Networks (RNNs) have been proposed recently to address the difficulty of storing information over long time periods. In this paper, we experiment with the capacity of Neural Turing Machines (NTMs) to deal with these long-term dependencies on well-balanced strings of parentheses. We show that not only does the NTM emulate a stack with its heads and learn an algorithm to recognize such words, but it is also capable of strongly generalizing to much longer sequences.
Introduction
Recurrent Neural Networks (RNNs) often struggle with long-term dependencies that require structural reasoning. A classic example is the membership problem for the Dyck language—determining if a string of parentheses is "well-balanced." Solving this requires maintaining a stack or a counter: incrementing for opening brackets and decrementing for closing ones. While standard neural networks typically fail when input lengths exceed training distributions, memory-augmented architectures like the Neural Turing Machine (NTM) offer a potential solution by learning algorithmic strategies rather than simple statistical patterns.
Neural Turing Machine Architecture
The researchers utilized an NTM consisting of a neural network "controller" and an external memory bank. To ensure the model relied solely on external memory for sequence tracking, they used a 1-layer feed-forward network with 100 units as the controller, deliberately avoiding recurrent units like LSTMs.
The memory bank contained 128 locations, each with a dimension of 20. One read head and one write head were employed, utilizing both content-based and location-based addressing to navigate the memory tape.
Experimental Setup
The model was trained on a binary classification task using synthetically generated Dyck words (positive examples) and unbalanced strings (negative examples). Crucially, training was restricted to short sequences of length less than 12 ($D_{<12}$). To evaluate "strong generalization," the NTM was then tested on sequences up to length 200, far exceeding its training exposure.
Results: Emergent Stack Emulation
The NTM demonstrated a remarkable ability to generalize, maintaining near-perfect performance on sequences up to 20 times longer than those seen during training. In contrast, an LSTM baseline's performance plummeted as sequence length increased.
Analysis of the NTM's internal operations revealed that it solved the problem by emulating a stack. Instead of complex memory writes, the model used the physical movement of its heads to perform computation. The read head position effectively served as a stack pointer: moving "up" the memory bank for opening parentheses and "down" for closing ones.
This algorithmic approach allowed the NTM to process sequences until it reached a physical limit—the 128-location memory bank. Performance only degraded when the nesting depth exceeded the available memory rows, representing an "overflow" rather than a failure of logic.
Conclusion
This work demonstrates that NTMs can move beyond pattern matching to discover underlying algorithmic rules. By emulating a stack through head movement, the NTM achieves strong generalization on structural tasks like Dyck language recognition. Future work may explore memory-restricted regimes to see if models can find alternative ways to represent complex data structures with even fewer structural priors.
Summary updated