DER-Network is a neural network that read article, organize information about entities and answer questions about them, which is proposed on our paper "Dynamic Entity Representation with Max-pooling Improves Machine Reading." This repository contains code for traning new models and test them and some preprocessing for dataset. CNN QA dataset is needed for training and test.
CNN QA dataset is available by using download/preprocess scripts or downloding processed dataset directly. I recommend the latter way.
- RNN encodes each local context for each entity's mention in each sentence.
An entity representation as input of RNN is constructed from preceding contexts. - RNN encodes the placeholder's local context in a query.
- Attention mechanism based on the query's context merges all the local contexts of each entity by weighted mean.
- Probability of entity as the answer is calculated by dot-product of entity's context and query's context, and softmax.
These code will need:
-
Download CNN QA dataset and decompress it, following this.
-
Preprocess it.
- Add EOS tokens.
python -u scripts/add_eos.py dmqa_dir/cnn/questions
- Preprocess.
python -u scripts/preprocess_dataset.py -dir dmqa_dir/cnn/eos_questions -save data/dataset.json
- Add EOS tokens.
-
Train a model.
python -u scripts/train_model.py --per 500 -savem models_dir -mn modelname -b 2 -np 6 -fe 8 --load-corpus data/dataset.json --plus-valid 8 --plus-test 8
If you use anything in this repository, please cite:
Sosuke Kobayashi, Ran Tian, Naoaki Okazaki and Kentaro Inui. Dynamic Entity Representation with Max-pooling Improves Machine Reading. Proceedings of the NAACL HLT 2016, Jun. 2016.
@InProceedings{kobayashi2016dynamic,
title={Dynamic Entity Representation with Max-pooling Improves Machine Reading},
author={Sosuke Kobayashi and Ran Tian and Naoaki Okazaki and Kentaro Inui},
booktitle={Proceedings of the NAACL HLT 2016},
year={2016}
}