Skip to content

Latest commit

 

History

History
56 lines (49 loc) · 1.74 KB

README.md

File metadata and controls

56 lines (49 loc) · 1.74 KB

ZS-BERT

This repository contains the implementation of the NAACL 2021 paper "Towards Zero-Shot Relation Extraction with Attribute Representation Learning".

Dataset

You can download the datasets employed in our work from the following link:

and place them to the /data folder.

Structure

ZS-BERT/
├── model
    ├── model.py
    ├── data_helper.py
    ├── evaluation.py
    ├── train_wiki.py
    └── train_fewrel.py
└── resources/
    ├── property_list.html
└── data/
    ├── wiki_train_new.json
    └── fewrel_all.json

Requirements

python >= 3.6 torch >= 1.4.0 or simply run:

pip install -r requirements.txt

Train ZS-BERT

If you wish to train on the wiki dataset, run:

python3 train_wiki.py --seed 300 --n_unseen 10 --gamma 7.5 --alpha 0.4 --dist_func 'inner' --batch_size 4 --epochs 10

Otherwise to train on FewRel dataset, you can run:

python3 train_fewrel.py --seed 300 --n_unseen 10 --gamma 7.5 --alpha 0.4 --dist_func 'inner' --batch_size 4 --epochs 10

inside the /model folder.

Citing this paper

If you use the code, we appreciate it if you cite the following paper:

@inproceedings{chen2021zsbert,
  title={ZS-BERT: Towards Zero-Shot Relation Extraction with Attribute Representation Learning},
  author={Chih-Yao Chen and Cheng-Te Li},
  booktitle={Proceedings of 2021 Annual Conference of the North American Chapter of the Association for Computational Linguistics (NAACL-2021)},
  year={2021}
}