Giter VIP home page Giter VIP logo

graph2seq-for-kgqg's Introduction

Graph2Seq-for-KGQG

Code & data accompanying the paper "Toward Subgraph Guided Knowledge Graph Question Generation with Graph Neural Networks".

Architecture

Model architecture.

Get started

Prerequisites

This code is written in python 3. You will need to install a few python packages in order to run the code. We recommend you to use virtualenv to manage your python packages and environments. Please take the following steps to create a python virtual environment.

  • If you have not installed virtualenv, install it with pip install virtualenv.
  • Create a virtual environment with virtualenv venv.
  • Activate the virtual environment with source venv/bin/activate.
  • Install the package requirements with pip install -r requirements.txt.

In order to compute the meteor score, please download the required data from here and put it under the src/core/evaluation/meteor/data folder.

Run the QG model

  • Download the pretrained GloVe word ebeddings glove.840B.300d.zip and move glove.840B.300d.txt to the data folder in this repo.
  • Download the data from here and move it to the data folder in this repo.
  • Cd into the src folder
  • Run the QG model and report the performance
        python main.py -config config/mhqg-wq/graph2seq.yml
        python main.py -config config/mhqg-pq/graph2seq.yml
    
  • You can finetune the above trained QG model using RL by running the following command:
        python main.py -config config/mhqg-wq/rl_graph2seq.yml
        python main.py -config config/mhqg-pq/rl_graph2seq.yml
    
  • You can find the output data in the out_dir folder specified in the config file.

Reference

If you found this code useful, please consider citing the following paper:

Chen, Yu, Lingfei Wu, and Mohammed J. Zaki. "Toward Subgraph Guided Knowledge Graph Question Generation with Graph Neural Networks." arXiv preprint arXiv:2004.06015 (2020).

@article{chen2020toward,
  title={Toward Subgraph Guided Knowledge Graph Question Generation with Graph Neural Networks},
  author={Chen, Yu and Wu, Lingfei and Zaki, Mohammed J.},
  journal={arXiv preprint arXiv:2004.06015},
  year={2020}
}

graph2seq-for-kgqg's People

Contributors

hugochan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

graph2seq-for-kgqg's Issues

Exception: Directory already exists: ../out/mhqg-wq/graph2seq

In fact, the directory doesn't exist. I don't know why.

Traceback (most recent call last):
File "./src/main.py", line 144, in
main(config)
File "./src/main.py", line 23, in main
model = ModelHandler(config)
File "/home/Graph2Seq-for-KGQG/src/core/model_handler.py", line 45, in init
self.logger = DummyLogger(config, dirname=config['out_dir'], pretrained=config['pretrained'])
File "/home/Graph2Seq-for-KGQG/src/core/utils/logger.py", line 17, in init
raise Exception('Directory already exists: {}'.format(dirname))
Exception: Directory already exists: ../out/mhqg-wq/graph2seq

Test Trained Model

Is there a way to test the trained model without performing the training again and evaluating the model?

I used the following command for training:
python main.py -config config/mhqg-wq/graph2seq.yml

Now I need to use this trained model to do some predictions on a new file, Is there a way to do that given the current code?

how to obtain the datasets?

I notice that some scripts are provided in src/scripts, and they seem to be related to data preprocessing.

Could you please explain how can I get your datasets from freebase and WebQuestionsSP/CWQ?

ram out of memory

When I use colab to run this project, I have met the problem of ram out of memory. This problem happens during the 30th to 40th epoch. When this problem happens, the training stops without raising exception and the model can not reach the test part.
Have you ever net this problem? And how can I solve it?

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.