Awesome Open Source
Awesome Open Source

End-To-End Memory Networks for Question Answering

This is an implementation of MemN2N model in Python for the bAbI question-answering tasks as shown in the Section 4 of the paper "End-To-End Memory Networks". It is based on Facebook's Matlab code.

Web-based Demo


  • Python 2.7
  • Numpy, Flask (only for web-based demo) can be installed via pip:
$ sudo pip install -r requirements.txt
  • bAbI dataset should be downloaded to data/tasks_1-20_v1-2:
$ wget -qO- | tar xvz -C data


  • To run on a single task, use with -t followed by task's id. For example,
python -t 1

The output will look like:

Using data from data/tasks_1-20_v1-2/en
Train and test for task 1 ...
1 | train error: 0.876116 | val error: 0.75
|===================================               | 71% 0.5s
  • To run on 20 tasks:
python -a
  • To train using all training data from 20 tasks, use the joint mode:
python -j

Question Answering Demo

  • In order to run the Web-based demo using the pretrained model memn2n_model.pklz in trained_model/, run:
python -m
  • Alternatively, you can try the console-based demo:
python -m -console
  • The pretrained model memn2n_model.pklz can be created by running:
python -m -train
  • To show all options, run python -m -h


See the results here.


Vinh Khuc

Future Plans

  • Port to TensorFlow/Keras
  • Support Python 3


Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (821,947
Machine Learning (37,806
Network (37,625
Question Answering (747