Giter Club home page Giter Club logo

ecnu-sensemaker's Introduction

ECNU-SenseMaker (SemEval-2020 Task 4)

license

Source code for "ECNU-SenseMaker at SemEval-2020 Task 4: Leveraging Heterogeneous Knowledge Resources for Commonsense Validation and Explanation" (SemEval 2020).

Introduction

  • The overview of ECNU-SenseMaker.

    Overview

  • The KEmb module.

    kemb

Leaderboard

Subtask B (Top-5)

User Team Name Accuracy Rank
im0qianqian ECNU_ICA 95.0 1
jession hit_itnlp 94.8 2
Solomon Solomon 94.0 3
w-h-m NEUKG 93.8 3
xlx NUT 93.7 5

Subtask A (Top-5)

User Team Name Accuracy Rank
jession hit_itnlp 97.0 1
im0qianqian ECNU_ICA 96.7 2
xlx NUT 96.4 3
nlpx 96.4 3
Solomon Solomon 96.0 5

Usage

1. Envs and Dependencies

# create a conda envs
conda create -n semeval2020 python=3.6 ipython
conda activate semeval2020

# pytorch
conda install pytorch=1.6 cudatoolkit=10.2 -c pytorch

# transformers
pip install transformers==2.5.1

# pyG
CUDA=cu102
TORCH=1.6.0
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric

# sklearn
conda install scikit-learn=0.21.3

# bidict
pip install bidict==0.18.3

# nltk
conda install nltk

# tensorboard
conda install TensorBoard==1.15

# others
pip install future
pip install wordfreq

2. Download Data

  • Download the conceptnet5.zip from here, and unzip it to the conceptnet5/ directory.
  • Download the pre_weights.zip from here, and unzip it to the pre_weights/ directory.

The directory tree of ECNU-SenseMaker:

ECNU-SenseMaker
โ”œโ”€โ”€ commonsenseQA
โ”‚ย ย  โ”œโ”€โ”€ dev_rand_split_EASY.jsonl
โ”‚ย ย  โ”œโ”€โ”€ dev_rand_split.jsonl
โ”‚ย ย  โ”œโ”€โ”€ test_rand_split_no_answers.jsonl
โ”‚ย ย  โ”œโ”€โ”€ train_rand_split_EASY.jsonl
โ”‚ย ย  โ””โ”€โ”€ train_rand_split.jsonl
โ”œโ”€โ”€ conceptnet5
โ”‚ย ย  โ”œโ”€โ”€ numberbatch-en.txt
โ”‚ย ย  โ””โ”€โ”€ res_all.pickle
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ functions.py
โ”œโ”€โ”€ loss.py
โ”œโ”€โ”€ model_modify.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ optimizer.py
โ”œโ”€โ”€ pre_weights
โ”‚ย ย  โ”œโ”€โ”€ albert-xxlarge_model.bin
โ”‚ย ย  โ”œโ”€โ”€ bert-base-uncased_model.bin
โ”‚ย ย  โ”œโ”€โ”€ roberta-base_model.bin
โ”‚ย ย  โ””โ”€โ”€ roberta-large_model.bin
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ run_ensemble_model.py
โ”œโ”€โ”€ run_single_model.py
โ”œโ”€โ”€ SemEval2020-Task4-Commonsense-Validation-and-Explanation-master
โ”‚ย ย  โ”œโ”€โ”€ Training Data
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ subtaskA_answers_all.csv
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ subtaskA_data_all.csv
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ subtaskB_answers_all.csv
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ subtaskB_data_all.csv
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ subtaskC_answers_all.csv
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ subtaskC_data_all.csv
โ”‚ย ย  ...
|
โ””โ”€โ”€ utils
    โ”œโ”€โ”€ attentionUtils.py
    โ”œโ”€โ”€ commonsenseQAutils.py
    โ”œโ”€โ”€ ensembleUtils.py
    โ”œโ”€โ”€ getGraphUtils.py
    โ”œโ”€โ”€ gpu_mem_track.py
    โ”œโ”€โ”€ GraphUtils.py
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ MyDataset.py
    โ”œโ”€โ”€ semevalUtils.py
    โ”œโ”€โ”€ testUtils.py
    โ””โ”€โ”€ text_to_uri.py

