Giter VIP home page Giter VIP logo

redr's Introduction

ReDR

Code for the ACL 2019 paper Reinforced Dynamic Reasoning for Conversational Question Generation. This paper investigates a new task named Conversational Question Generation (CQG), which is to generate a question based on a passage and a conversation history (i.e., previous turns of question-answer pairs). We also propose a question generation approach named Reinforced Dynamic Reasoning (ReDR) network, which is based on the general encoder-decoder framework but incorporates a reasoning procedure in a dynamic manner to better understand what has been asked and what to ask next about the passage. Our code is based on the OpenNMT.

Required

All dependencies can be installed via:

pip install -r requirements.txt

Running the Script

1. Download the data.

The dataset we used for training and testing our model is the Conversational Question Answering (CoQA) dataset here. We download our data to a data/ folder.

We also have a pre-trained QA model to produce the F1 scores as the reward function. We download the model to a drqa_param/ folder.

2. Preprocess the data.

python cqg_preprocess.py

This is to split the data into conversation histories, rationales, targets and answers. The processed data consists of parallel source (src) and target (tgt) data containing one sentence per line with tokens separated by a space.

python preprocess.py -train_src data/coqa-cqg-src.train.txt -train_history data/coqa-cqg-history.train.txt -train_ans data/coqa-cqg-ans.train.txt -train_tgt data/coqa-cqg-tgt.train.txt -valid_src data/coqa-cqg-src.dev.txt -valid_history data/coqa-cqg-history.dev.txt -valid_ans data/coqa-cqg-ans.dev.txt -valid_tgt data/coqa-cqg-tgt.dev.txt -save_data data/coqa-cqg --share_vocab --dynamic_dict  

This is to transform the data to indices, which means the system doesn't need to touch the words themselves. After running the preprocessing, the following files are generated:

  • coqa-cqg.train.0.pt: serialized PyTorch file containing training data
  • coqa-cqg.valid.0.pt: serialized PyTorch file containing validation data
  • coqa-cqg.vocab.pt: serialized PyTorch file containing vocabulary data

3. Train and test the model of ReDR.

python train.py -data data/coqa-cqg -save_model out_model/
python generate.py  -src data/coqa-cqg-src.dev.txt -history data/coqa-cqg-history.dev.txt -tgt data/coqa-cqg-tgt.dev.txt -replace_unk -model out_model/_step_XXXXX.pt -output pred.txt

If you want to train on GPU, you need to set, as an example: CUDA_VISIBLE_DEVICES=1,3 -world_size 2 -gpu_ranks 0 1 to use (say) GPU 1 and 3 on this node only.

Reference

"Reinforced Dynamic Reasoning for Conversational Question Generation" Boyuan Pan, Hao Li, Ziyu Yao, Deng Cai, Huan Sun. ACL (2019)

@inproceedings{pan2019reinforced,
  title={Reinforced Dynamic Reasoning for Conversational Question Generation},
  author={Pan, Boyuan and Li, Hao and Yao, Ziyu and Cai, Deng and Sun, Huan},
  booktitle={Proceedings of the 57th Conference of the Association for Computational Linguistics},
  pages={2114--2124},
  year={2019}
}

redr's People

Contributors

byronpan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.