Pytorch implementation for EMNLP 2022 paper
A Sequential Flow Control Framework for Multi-hop Knowledge Base Question Answering
Minghui Xie, Chuzhan Hao, and Peng Zhang
Overall architecture of our proposed GFC model.
The schematic diagram of the GRU-inspired Flow Control Framework.
If you find this code useful in your research, please cite
@InProceedings{xie2022gfc,
author = {Minghui Xie and Chuzhan Hao and Peng Zhang},
title = {A Sequential Flow Control Framework for Multi-hop Knowledge Base Question Answering},
year = {2022},
booktitle = {Empirical Methods in Natural Language Processing (EMNLP)},
}
- pytorch>=1.2.0
- transformers
- tqdm
- nltk
- shutil
For all raw data files and their corresponding preprocessed data files, we have uploaded them to google drive
We use script files from EmbedKGQA to process completed dataset of WebQSP.
We use the dataset preprocessed by EmbedKGQA.
You should preprocess MetaQA using MetaQA/preprocess.py
We use dataset processed by NSM.
To ensure the reproducibility, we write demo.py for all 4 main tasks. You can use pretrained model checkpoints to reproduce the results. You should put the checkpoints files into corresponding path. The checkpoints files are uploaded to google drive.
Enter the directory GFC/WebQSP, then input the following command.
python demo_wsp.py --input_dir data/WebQSP --save_dir checkpoints/WebQSP --ckpt checkpoints/WebQSP/model_wqsp.pt
Enter the directory GFC/WebQSP_half, then input the following command
python demo_half.py --input_dir data/WebQSP_half --save_dir checkpoints/WebQSP_half --ckpt checkpoints/WebQSP_half/model_wqsp_half.pt
Enter the directory GFC/CWQ, then input the following command
python demo_cwq.py --input_dir data/CWQ --save_dir checkpoints/CWQ --ckpt checkpoints/CWQ/model_cwq.pt
Enter the directory GFC/CWQ, then input the following command
python demo_metaqa.py --input_dir data/Metaqa --save_dir checkpoints/Metaqa_ps --ckpt checkpoints/Metaqa/model_metaqa.pt
We train and test simultaneously. You should enter the corresponding directory of different datasets.
Enter the directory GFC/WebQSP, then input the following command.
python train_hop_final.py --input_dir data/WebQSP --save_dir checkpoints/WebQSP
Enter the directory GFC/WebQSP_half, then input the following command
python train_half_hop_final.py --input_dir data/WebQSP_half --save_dir checkpoints/WebQSP_half
Enter the directory GFC/CWQ, then input the following command.
python train_final.py --input_dir data/CWQ --save_dir checkpoints/CWQ --rev
Enter the directory GFC/MetaQA, then input the following command.
python train_final.py --glove_pt data/glove/glove.840B.300d.pickle --input_dir data/MetaQA --save_dir checkpoints/MetaQA
This repo is built upon the following work:
TransferNet: An Effective and Transparent Framework for Multi-hop Question Answering over Relation Graph. Jiaxin Shi, Shulin Cao, Lei Hou1∗, Juanzi Li1 and Hanwang Zhang. EMNLP 2021.
https://github.com/shijx12/TransferNet
Many thanks to the authors and developers!