Oduwo commited on
Commit
2cff93e
·
verified ·
1 Parent(s): f74d2f2

Add sultan/BioM-ELECTRA-Large-SQuAD2 → nlp/biom-electra

Browse files
nlp/biom-electra/.gitattributes ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.arrow filter=lfs diff=lfs merge=lfs -text
10
+ *.ftz filter=lfs diff=lfs merge=lfs -text
11
+ *.joblib filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.pb filter=lfs diff=lfs merge=lfs -text
15
+ *.pt filter=lfs diff=lfs merge=lfs -text
16
+ *.pth filter=lfs diff=lfs merge=lfs -text
nlp/biom-electra/README.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BioM-Transformers: Building Large Biomedical Language Models with BERT, ALBERT and ELECTRA
2
+
3
+ # Abstract
4
+
5
+
6
+ The impact of design choices on the performance
7
+ of biomedical language models recently
8
+ has been a subject for investigation. In
9
+ this paper, we empirically study biomedical
10
+ domain adaptation with large transformer models
11
+ using different design choices. We evaluate
12
+ the performance of our pretrained models
13
+ against other existing biomedical language
14
+ models in the literature. Our results show that
15
+ we achieve state-of-the-art results on several
16
+ biomedical domain tasks despite using similar
17
+ or less computational cost compared to other
18
+ models in the literature. Our findings highlight
19
+ the significant effect of design choices on
20
+ improving the performance of biomedical language
21
+ models.
22
+
23
+ # Model Description
24
+
25
+ We fine-tuned BioM-ELECTRA-Large, which was pre-trained on PubMed Abstracts, on the SQuAD2.0 dataset. Fine-tuning the biomedical language model on the SQuAD dataset helps improve the score on the BioASQ challenge. If you plan to work with BioASQ or biomedical QA tasks, it's better to use this model over BioM-ELECTRA-Large. This model (TensorFlow version ) took the lead in the BioASQ9b-Factoid challenge (Batch 5) under the name of (UDEL-LAB2). To see the full details of BioASQ9B results, please check this link http://participants-area.bioasq.org/results/9b/phaseB/ ( you need to register).
26
+
27
+ Huggingface library doesn't implement Layer-Wise decay feature, which affects the performance on SQuAD task. The reported result of BioM-ELECTRA-SQuAD in our paper is 88.3 (F1) since we use ELECTRA open-source code with TF checkpoint, which uses Layer-Wise decay.
28
+
29
+
30
+ Training Script
31
+
32
+ ```python
33
+ run_qa.py --model_name_or_path sultan/BioM-ELECTRA-Large-Discriminator \
34
+ --dataset_name squad_v2 \
35
+ --do_train \
36
+ --do_eval \
37
+ --dataloader_num_workers 20 \
38
+ --preprocessing_num_workers 20 \
39
+ --version_2_with_negative \
40
+ --num_train_epochs 2 \
41
+ --learning_rate 5e-5 \
42
+ --max_seq_length 512 \
43
+ --doc_stride 128 \
44
+ --per_device_train_batch_size 8 \
45
+ --gradient_accumulation_steps 6 \
46
+ --per_device_eval_batch_size 128
47
+ --fp16 \
48
+ --fp16_opt_level O1 \
49
+ --logging_steps 50 \
50
+ --save_steps 1000 \
51
+ --overwrite_output_dir \
52
+ --output_dir out
53
+ ```
54
+
55
+ Evaluation results on SQuAD2.0 Dev Dataset
56
+ ```
57
+ exact = 84.33420365535248
58
+ f1 = 87.49354241889522
59
+ total = 11873
60
+ HasAns_exact = 80.43184885290148
61
+ HasAns_f1 = 86.75958656200127
62
+ HasAns_total = 5928
63
+ NoAns_exact = 88.22539949537426
64
+ NoAns_f1 = 88.22539949537426
65
+ NoAns_total = 5945
66
+ best_exact = 84.33420365535248
67
+ best_exact_thresh = 0.0
68
+ best_f1 = 87.49354241889522
69
+ best_f1_thresh = 0.0
70
+ epoch = 2.0
71
+
72
+ ```
73
+
74
+ To reproduce results in Google Colab:
75
+ - Make sure you have GPU enabled.
76
+ - Clone and install required libraries through this code
77
+
78
+ !git clone https://github.com/huggingface/transformers
79
+
80
+ !pip3 install -e transformers
81
+
82
+ !pip3 install sentencepiece
83
+
84
+ !pip3 install -r /content/transformers/examples/pytorch/question-answering/requirements.txt
85
+
86
+ - Run this python code:
87
+
88
+ ```python
89
+ python /content/transformers/examples/pytorch/question-answering/run_qa.py --model_name_or_path sultan/BioM-ELECTRA-Large-SQuAD2 \
90
+ --do_eval \
91
+ --version_2_with_negative \
92
+ --per_device_eval_batch_size 8 \
93
+ --dataset_name squad_v2 \
94
+ --overwrite_output_dir \
95
+ --fp16 \
96
+ --output_dir out
97
+ ```
98
+
99
+ - You don't need to download the SQuAD2 dataset. The code will download it from the HuggingFace datasets hub.
100
+
101
+ - Check our GitHub repo at https://github.com/salrowili/BioM-Transformers for TensorFlow and GluonNLP checkpoints.
102
+
103
+ - We added examples to fine-tune BioM-ELECTRA-Large on SQuAD and BioASQ7B using TensorFlow and TPU here https://github.com/salrowili/BioM-Transformers/tree/main/examples . In this example we show that we achieve 88.22 score in SQuAD2.0 since Tensor Flow code has Layer-wise decay feature.
104
+
105
+ # Acknowledgment
106
+
107
+ We would like to acknowledge the support we have from Tensorflow Research Cloud (TFRC) team to grant us access to TPUv3 units.
108
+
109
+ # Citation
110
+
111
+
112
+ ```bibtex
113
+ @inproceedings{alrowili-shanker-2021-biom,
114
+ title = "{B}io{M}-Transformers: Building Large Biomedical Language Models with {BERT}, {ALBERT} and {ELECTRA}",
115
+ author = "Alrowili, Sultan and
116
+ Shanker, Vijay",
117
+ booktitle = "Proceedings of the 20th Workshop on Biomedical Language Processing",
118
+ month = jun,
119
+ year = "2021",
120
+ address = "Online",
121
+ publisher = "Association for Computational Linguistics",
122
+ url = "https://www.aclweb.org/anthology/2021.bionlp-1.24",
123
+ pages = "221--227",
124
+ abstract = "The impact of design choices on the performance of biomedical language models recently has been a subject for investigation. In this paper, we empirically study biomedical domain adaptation with large transformer models using different design choices. We evaluate the performance of our pretrained models against other existing biomedical language models in the literature. Our results show that we achieve state-of-the-art results on several biomedical domain tasks despite using similar or less computational cost compared to other models in the literature. Our findings highlight the significant effect of design choices on improving the performance of biomedical language models.",
125
+ }
126
+ ```
nlp/biom-electra/config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ElectraForQuestionAnswering"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "embedding_size": 1024,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 1024,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 4096,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "electra",
15
+ "num_attention_heads": 16,
16
+ "num_hidden_layers": 24,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "summary_activation": "gelu",
20
+ "summary_last_dropout": 0.1,
21
+ "summary_type": "first",
22
+ "summary_use_proj": true,
23
+ "type_vocab_size": 2,
24
+ "vocab_size": 28895
25
+ }
nlp/biom-electra/eval_results.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ exact = 84.33420365535248
2
+ f1 = 87.49354241889522
3
+ total = 11873
4
+ HasAns_exact = 80.43184885290148
5
+ HasAns_f1 = 86.75958656200127
6
+ HasAns_total = 5928
7
+ NoAns_exact = 88.22539949537426
8
+ NoAns_f1 = 88.22539949537426
9
+ NoAns_total = 5945
10
+ best_exact = 84.33420365535248
11
+ best_exact_thresh = 0.0
12
+ best_f1 = 87.49354241889522
13
+ best_f1_thresh = 0.0
14
+ epoch = 2.0
nlp/biom-electra/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b99b3b75d0f568ee7ecf349424d4bccc10a52b58812d331bd17b980f7cd1e903
3
+ size 1329881942
nlp/biom-electra/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": null, "name_or_path": "/home/user/research/models/PubMedELECTRA/PubMedELECTRA-Large/", "do_basic_tokenize": true, "never_split": null}
nlp/biom-electra/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60987ef218637c4df0a179c8d68691e98a37d414524db4743d6b08aed459dc45
3
+ size 1903
nlp/biom-electra/vocab.txt ADDED
The diff for this file is too large to render. See raw diff