Need help with NQG?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

129 Stars 26 Forks GNU General Public License v3.0 5 Commits 6 Opened issues


Code for the paper "Neural Question Generation from Text: A Preliminary Study"

Services available


Need anything else?

Contributors list

# 135,180
5 commits


This repository contains code for the paper "Neural Question Generation from Text: A Preliminary Study"

About this code

The experiments in the paper were done with an in-house deep learning tool. Therefore, we re-implement this with PyTorch as a reference.

This code only implements the setting

in the paper. Within 1 hour's training on Tesla P100, the
model achieves 12.78 BLEU-4 score on the dev set.

If you find this code useful in your research, please consider citing:

  title={Neural Question Generation from Text: A Preliminary Study},
  author={Zhou, Qingyu and Yang, Nan and Wei, Furu and Tan, Chuanqi and Bao, Hangbo and Zhou, Ming},
  journal={arXiv preprint arXiv:1704.01792},

How to run

Prepare the dataset and code

Make an experiment home folder for NQG data and code:

mkdir -p $NQG_HOME/code
mkdir -p $NQG_HOME/data
cd $NQG_HOME/code
git clone
cd $NQG_HOME/data
Put the data in the folder
and organize them as:
├── code
│   └── NQG
│       └── seq2seq_pt
└── data
    └── redistribute
        ├── QG
        │   ├── dev
        │   ├── test
        │   ├── test_sample
        │   └── train
        └── raw
Then collect vocabularies:
python $NQG_HOME/code/NQG/seq2seq_pt/ \
       $NQG_HOME/data/redistribute/QG/train/train.txt.source.txt \
       $NQG_HOME/data/redistribute/QG/train/ \
python $NQG_HOME/code/NQG/seq2seq_pt/ \
       $NQG_HOME/data/redistribute/QG/train/ \
python $NQG_HOME/code/NQG/seq2seq_pt/ \
       $NQG_HOME/data/redistribute/QG/train/train.txt.pos \
       $NQG_HOME/data/redistribute/QG/train/train.txt.ner \
       $NQG_HOME/data/redistribute/QG/train/ \
head -n 20000 $NQG_HOME/data/redistribute/QG/train/vocab.txt > $NQG_HOME/data/redistribute/QG/train/vocab.txt.20k

Setup the environment

Package Requirements:

nltk scipy numpy pytorch

PyTorch version: This code requires PyTorch v0.4.0.

Python version: This code requires Python3.

Warning: Older versions of NLTK have a bug in the PorterStemmer. Therefore, a fresh installation or update of NLTK is recommended.

A Docker image is also provided.

Docker image

docker pull magic282/pytorch:0.4.0

Run training

The file
is an example. Modify it according to your configuration.

Without Docker

bash $NQG_HOME/code/NQG/seq2seq_pt/ $NQG_HOME/data/redistribute/QG $NQG_HOME/code/NQG/seq2seq_pt

With Docker

nvidia-docker run --rm -ti -v $NQG_HOME:/workspace magic282/pytorch:0.4.0

Then inside the docker:

bash code/NQG/seq2seq_pt/ /workspace/data/redistribute/QG /workspace/code/NQG/seq2seq_pt

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.