Coder Social home page Coder Social logo

blackhandlyh / cronkgqa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apoorvumang/cronkgqa

0.0 1.0 0.0 41.09 MB

ACL 2021: Question Answering over Temporal Knowledge Graphs

License: MIT License

Python 36.73% Shell 0.06% Jupyter Notebook 63.21%

cronkgqa's Introduction

CronKGQA

This is the code for our ACL 2021 paper Question Answering over Temporal Knowledge Graphs

Installation

Clone and create a conda environment

git clone [email protected]:apoorvumang/CronKGQA.git
cd CronKGQA
conda create --prefix ./cronkgqa_env python=3.8
conda activate ./cronkgqa_env

We use TComplEx KG Embeddings as proposed in Tensor Decompositions for temporal knowledge base completion. We use a slightly modified version of their code from https://github.com/facebookresearch/tkbc

Install tkbc requirements and setup tkbc

conda install --file requirements_tkbc.txt -c pytorch
python setup_tkbc.py install

Install CronKGQA requirements

conda install --file requirements.txt -c conda-forge

Dataset and pretrained models download

Download and unzip data.zip and models.zip in the root directory.

Drive: https://drive.google.com/drive/folders/15L4bpGEvCCp7Kuz6xJOFBQFzQGWKJ9rL?usp=sharing, or use gdown

gdown https://drive.google.com/uc\?id\=1wilPf3qohD-6156Daaz5M6GRuJiRP3P4
gdown https://drive.google.com/uc\?id\=18w_aPl-oLfWnTLnoMnTU9Pm4El1T9wkB
unzip -q data.zip && unzip -q models.zip
rm data.zip && rm models.zip

Try out pretrained model

Run a jupyter notebook in the root folder. Make sure to activate the correct environment before running the notebook

The notebook cronkgqa_testing.ipynb can be used to test a model's responses to any textual question, provided you give the list of entities and times in the question as well - this is needed since perfect entity linking is assumed. You can explore the dataset for questions which have entity annotation and modify those questions. You can also make a reverse dict of data/wikidata_big/kg/wd_id2entity_text.txt and search for wikidata ids of an entity that you want.

Running the code

Finally you can run training of QA model using these trained tkbc embeddings. embedkgqa model = cronkgqa (will fix naming etc. soon)

 CUDA_VISIBLE_DEVICES=1 python -W ignore ./train_qa_model.py --frozen 1 --eval_k 1 --max_epochs 200 \
 --lr 0.00002 --batch_size 250 --mode train --tkbc_model_file tcomplex_17dec.ckpt \
 --dataset wikidata_big --valid_freq 3 --model embedkgqa --valid_batch_size 50  \
 --save_to temp --lm_frozen 1 --eval_split valid

Evaluating the pretrained model (CronKGQA):

 CUDA_VISIBLE_DEVICES=1 python -W ignore ./train_qa_model.py \
--mode eval --tkbc_model_file tcomplex_17dec.ckpt \
--dataset wikidata_big --model embedkgqa --valid_batch_size 50  \
--load_from cronkgqa_29may --eval_split test

Please explore the qa_models.py file for other models, you can change the model by providing the --model parameter.

How to cite

If you used our work or found it helpful, please use the following citation:

@inproceedings{saxena2021cronkgqa,
  title={Question Answering over Temporal Knowledge Graphs},
  author={Saxena, Apoorv and Chakrabarti, Soumen and Talukdar, Partha},
  booktitle={Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics},
  year={2021}
}

cronkgqa's People

Contributors

apoorvumang avatar theartpiece avatar

Watchers

James Cloos 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.