Neural Turing Machines

A recurrent controller coupled to an external memory matrix through differentiable read and write operations.

Metadata

FieldValue
PaperNeural Turing Machines
AuthorsAlex Graves, Greg Wayne, Ivo Danihelka
Year2014
VenuearXiv preprint
arXiv1410.5401
Statusverified

Question

An ordinary RNN stores information in a fixed-size hidden state. That state must simultaneously represent the current computation, the history needed for later steps, and any temporary workspace. The paper asks whether a neural network can separate these roles by giving a recurrent controller an addressable external memory.

The design target is not simply a larger hidden state. It is a differentiable analogue of a computer with:

  • a controller that transforms observations into actions;
  • a memory matrix that stores a sequence of vectors;
  • a read head that retrieves content;
  • a write head that modifies memory;
  • soft attention weights that keep the whole operation differentiable.

This is an architecture question about where state lives. The recurrent controller remains sequential, while the memory is an explicit data structure with a larger and more structured capacity.

Main Claim

The paper argues that a neural network can learn simple algorithms such as copying, sorting, and associative recall when a recurrent controller is coupled to external memory with attention-based read and write operations.

The narrow claim is:

This does not establish reliable arbitrary computation, general-purpose reasoning, or deployment-quality long-context memory. The evidence is primarily a proof of architectural possibility on deliberately structured tasks.

Architecture Contract

ItemContract
Inputobservation sequence
Controllerrecurrent neural network
Memorymatrix with locations and width
Interfacedifferentiable read and write heads
Read outputweighted sum of memory rows
Write outputerase then add update to memory rows
Traininggradient descent through the complete controller-memory computation
Outputcontroller output and/or task-specific prediction

At time , the controller receives an observation and the previous read vector:

where is the controller state, contains interface parameters, and is the previous read result. The controller does not directly manipulate a discrete address. It emits continuous parameters that determine a soft access distribution.

Memory Representation

The external memory is a collection of row vectors:

The memory size is separated into two axes:

AxisMeaning
number of addressable locations
width of each stored vector

This separation is important. Increasing the controller hidden dimension changes the computation state, while increasing changes how many slots can be addressed. The two capacities are not interchangeable.

Addressing Mechanisms

Each head produces a weight vector satisfying:

The paper combines content-based addressing with location-based addressing.

Content Addressing

For a key , content similarity compares the key with each memory row. A cosine similarity is:

The content weights are obtained with a temperature or strength parameter :

Large makes the distribution sharper; small makes retrieval more diffuse. This is a soft form of content-addressable memory.

Location Addressing

Content matching alone cannot express operations such as “move one slot to the right.” The location path therefore transforms a previous weighting using a learned interpolation, circular shift, and sharpening step.

First interpolate content and previous weights:

where controls how much the head follows the new content match. A circular convolution shifts the weighting:

where is a normalized shift distribution. Finally, sharpening changes the concentration:

with . The address is therefore a differentiable composition of content lookup and relative movement.

Read Operation

Given a read weighting , the read vector is the weighted sum of memory rows:

In matrix notation:

The operation is differentiable with respect to both the weights and the memory contents. A useful consequence is that gradients can teach the controller not only what to store, but also which addressing pattern retrieves it later.

Write Operation

Writing uses an erase vector and an add vector . The erase step is:

The add step is:

where is the write weighting and is element-wise multiplication. The factor distributes the operation over locations, so a hard discrete write is replaced by a smooth write that can receive gradient signal.

The erase-add decomposition makes overwrite behavior explicit:

Controller and Memory Loop

One recurrent step can be read as:

  1. receive the current input and the previous read vector;
  2. update the controller state;
  3. emit interface parameters;
  4. compute read and write address weights;
  5. write to memory;
  6. read the new memory contents;
  7. expose the read vector to the controller and output head.

The computation is sequential across , but the memory interface is differentiable inside each step. This gives the model two distinct time scales: controller recurrence over steps and addressable storage over locations.

Why This Is an Architecture Paper

The paper changes the primitive state transition from:

to:

The memory is no longer an implicit by-product of a fixed hidden vector. It is an explicit module with an interface contract. That pattern reappears in differentiable data structures, retrieval systems, external-memory agents, and tool-using systems.

Evidence