3. Training and Evaluation

Run example on Subtask B with LM and KEGAT:

CUDA_VISIBLE_DEVICES='0' python -u -m run_single_model \
	--batch-size 8 \
	--test-batch-size 8 \
	--epochs 4 \
	--fine-tune-epochs 8 \
	--lr 0.001 \
	--fine-tune-lr 0.000005 \
	--adam-epsilon 0.000001 \
	--max-seq-length 128 \
	--subtask-id B \
	--with-lm \
	--with-kegat

Options of run_single_model.py:

usage: run_single_model.py [-h] [--batch-size N] [--test-batch-size N]
                           [--epochs N] [--fine-tune-epochs N] [--lr LR]
                           [--fine-tune-lr LR] [--adam-epsilon M]
                           [--max-seq-length N] [--subtask-id {A,B}]
                           [--with-lm] [--with-kegat] [--with-kemb]
                           [--no-cuda] [--seed S]

ECNU-SenseMaker single model

optional arguments:
  -h, --help            show this help message and exit
  --batch-size N        input batch size for training (default: 8)
  --test-batch-size N   input batch size for testing (default: 8)
  --epochs N            number of epochs to train (default: 4)
  --fine-tune-epochs N  number of fine-tune epochs to train (default: 8)
  --lr LR               learning rate (default: 0.001)
  --fine-tune-lr LR     fine-tune learning rate (default: 5e-06)
  --adam-epsilon M      Adam epsilon (default: 1e-06)
  --max-seq-length N    max length of sentences (default: 128)
  --subtask-id {A,B}    subtask A or B (default: B)
  --with-lm             Add Internal Sharing Mechanism (LM)
  --with-kegat          Add Knowledge-enhanced Graph Attention Network (KEGAT)
  --with-kemb           Add Knowledge-enhanced Embedding (KEmb)
  --no-cuda             disables CUDA training
  --seed S              random seed (default: 1)

References

Please cite this repository using the following reference:

@inproceedings{zhao-etal-2020-ecnu,
    title = "{ECNU}-{S}ense{M}aker at {S}em{E}val-2020 Task 4: Leveraging Heterogeneous Knowledge Resources for Commonsense Validation and Explanation",
    author = "Zhao, Qian  and
      Tao, Siyu  and
      Zhou, Jie  and
      Wang, Linlin  and
      Lin, Xin  and
      He, Liang",
    booktitle = "Proceedings of the Fourteenth Workshop on Semantic Evaluation",
    month = dec,
    year = "2020",
    address = "Barcelona (online)",
    publisher = "International Committee for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2020.semeval-1.48",
    pages = "401--410",
    abstract = "This paper describes our system for SemEval-2020 Task 4: Commonsense Validation and Explanation (Wang et al., 2020). We propose a novel Knowledge-enhanced Graph Attention Network (KEGAT) architecture for this task, leveraging heterogeneous knowledge from both the structured knowledge base (i.e. ConceptNet) and unstructured text to better improve the ability of a machine in commonsense understanding. This model has a powerful commonsense inference capability via utilizing suitable commonsense incorporation methods and upgraded data augmentation techniques. Besides, an internal sharing mechanism is cooperated to prohibit our model from insufficient and excessive reasoning for commonsense. As a result, this model performs quite well in both validation and explanation. For instance, it achieves state-of-the-art accuracy in the subtask called Commonsense Explanation (Multi-Choice). We officially name the system as ECNU-SenseMaker. Code is publicly available at https://github.com/ECNU-ICA/ECNU-SenseMaker.",
}

ecnu-sensemaker's People

Contributors

im0qianqian avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

ecnu-sensemaker's Issues

ๆฑ‚ๅคงไฝฌๅ›žๅคไธ€ไธ‹

็Žฐๆœ‰ๅฎŒๆˆ็š„ run_single_model.py ๆ–‡ไปถๆ˜ฏๅฆๅฏไปฅๅฎŒๆˆTask A็š„ๆŽจ็†ๅ‘ข๏ผŒๅคงไฝฌๅฏไปฅๆไพ›ไธ€ไธ‹้ข„่ฎญ็ปƒๆจกๅž‹ๅ—

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.