Code Monkey home page Code Monkey logo

discos-commonsense's Introduction

DISCOS-commonsense

This is the github repo for The Web Conference (WWW) 2021 paper DISCOS: Bridging the Gap between Discourse Knowledge and Commonsense Knowledge.

How to train the Commonsense Knowledge Graph Population (CKGP) model

Here is the instruction for learning the CKGP model. We use the filtered graph as introduced in Section 5.1.1 for this experiment.

First, git clone this repo, and then download the prepared aligned graph from here. The data/graph_cache folder contains the data that can be directly used for training and testing. The data/graph_raw_data is the graph file that we got after aligning ATOMIC and ASER, with pre-defined negative edges for the CKGP task. The data/infer_candidates folder contains the candidate (h, r, t) tuples to be scored by our BertSAGE model.

Next install dependencies. Recommended python version is 3.8+.

pip install -r requirements.txt

Note that to load the files in data/graph_cache requires the same dependencies as in the requirements.txt file. E.g., you need to install the transformers package with version 3.4.0.

Next train the BertSAGE model. For example here is the command to train with the oReact relation:

python -u BertSAGE/train.py --model graphsage \
    --load_edge_types ASER \
    --neg_prop 1 \
    --graph_cach_path data/graph_cache/neg_{}_{}_{}.pickle \
    --negative_sample prepared_neg \
    --file_path data/graph_raw_data/G_aser_oReact_1hop_thresh_100_neg_other_20_inv_10.pickle

For other relations, you could find the corresponding .pickle file from data folder.

For the inference part, you could run after training:

python -u BertSAGE/infer.py --gpu 0 --model graphsage \
    --model_path models/G_aser_oReact_1hop_thresh_100_neg_other_20_inv_10/graphsage_best_bert_bs64_opt_SGD_lr0.01_decay0.8_500_layer1_neighnum_4_graph_ASER_acc.pth \
    --infer_path data/infer_candidates/G_aser_oReact_1hop_thresh_100_neg_other_20_inv_10.npy \
    --graph_cach_path data/graph_cache/neg_prepared_neg_ASER_G_aser_oReact_1hop_thresh_100_neg_other_20_inv_10.pickle

The Acquired Knowledge Graph DISCOS-ATOMIC

By populating the knowledge in ATOMIC to the whole ASER, we can acquire a large-scale ATOMIC-like knowledge graph by selecting the tuples scored by BertSAGE over 0.5. Also, we present the acquisition results of DISCOS under the setting of COMET, i.e., given h and r to generate t. The new knowledge graph can be downloaded here.

The 3.4M if-then knowledge is populated using the whole graph of ASER-core, without the neighbor filtering. You may find the processed training graph and inference candidates here.

discos-commonsense's People

Contributors

tqfang avatar

Watchers

 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.