Code for paper "Multi-Granularity Neural Networks for Document-Level Relation Extraction".
- python=3.7
- CUDA=10.0
- torch=1.7.0
- stanford-parser=4.2.0
- pytorch_transformers=1.2.0
- numpy=1.16.0
- nltk=3.6.1
- tqdm=4.59.0
- matplotlib=3.0.2
- scikit_learn=0.21.2
- Download DocRED dataset
- Put the
train_annotated.json
,dev.json
,test.json
into the directorydata/
- Put the
vec.npy
,word2id.json
,rel2id.json
,ner2id.json
,char2id.json
into the directoryprepro_data/
>> python gen_data_tree.py
>> python gen_data.py # for Glove
>> python gen_data_bert.py # for BERT
For Golve:
>> python train.py --model_name MRGE --save_name checkpoint_MRGE --train_prefix dev_train --test_prefix dev_dev
For BERT:
>> python train_bert.py --model_name MRGE_bert --save_name checkpoint_MRGE_bert --train_prefix dev_train --test_prefix dev_dev
For Golve:
>> python test.py --model_name MRGE --save_name checkpoint_MRGE --train_prefix dev_train --test_prefix dev_test
For BERT:
>> python test_bert.py --model_name MRGE_bert --save_name checkpoint_MRGE_bert --train_prefix dev_train --test_prefix dev_test
You will get json file named result.json
, and then you can submit it to CodaLab.
We refer to the code of DocRED. Thanks for their contributions.