Learning to Reason with Third-Order Tensor Products

January 14, 2019 ยท View on GitHub

This repository contains the code accompanying the paper Learning to Reason with Third-Order Tensor Products published at NeurIPS, 2018. It encompasses our implementation of the Tensor Product Representation Recurrent Neural Network (TPR-RNN) applied to the bAbI tasks with SOTA results. A download script for a pretrained model is provided.

Requirements

  • Python 3
  • Tensorflow==1.11.0
  • Seaborn==0.9.0
  • Sklearn==0.0

Make sure to upgrade pip before installing the requirements.

pip3 install -r requirements.txt
sh download_data_and_model.sh

Usage

Run the pre-trained model.

python3 evaluation.py

Train from scratch. (Look at the train.py files for details)

python3 train.py

Generate small hierarchically clustered similarity matrices of a random set of sentences using different internal representations and the cosine similarity.

python3 cluster_analysis.py

Results

With this code we achieved the following error (rounded to two decimal places) when trained on all bAbI tasks simultaneously. In the appendix of the paper we provide a breakdown per task.

taskrun-0run-1run-2run-3run-4run-5run-6run-7bestmeanstd
all1.501.691.131.040.780.961.202.400.781.340.52

Citation

@inproceedings{schlag2018tprrnn,
  title={Learning to Reason with Third Order Tensor Products},
  author={Schlag, Imanol and Schmidhuber, J{\"u}rgen},
  booktitle={Advances in Neural Information Processing Systems},
  pages={10002--10013},
  year={2018}
}