HCRP
Code of paper Exploring Task Difficulty for Few-Shot Relation Extraction. https://arxiv.org/abs/2109.05473
Install / Use
/learn @hanjiale/HCRPREADME
HCRP
This is the implementation of our paper Exploring Task Difficulty for Few-Shot Relation Extraction.
Requirements
python 3.6PyTorch 1.7.0transformers 4.0.0numpy 1.19
Datasets
We experiment our model on two few-shot relation extraction datasets,
Please download data from the official links and put it under the ./data/.
Evaluation
Please download trained model from here and put it under the ./checkpoint/. To evaluate our model, use command
FewRel 1.0
python train.py \
--N 10 --K 1 --Q 1 --test_iter 10000\
--only_test True --load_ckpt "checkpoint/hcrp.pth.tar"
FewRel 2.0
python train.py \
--N 10 --K 1 --Q 1 --test_iter 10000\
--val val_pubmed --test val_pubmed --ispubmed True\
--only_test True --load_ckpt "checkpoint/hcrp-da.pth.tar"
Training
FewRel 1.0
To run our model, use command
python train.py
This will start the training and evaluating process of HCRP in a 10-way-1-shot setting. You can also use different args to start different process. Some of them are here:
train / val / test: Specify the training / validation / test set.trainN: N in N-way K-shot.trainNis the specific N in training process.N: N in N-way K-shot.K: K in N-way K-shot.Q: Sample Q query instances for each relation.
There are also many args for training (like batch_size and lr) and you can find more details in our codes.
FewRel 2.0
Use command
python train.py \
--val val_pubmed --test val_pubmed --ispubmed True --lamda 2.5
Results
FewRel 1.0
| | 5-way-1-shot | 5-way-5-shot | 10-way-1-shot | 10-way-5-shot | | --------------- | ----------- | ------------- | ------------ | ------------- | | Val | 90.90 | 93.22 | 84.11 | 87.79 | | Test | 93.76 | 95.66 | 89.95 | 92.10 |
FewRel 2.0
| | 5-way-1-shot | 5-way-5-shot | 10-way-1-shot | 10-way-5-shot | | --------------- | ----------- | ------------- | ------------ | ------------- | | Val | 78.90 | 83.22 | 68.99 | 74.45 | | Test | 76.34 | 83.03 | 63.77 | 72.94 |
Cite
If you use the code, please cite the following paper: "Exploring Task Difficulty for Few-Shot Relation Extraction" Jiale Han, Bo Cheng and Wei Lu. EMNLP (2021)
@inproceedings{han2021exploring,
title = {Exploring Task Difficulty for Few-Shot Relation Extraction},
author = {Han, Jiale and Cheng, Bo and Lu, Wei},
booktitle = {Proc. of EMNLP},
year={2021}
}
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
flutter-tutor
Flutter Learning Tutor Guide You are a friendly computer science tutor specializing in Flutter development. Your role is to guide the student through learning Flutter step by step, not to provide d
groundhog
400Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
workshop-rules
Materials used to teach the summer camp <Data Science for Kids>
