LittleGuoKe / ConceptFERE

This code is the source code of our paper "Entity Concept-enhanced Few-shot Relation Extraction" in the ACL2021
MIT License
32 stars 9 forks source link

Entity Concept-enhanced Few-shot Relation Extraction

This code is the source code of our paper "Entity Concept-enhanced Few-shot Relation Extraction" in the ACL2021.

Requirements

 conda env create -f environment.yml

Checkpoint, Data files

Since the files are very large, they are placed on the Beihang cloud disk. If Beihang Cloud Disk cannot be downloaded normally, you can try to download it in Google Drive.

Training data

For the Details of training data, you can refer to FewRel.

Warning

Re-split the dataset

We divide the original training dataset into a new training dataset and a new validation dataset, the corresponding code is in the re_split_dataset module in fewshot_re_kit/utils.py, and the validation set in the original dataset is used as the new test dataset

Randomness

Due to the randomness of the experiments of the FSRE task, the results in the paper are the average of the results of multiple experiments

How the code is executed

Example:

python train_demo.py --trainN 5 --N 5 --K 1 --Q 1 --model pair --encoder bert --pair --hidden_size 768 --val_step 1000  --save_ckpt checkpoint/5way1shot.ConceptFere.pth.tar --batch_size 1 --grad_iter 4  --optim adam --fp16 --id_from MultiHeadAttentionAndBeyondWordEmbedding > 5way1shot.ConceptFere.log 2>&1

--trainN --N --K --Q: N-way-K-shot.

--model: specify the name of the model, such as proto, pair, etc.

--id_from: specify the source of the pre-trained concept embedding.

--grad_iter: in the case of insufficient GPU memory, set a small batchsize accumulate gradient every x iterations.

--fp16: use nvidia apex fp16.

Citing

If you used our code, please kindly cite our paper:

@inproceedings{yang-etal-2021-entity,
    title = "Entity Concept-enhanced Few-shot Relation Extraction",
    author = "Yang, Shan  and
      Zhang, Yongfei  and
      Niu, Guanglin  and
      Zhao, Qinghua  and
      Pu, Shiliang",
    booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 2: Short Papers)",
    month = aug,
    year = "2021",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2021.acl-short.124",
    doi = "10.18653/v1/2021.acl-short.124",
    pages = "987--991"
}