模型:

sultan/BioM-ELECTRA-Large-SQuAD2

英文

BioM-Transformers: 使用BERT、ALBERT和ELECTRA构建大规模生物医学语言模型

摘要

最近设计选择对生物医学语言模型性能的影响成为研究的主题。在本文中,我们通过经验研究不同设计选择下使用大型Transformer模型的生物医学领域自适应。我们将我们预训练模型与文献中其他现有的生物医学语言模型进行了性能评估。我们的结果表明,尽管与文献中其他模型相比使用的计算成本相似或更低,但我们在几个生物医学领域任务上取得了最新的成果。我们的发现突出了设计选择对提高生物医学语言模型性能的重要影响。

模型描述

我们对在PubMed摘要上预训练的BioM-ELECTRA-Large进行微调,使用了SQuAD2.0数据集对生物医学语言模型进行微调,以提高在BioASQ挑战中的得分。如果您计划处理BioASQ或生物医学问答任务,建议使用此模型而不是BioM-ELECTRA-Large。此模型(TensorFlow版本)在BioASQ9b-Factoid挑战赛(Batch 5)中以(UDEL-LAB2)名义取得了领先地位。要查看BioASQ9B结果的完整细节,请查看此链接 http://participants-area.bioasq.org/results/9b/phaseB/ (您需要注册)。

Huggingface库不实现层次递减功能,这会影响SQuAD任务的性能。我们论文中报告的BioM-ELECTRA-SQuAD结果为88.3(F1),因为我们使用具有Layer-Wise Decay功能的ELECTRA开源代码与TF checkpoint。

训练脚本

run_qa.py --model_name_or_path sultan/BioM-ELECTRA-Large-Discriminator \
--dataset_name squad_v2 \
--do_train \
--do_eval \
--dataloader_num_workers 20 \
--preprocessing_num_workers 20 \
--version_2_with_negative \
--num_train_epochs 2 \
--learning_rate 5e-5 \
--max_seq_length 512 \
--doc_stride 128 \
--per_device_train_batch_size 8 \
--gradient_accumulation_steps 6 \
--per_device_eval_batch_size 128 
--fp16 \
--fp16_opt_level O1 \
--logging_steps 50 \
--save_steps 1000 \
--overwrite_output_dir \
--output_dir out

在SQuAD2.0开发数据集上的评估结果

exact = 84.33420365535248
f1 = 87.49354241889522
total = 11873
HasAns_exact = 80.43184885290148
HasAns_f1 = 86.75958656200127
HasAns_total = 5928
NoAns_exact = 88.22539949537426
NoAns_f1 = 88.22539949537426
NoAns_total = 5945
best_exact = 84.33420365535248
best_exact_thresh = 0.0
best_f1 = 87.49354241889522
best_f1_thresh = 0.0
epoch = 2.0

要在Google Colab中复现结果:

  • 确保已启用GPU。
  • 通过以下代码克隆并安装所需的库

!git clone https://github.com/huggingface/transformers

!pip3 install -e transformers

!pip3 install sentencepiece

!pip3 install -r /content/transformers/examples/pytorch/question-answering/requirements.txt

  • 运行此Python代码:
python /content/transformers/examples/pytorch/question-answering/run_qa.py --model_name_or_path sultan/BioM-ELECTRA-Large-SQuAD2 \
--do_eval \
--version_2_with_negative \
--per_device_eval_batch_size 8 \
--dataset_name squad_v2 \
--overwrite_output_dir \
--fp16 \
--output_dir out
  • 您不需要下载SQuAD2数据集。代码将从HuggingFace数据集存储库中下载它。

  • 请查看我们的GitHub库中的TensorFlow和GluonNLP checkpoints。

  • 我们在这里的示例中添加了使用TensorFlow和TPU在SQuAD和BioASQ7B上微调BioM-ELECTRA-Large的示例 https://github.com/salrowili/BioM-Transformers/tree/main/examples 。在这个示例中,我们展示了我们在SQuAD2.0中取得的88.22分数,因为TensorFlow代码具有层级递减功能。

致谢

我们要感谢Tensorflow研究云(TFRC)团队的支持,给予我们访问TPUv3设备的权限。

引用

@inproceedings{alrowili-shanker-2021-biom,
title = "{B}io{M}-Transformers: Building Large Biomedical Language Models with {BERT}, {ALBERT} and {ELECTRA}",
author = "Alrowili, Sultan and
Shanker, Vijay",
booktitle = "Proceedings of the 20th Workshop on Biomedical Language Processing",
month = jun,
year = "2021",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2021.bionlp-1.24",
pages = "221--227",
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.",
}