Coder Social home page Coder Social logo

federaffo / graph-soft-counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shawn-dm/graph-soft-counter

0.0 0.0 0.0 362 KB

[ICLR 2022] GNN is a Counter? Revisiting GNN for Question Answering

License: MIT License

Shell 2.80% Python 85.82% Jupyter Notebook 11.38%

graph-soft-counter's Introduction

Graph Soft Counter

This repo contains PyTorch implementation for paper: GNN is a Counter? Revisiting GNN for Question Answering (ICLR 2022).

@inproceedings{gsc,
author = {Wang, Kuan and Zhang, Yuyu and Yang, Diyi and Song, Le and Qin, Tao},
title = {GNN is a Counter? Revisiting GNN for Question Answering},
booktitle = {International conference on learning representations (ICLR), 2022},
year = {2022}
}

Environment

You can just run the bash file 'setup.sh' or run the following commands to create a conda environment:

conda create -n gsc python=3.9
source activate gsc
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
conda install pyg -c pyg
conda install transformers

Dataset

We use the question answering datasets (CommonsenseQA, OpenBookQA) and the ConceptNet knowledge graph. We process the dataset following QA-GNN, and the preprocessing may take long. For your convenience, you can download all the processed data by

./download_preprocessed_data.sh

The resulting file structure will look like:

.
├── README.md
├── data/
    ├── cpnet/                 (prerocessed ConceptNet)
    ├── csqa/
        ├── train_rand_split.jsonl
        ├── dev_rand_split.jsonl
        ├── test_rand_split_no_answers.jsonl
        ├── statement/             (converted statements)
        ├── grounded/              (grounded entities)
        ├── graphs/                (extracted subgraphs)
        ├── ...
    └── obqa/

2. Train GSC

For CommonsenseQA, run

./run_gsc__csqa.sh

For OpenBookQA, run

./run_gsc__obqa.sh

As configured in these scripts, the model needs two types of input files

  • --{train,dev,test}_statements: preprocessed question statements in jsonl format. This is mainly loaded by load_input_tensors function in utils/data_utils.py.
  • --{train,dev,test}_adj: information of the KG subgraph extracted for each question. This is mainly loaded by load_sparse_adj_data_with_contextnode function in utils/data_utils.py. load_sparse_adj_data_with_contextnode Note: We find that training for OpenBookQA is unstable (e.g. best dev accuracy varies when using different seeds, different versions of the transformers / torch-geometric libraries, etc.), likely because the dataset is small. We suggest trying out different seeds. Another potential way to stabilize training is to initialize the model with one of the successful checkpoints provided below, e.g. by adding an argument --load_model_path obqa_model.pt.

3. Evaluate trained model

For CommonsenseQA, run

./eval_gsc__csqa.sh

For OpenBookQA, run

./eval_gsc__obqa.sh

Trained model examples

CommonsenseQA

Trained model In-house Dev acc. In-house Test acc.
RoBERTa-large + GSC [link] 0.7969 0.7478

OpenBookQA

Trained model Dev acc. Test acc.
RoBERTa-large + GSC [link] 0.6960 0.7060

Note: The models were trained and tested with HuggingFace transformers==2.0.1.

Acknowledgment

This repo is built upon the following works:

QA-GNN: Reasoning with Language Models and Knowledge Graphs for Question Answering. Michihiro Yasunaga and Hongyu Ren and Antoine Bosselut and Percy Liang and Jure Leskovec. NAACL 2021. 
https://github.com/michiyasunaga/qagnn

Scalable Multi-Hop Relational Reasoning for Knowledge-Aware Question Answering. Yanlin Feng*, Xinyue Chen*, Bill Yuchen Lin, Peifeng Wang, Jun Yan and Xiang Ren. EMNLP 2020. 
https://github.com/INK-USC/MHGRN

Many thanks to the authors and developers!

graph-soft-counter's People

Contributors

aianonymous avatar anonymoususe avatar federaffo 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.