Task familyWhat it probesInterpretation
Copywrite a sequence and reproduce it laterseparable storage and retrieval
Repeat copyretain and emit a sequence multiple timesread timing and controller state
Associative recallretrieve an item using a related cuecontent addressing
Priority sortstore items and emit them in learned orderinteraction between memory and controller
Simple sequence tasksuse input/output examples to infer a procedurealgorithm-like behavior under the tested distribution

The results should be read as architectural demonstrations. Synthetic tasks make the intended algorithmic structure visible, but they do not measure broad natural-language or scientific generalization.

Ablation and Reading Questions

QuestionWhy it matters
Is content addressing necessary?tests whether the model can retrieve by key rather than only by position
Is location addressing necessary?tests sequential traversal and relative movement
Does memory size scale independently from controller size?tests whether external storage creates a distinct capacity axis
Are tasks evaluated beyond training lengths?separates memorization of sequence lengths from algorithmic extrapolation
Is the write distribution sharp or diffuse?reveals whether the learned operation behaves like a discrete write
Is the controller recurrent state enough by itself?checks whether the external memory provides measurable benefit

For an implementation comparison, keep the following fixed: controller capacity, memory dimensions, training steps, task length distribution, initialization, and evaluation lengths. Otherwise an apparent memory benefit may be a capacity or optimization difference.

Complexity and Systems Trade-offs

For a memory with locations and width , a dense content lookup is approximately:

per head and step. The memory interface is therefore not free. It exchanges the compact hidden-state bottleneck of an RNN for explicit storage and address computation.

PropertyOrdinary RNNNTM-style model
persistent statehidden vectorhidden vector plus memory matrix
accessimplicit transitiondifferentiable read/write
capacity knobhidden widthmemory slots and width
long-range pathrepeated recurrent updatesrepeated updates plus address reuse
parallelism across timelimitedstill limited by controller loop
implementation riskhidden-state stabilityaddressing, write interference, memory initialization

The NTM does not solve sequential latency. It changes the representation and access path of state.

Limitations

  • Soft addressing can blur writes across multiple locations and create interference.
  • The controller still processes time steps recurrently, so training and inference retain sequential dependencies.
  • Synthetic algorithmic tasks are not evidence for general reasoning or reliable program induction.
  • Addressing distributions can be difficult to optimize, especially when a task needs nearly discrete pointer behavior.
  • Memory size and initialization are part of the effective model; changing them changes the task capacity.
  • A read vector is a weighted average, so exact retrieval can degrade when keys are similar or memory contents are noisy.
  • The architecture does not define persistence, provenance, or access control for real-world knowledge.
  • External memory does not by itself make a model factual, grounded, or safe.

Relation to Later Architectures

Later ideaShared problemDifference
LSTMpreserve information across stepsLSTM stores state in a gated fixed-size vector
Transformerselect relevant contextTransformer performs token-to-token attention without an explicit writable memory matrix
Perceiver IOroute information through a bottleneckPerceiver uses learned latent arrays and cross-attention rather than NTM write/erase dynamics
agent memoryretain and retrieve information across actionsagent memory adds persistence, provenance, and workflow policy outside the neural block
Mambamaintain a compact sequence stateselective state-space updates a recurrent state with input-dependent dynamics

The useful distinction is not “memory versus no memory.” Every sequence model has state somewhere. The distinction is whether state is an explicit addressable data structure, a fixed recurrent state, an attention context, or a system-level store.

Implementation Checklist

  • State the memory shape separately from controller hidden size.
  • Verify that read and write weights are normalized and non-negative.
  • Keep erase and add operations numerically stable and shape-checked.
  • Log address entropy or concentration when diagnosing diffuse reads and writes.
  • Test copy and associative recall with lengths outside the training range.
  • Compare against a controller-only baseline with matched parameter and training budgets.
  • Treat initialization as part of the reproducibility contract.
  • Separate in-memory state from persistent external artifacts when building a real system.

Why It Matters

NTM is a canonical paper for the question “what should a model remember, and how should it address that memory?” It makes the controller-memory boundary explicit before later systems rediscover variants of the same boundary through attention, retrieval, latent arrays, or agent memory.

The reusable pattern is:

For this wiki, read it after LSTM and before Attention Is All You Need when studying how sequence models represent and access history.

Connections