This is the code for the paper Multi-granularity Temporal Question Answering over Knowledge Graphs (Chen et al., ACL 2023).
MULTITQ is a large-scale dataset featuring ample relevant facts and multiple temporal granularities.
🤗Datasets Link: https://huggingface.co/datasets/chenziyang/MultiTQ
| Example questions | Answer |
|---|---|
| Who condemned Abhisit Vejjajiva in May 2010? | Thailand |
| Who was the first to visit the Middle East in 2008? | Frank Bainimarama |
| When did the Aam Aadmi Party first negotiated with Harish Rawat? | 2015-12-13 |
| Who expressed intent to engage in diplomatic cooperation with Ethiopia before Jun 25th, 2006? | China |
MultiTQ dataset can be found in ./data folder.
git clone https://github.com/czy1999/MultiTQ.git
cd ./MultiTQ/data
unzip Dataset.zip
cd ../MultiQA/models
unzip Models.zipbash setup_env.shThis creates a conda environment named multitq (Python 3.10),
installs PyTorch 2.1.2 (CUDA 12.1 wheel), and installs the rest of the
dependencies from requirements.txt. End-to-end verified on RTX 4090.
conda create -n multitq python=3.10 -y
conda activate multitq
pip install -r requirements.txtMultiQA runs in two stages: an NER preprocessing pass that adds entity/time
annotations to each question (output written to
data/MultiTQ/questions/processed_questions/), and the actual QA
training.
cd MultiQA
python ner_task.py # NER preprocessing (uses GPU if available)
python ./train_qa_model.py --model multiqa # Train MultiQAThe first run of ner_task.py downloads the
flair/ner-english-large
checkpoint (~1.4 GB). On an RTX 4090 + 22-core CPU, the full
preprocessing of train/dev/test (~500k questions) takes about an hour.
Please explore more argument options in train_qa_model.py.
The implementation is based on TempoQR in TempoQR: Temporal Question Reasoning over Knowledge Graphs and their code from https://github.com/cmavro/TempoQR. You can find more installation details there. We use TComplEx KG Embeddings as implemented in https://github.com/facebookresearch/tkbc.
If you find our method, code, or experimental setups useful, please cite our paper:
@inproceedings{chen-etal-2023-multi,
title = "Multi-granularity Temporal Question Answering over Knowledge Graphs",
author = "Chen, Ziyang and
Liao, Jinzhi and
Zhao, Xiang",
booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = jul,
year = "2023",
address = "Toronto, Canada",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.acl-long.637",
pages = "11378--11392",
}