Giter VIP home page Giter VIP logo

salkg's Introduction

SalKG

arXiv PyTorch

This is the official PyTorch implementation of our NeurIPS 2021 paper

SalKG: Learning From Knowledge Graph Explanations for Commonsense Reasoning
Aaron Chan, Jiashu Xu*, Boyuan Long*, Soumya Sanyal, Tanish Gupta, Xiang Ren
NeurIPS 2021
*=equal contritbution

Please note that this is still under construction

TODO

  • fine occl
  • hybrid models
  • release dataset files
  • clean up configs

Requirements

  • python >= 3.6
  • pytorch >= 1.7.0

After you have pytorch (preferably with cuda support), please install other requirements by pip install -r requirements.txt

Data

First download csqa data and unzip. The default folder is data. Then download embeddings, unzip and put tzw.ent.np to data/mhgrn_data/cpnet/ and glove.transe.sgd.rel.npy to data/mhgrn_data/transe.

The final dataset folder should look like this

data/ # root dir
  csqa/
    path_embedding.pickle

  mhgrn_data/
    csqa/
      graph/      # extracted subgraphs
      paths/      # unpruned/pruned paths
      statement/  # csqa statement
    cpnet/
    transe/

Usage

We use neptune to track our experiment. Please set the api token and project id by

export NEPTUNE_API_TOKEN='<YOUR API KEY>'
export NEPTUNE_PROJ_NAME='<YOUR PROJECT NAME>'

The model weight would be saved to save with the subfolder name equal to the neptune id.

The pipeline to train SalKG models (for detail parameters that we suggest tuning, please see the bash scripts)

  1. run runs/build_qa.sh for generating indexed dataset required by nokg and kg model

    In the script, the flag --fine-occl would generate indexed dataset required by fine occl model

  2. run runs/qa.sh to run nokg and kg model

  3. run runs/save_target_saliency.sh with nokg / kg checkpoints to generate the model's saliency. Currently we suppport coarse occlusion and fine {occlusion, gradient} saliency

Results

The table below shows our results in three commonly used QA benchmarks: CommonsenseQA (CSQA), OpenbookQA (OBQA), and CODAH

For each column,

  • Green cells are the best performance
  • Blue cells are the second-best performance
  • Red cells arae the non-SalKG best performance

Results

Across the 3 datasets, we find that SalKG-Hybrid and SalKG-Coarse consistently outperform other models.

salkg's People

Contributors

cnut1648 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

salkg's Issues

There is no qa_model in your project

When I ran qa.sh, I checked out that that there was not 'qa_model' in your python project. I am confused. Maybe it's in another python file, but I really can't find it. I appreciate your response。

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.