Learning to Reason with Third Order Tensor Products

Imanol Schlag, Jürgen Schmidhuber

Introduction

While deep learning has revolutionized natural language processing, standard connectionist models like Long Short-Term Memory (LSTM) networks often struggle with systematic generalization. Humans can learn a rule (e.g., "Person X picks up Object Y") and immediately apply it to any person or object they know. In contrast, standard Recurrent Neural Networks (RNNs) frequently fail when asked to reason about a specific combination (e.g., "Mary picks up the milk") if that exact pairing was absent from the training data—even if the model saw Mary doing other things and other people picking up milk.

Researchers from the Swiss AI Lab IDSIA argue that this failure stems from a lack of combinatorial representations. Standard RNNs squash information into a single hidden vector, making it difficult to disentangle entities from the roles they play. To bridge the gap between the flexible learning of neural networks and the structured, rule-based reasoning of symbolic AI, they developed a new architecture: the TPR-RNN. By utilizing third-order Tensor Product Representations (TPRs), this model learns to deconstruct natural language into entities and relations stored in a 3D tensor, achieving state-of-the-art performance on reasoning tasks.

The TPR-RNN Architecture

The core innovation of the TPR-RNN is the use of a third-order tensor (essentially a "cube" of data) as its memory state. The architecture processes information through several key steps:

  1. Deconstruction: An input module takes a sentence and uses Multi-Layer Perceptrons (MLPs) to "deconstruct" it into three distinct components: a source entity ($e^{(1)}$), a relation ($r$), and a target entity ($e^{(2)}$).
  2. Tensor Product Representation (TPR): These components are bound together using a tensor product ($e^{(1)} \otimes r \otimes e^{(2)}$) and added to a global memory tensor $\mathbf{F}$. This effectively builds a dynamic knowledge graph where entities act as nodes and relations act as edges.
  3. Memory Operations: The model does not simply accumulate data; it performs specific, structured operations to maintain an accurate world state:
  4. Write: Stores a new association while optionally "unbinding" (removing) old, conflicting information.
  5. Move: Re-links an existing entity with a new relation (e.g., moving an object to a new room).
  6. Backlink: Automatically creates inverse relations (e.g., if "John is left of Mary," it infers "Mary is right of John").
Memory operations in the TPR-RNN

Unlike older TPR methods that required manual engineering of vectors, this system is trained entirely end-to-end via backpropagation. The model learns for itself how to represent concepts like "Mary," "the kitchen," and "is in" as vectors that interact systematically within the tensor.

Key Insights and Datasets

The memory tensor acts as a set of "Fast Weights"—context-specific weights that change rapidly with each input sentence. This allows the model to "program" its own internal logic on the fly based on the story it is reading. By using a third-order tensor, the model implicitly treats reasoning as a graph traversal problem. Retrieving an answer is equivalent to following a path from a query entity through a specific relation to find the target.

Furthermore, the model learns nearly orthogonal (independent) representations for different entities. This "disentanglement" is what allows it to swap "Mary" for "John" in a reasoning chain without breaking the underlying logic.

The authors evaluated the model on the bAbI Dataset, a benchmark of 20 synthetic tasks designed to test various types of reasoning (e.g., deduction, pathfinding, tracking moving objects). They also tested on a custom Systematic Generalization Subset of bAbI, where training and test data have large systematic differences (e.g., testing on novel entity-task combinations never seen during training).

Results: State-of-the-Art Reasoning

The TPR-RNN demonstrated exceptional performance across the board:

  • State-of-the-Art on bAbI: In the "all-tasks" setting (training one model on all 20 tasks simultaneously), the TPR-RNN achieved an average error of just 1.34%. This significantly outperforms previous memory-augmented networks like the Differentiable Neural Computer (DNC) at 12.8% and the Sparse DNC (SDNC) at 6.4%.
  • Robust Generalization: In the systematic generalization experiment, the TPR-RNN maintained high accuracy even for novel entity-task combinations, whereas previous state-of-the-art models (like the Recurrent Entity Network) saw their performance degrade significantly.
  • Superior Convergence: The TPR-RNN reached <5% error in just 48 hours of training. In contrast, the authors' implementation of the DNC was still struggling to converge after 7 days.
TPR-RNN vs DNC convergence

Limitations and Future Work

While powerful, the TPR-RNN has a few notable limitations:

  • Scalability: Storing a third-order tensor is computationally expensive. As the dimensionality ($d$) of the entity and relation vectors increases, the memory requirement grows by $O(d^3)$. This cubic scaling may limit the model's applicability to very large-scale knowledge bases.
  • Vanishing Gradients: Like all "Fast Weight" systems, multiplicative interactions can lead to unstable gradients. The authors successfully mitigated this using Layer Normalization, but it remains an inherent challenge of the architecture.
  • Sentence-Level Granularity: The current model processes information sentence-by-sentence. Moving to word-level reasoning—where the model must dynamically decide which words constitute an entity or relation—is a non-trivial next step for future research.

Summary updated

BibTeX
@inproceedings{schlag2018learning,
  author = {Imanol Schlag and Jürgen Schmidhuber},
  title = {{Learning to Reason with Third Order Tensor Products}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=B1ZctdW_br},
}
Figure