README.md (5851B)
1 # DEGREE: A Data-Efficient Generation-Based Event Extraction Model 2 3 Code for our NAACL-2022 paper [DEGREE: A Data-Efficient Generation-Based Event Extraction Model](https://arxiv.org/abs/2108.12724). 4 5 ## Environment 6 - Python==3.8 7 - PyTorch==1.8.0 8 - transformers==3.1.0 9 - protobuf==3.17.3 10 - tensorboardx==2.4 11 - lxml==4.6.3 12 - beautifulsoup4==4.9.3 13 - bs4==0.0.1 14 - stanza==1.2 15 - sentencepiece==0.1.95 16 - ipdb==0.13.9 17 18 19 Note: 20 - If you meet issues reated to rust when installing transformers through pip, this 21 [website](https://programmerah.com/solved-transformers-install-error-error-cant-find-rust-compiler-50679/) might be helpful 22 23 - Or you can reference the `env_reference.yml` for clearer installation 24 25 ## Datasets 26 27 We support `ace05e`, `ace05ep`, and `ere`. 28 29 ### Preprocessing 30 Our preprocessing mainly adapts [OneIE's](https://blender.cs.illinois.edu/software/oneie/) released scripts with minor modifications. We deeply thank the contribution from the authors of the paper. 31 32 #### `ace05e` 33 1. Prepare data processed from [DyGIE++](https://github.com/dwadden/dygiepp#ace05-event) 34 2. Put the processed data into the folder `processed_data/ace05e_dygieppformat` 35 3. Run `./scripts/process_ace05e.sh` 36 37 #### `ace05ep` 38 1. Download ACE data from [LDC](https://catalog.ldc.upenn.edu/LDC2006T06) 39 2. Run `./scripts/process_ace05ep.sh` 40 41 #### `ere` 42 1. Download ERE English data from LDC, specifically, "LDC2015E29_DEFT_Rich_ERE_English_Training_Annotation_V2", "LDC2015E68_DEFT_Rich_ERE_English_Training_Annotation_R2_V2", "LDC2015E78_DEFT_Rich_ERE_Chinese_and_English_Parallel_Annotation_V2" 43 2. Collect all these data under a directory with such setup: 44 ``` 45 ERE 46 ├── LDC2015E29_DEFT_Rich_ERE_English_Training_Annotation_V2 47 │ ├── data 48 │ ├── docs 49 │ └── ... 50 ├── LDC2015E68_DEFT_Rich_ERE_English_Training_Annotation_R2_V2 51 │ ├── data 52 │ ├── docs 53 │ └── ... 54 └── LDC2015E78_DEFT_Rich_ERE_Chinese_and_English_Parallel_Annotation_V2 55 ├── data 56 ├── docs 57 └── ... 58 ``` 59 3. Run `./scripts/process_ere.sh` 60 61 The above scripts will generate processed data (including the full training set and the low-resourece sets) in `./process_data`. 62 63 ## Training 64 65 ### DEGREE (End2end) 66 67 Run `./scripts/train_degree_e2e.sh` or use the following commands: 68 69 Generate data for DEGREE (End2end) 70 ```Bash 71 python degree/generate_data_degree_e2e.py -c config/config_degree_e2e_ace05e.json 72 ``` 73 74 Train DEGREE (End2end) 75 ```Bash 76 python degree/train_degree_e2e.py -c config/config_degree_e2e_ace05e.json 77 ``` 78 79 The model will be stored at `./output/degree_e2e_ace05e/[timestamp]/best_model.mdl` in default. 80 81 ### DEGREE (ED) 82 83 Run `./scripts/train_degree_ed.sh` or use the following commands: 84 85 Generate data for DEGREE (ED) 86 ```Bash 87 python degree/generate_data_degree_ed.py -c config/config_degree_ed_ace05e.json 88 ``` 89 90 Train DEGREE (ED) 91 ```Bash 92 python degree/train_degree_ed.py -c config/config_degree_ed_ace05e.json 93 ``` 94 95 The model will be stored at `./output/degree_ed_ace05e/[timestamp]/best_model.mdl` in default. 96 97 ### DEGREE (EAE) 98 99 Run `./scripts/train_degree_eae.sh` or use the following commands: 100 101 Generate data for DEGREE (EAE) 102 ```Bash 103 python degree/generate_data_degree_eae.py -c config/config_degree_eae_ace05e.json 104 ``` 105 106 Train DEGREE (EAE) 107 108 ```Bash 109 python degree/train_degree_eae.py -c config/config_degree_eae_ace05e.json 110 ``` 111 112 The model will be stored at `./output/degree_eae_ace05e/[timestamp]/best_model.mdl` in default. 113 114 ## Evaluation 115 116 Evaluate DEGREE (End2end) on Event Extraction task 117 ```Bash 118 python degree/eval_end2endEE.py -c config/config_degree_e2e_ace05e.json -e [e2e_model] 119 ``` 120 121 Evaluate DEGREE (Pipe) on Event Extraction task 122 ```Bash 123 python degree/eval_pipelineEE.py -ced config/config_degree_ed_ace05e.json -ceae config/config_degree_eae_ace05e.json -ed [ed_model] -eae [eae_model] 124 ``` 125 126 Evaluate DEGREE (EAE) on Event Argument Extraction task (given gold triggers) 127 128 ```Bash 129 python degree/eval_pipelineEE.py -ceae config/config_degree_eae_ace05e.json -eae [eae_model] -g 130 ``` 131 132 ## Pre-Trained Models 133 134 | Dataset | Model | Model | Model | 135 | :------------- | :----------- | :------------- | :----------- | 136 | ace05e | [DEGREE (EAE)](https://drive.google.com/file/d/1KYI0zxtzoscTUqLJE79aAocORDg8Xuyv/view?usp=sharing) | [DEGREE (ED)](https://drive.google.com/file/d/1EEQRo2nWjop28GDTgNT8wng8yp4K_h4v/view?usp=sharing) | [DEGREE (E2E)](https://drive.google.com/file/d/1HxFIgWAgiQ1ZUHhea76oIwTXVn2rGove/view?usp=sharing) | 137 | ace05ep | [DEGREE (EAE)](https://drive.google.com/file/d/1RP-iFa0wpXlPM2_3N0x60CvGrJFBoVng/view?usp=sharing) | [DEGREE (ED)](https://drive.google.com/file/d/1x0Noa4ECwXBnpAKMaySGClE-UgWqPbb6/view?usp=sharing) | [DEGREE (E2E)](https://drive.google.com/file/d/16ovrzc4YbblA2vFtrzG6O6T10uk5VBwW/view?usp=sharing) | 138 | ere | [DEGREE (EAE)](https://drive.google.com/file/d/1AyiEp-0zt2Nb3wgmlovsV7wao-5P6AAb/view?usp=sharing) | [DEGREE (ED)](https://drive.google.com/file/d/1vNHeyt5Zqlj_M9b5hL2KuEGwQVg2mml3/view?usp=sharing) | [DEGREE (E2E)](https://drive.google.com/file/d/1i7Qw-qIxcC9pdzz7_H5O2LdIl0Oxo-Ob/view?usp=sharing) | 139 140 141 ## Citation 142 143 If you find that the code is useful in your research, please consider citing our paper. 144 145 @inproceedings{naacl2022degree, 146 author = {I-Hung Hsu and Kuan-Hao Huang and Elizabeth Boschee and Scott Miller and Prem Natarajan and Kai-Wei Chang and Nanyun Peng}, 147 title = {DEGREE: A Data-Efficient Generative Event Extraction Model}, 148 booktitle = {Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics (NAACL)}, 149 year = {2022}, 150 } 151 152 ## Contact 153 154 If you have any issue, please contact I-Hung Hsu at (ihunghsu@usc.edu) or 155 Kuan-Hao Huang at (khhuang@cs.ucla.edu).