巴塞罗那超级计算中心(BSC)的官方存储库生物医学和西班牙语临床预审前的语言模型。
我们以Apache Licens 2.0发布了最佳模型,以鼓励在生物医学和临床领域开发西班牙NLP应用程序。
我们培训了两种型号,并通过以下链接在Huggingface的模型中心上提供它们:
此外,已经对长形式版本进行了培训,以便能够处理需要更大环境(例如临床编码)的任务。使用的语料库与以下相同。也可以在Hugginface上找到模型:
我们对命名实体识别(NER)任务的模型进行了微调,并在以下链接上使HuggingFace的模型中心上的最佳模型可用:
培训语料库由西班牙语的几个生物医学语料库组成,是从公共可用的语料库和爬网中收集的,以及从超过278K的临床文件和注释中收集的现实世界中的临床语料库。为了获得高质量的培训语料库,同时保留了临床语言的特质,清洁管道仅适用于生物医学语料库,使临床语料库尚未确定。本质上,使用的清洁操作是:
然后,生物医学语料库是连接的,并且已经应用了生物医学语料库中的全球重复数据删除。结果是约9100万令牌的临床语料库,生物医学语料库约为963m令牌。最终,将临床语料库与清洁的生物医学语料库串联,从而为西班牙语组成的西班牙人提供了中等大小的生物医学临床语料库。下表显示了单个清洁语料库的一些基本统计数据:
| 姓名 | 不,令牌 | 描述 |
|---|---|---|
| 医疗爬虫 | 903,558,136 | 属于西班牙生物医学和健康领域的3,000多个URL的爬行者。 |
| 临床病例杂项。 | 102,855,267 | 医疗内容的杂项,本质上是临床病例。请注意,临床病例报告是科学出版物,医生共享患者病例,并且与临床笔记或文件不同。 |
| EHR文件 | 95,267,20 | 收集了超过278K的临床文件,包括出院报告,临床课程注释和X射线报告,总计9100万个令牌。 https://huggingface.co/plantl-gob-es/longformer-base-4096-biomedical-clinical-es |
| Scielo | 60,007,289 | 用西班牙语撰写的出版物于2017年从西班牙Scielo服务器上爬行。 |
| Barr2_Background | 24,516,442 | 生物医学缩写识别和解决(BARR2),其中包含来自各种临床学科的西班牙临床案例研究部分。 |
| wikipedia_life_sciences | 13,890,501 | Wikipedia文章从04/01/2021爬行,Wikipedia api Python库从“ Ciencias_de_la_vida”类别开始,最多为5个子类别。然后将多个指向同一文章的链接丢弃,以避免重复内容。 |
| 专利 | 13,463,387 | Google在西班牙(西班牙)的医疗领域专利。专利JSON文件的可接受的代码(医疗域)为:“ A61B”,“ A61C”,“ A61F”,“ A61H”,“ A61K”,“ A61L”,“ A61M”,“ A61M”,“ A61B”,A61B“,” A61P”。 |
| EMEA | 5,377,448 | 从欧洲药品局PDF文件制成的平行语料库中提取的西班牙侧文档。 |
| mespen_medline | 4,166,077 | 西班牙方面的文章从一系列由生物医学科学文献组成的西班牙语 - 英语平行语料库中提取。并行资源的收集是从MedlinePlus源汇总的。 |
| PubMed | 1,858,966 | PubMed存储库的开放式文章于2017年爬行。 |
使用三个临床NER数据集,例如Pharmaconer,Cantemist和Ictusnet,对命名实体识别(NER)任务进行了微调。我们使用标准线性层以及生物标记模式将NER任务作为令牌分类问题。我们将我们的模型与一般域西班牙罗伯塔基本 - 基本 - 基本域(Bne)进行了比较,该模型支持西班牙姆伯特(Mert),特定于领域的英国模型生物伯特(Biobert)和基于连续培训的三个特定领域的模型,Mbert-Galén,xlm-r-r-galén和beto-galén。下表显示了获得的F1分数:
| 任务/模型 | BSC-BIO-ES | bsc-bio-ehr-es | XLM-R-Galén | beto-galén | Mbert-Galén | 姆伯特 | 生物Biobert | 罗伯塔 - 基本 - 巴恩 |
|---|---|---|---|---|---|---|---|---|
| 药剂师 | 0.8907 | 0.8913 | 0.8754 | 0.8537 | 0.8594 | 0.8671 | 0.8545 | 0.8474 |
| 孔子主义者 | 0.8220 | 0.8340 | 0.8078 | 0.8153 | 0.8168 | 0.8116 | 0.8070 | 0.7875 |
| Ictusnet | 0.8727 | 0.8756 | 0.8716 | 0.8498 | 0.8509 | 0.8631 | 0.8521 | 0.8677 |
下面的示例,显示如何预测实体在Pharmaconer数据集上微调的BSC-BIO-EHR-ES模型:
from transformers import AutoTokenizer , AutoModelForTokenClassification , pipeline
tokenizer = AutoTokenizer . from_pretrained ( "PlanTL-GOB-ES/bsc-bio-ehr-es-pharmaconer" )
model = AutoModelForTokenClassification . from_pretrained ( "PlanTL-GOB-ES/bsc-bio-ehr-es-pharmaconer" )
pipe = pipeline ( task = 'token-classification' , model = 'PlanTL-GOB-ES/bsc-bio-ehr-es-pharmaconer' )
sentence = 'Por el hallazgo de múltiples fracturas por estrés, se procedió a estudio en nuestras consultas, realizándose análisis con función renal, calcio sérico y urinario, calcio iónico, magnesio y PTH, que fueron normales.'
results = pipe ( sentence )
print ( results ) # Expected output with the predicted entities:
[
{'word': 'Ġcalcio', 'score': 0.9963880181312561, 'entity': 'B-NORMALIZABLES', 'index': 24, 'start': 137, 'end': 143}, {'word': 'Ġcalcio', 'score': 0.9965023398399353, 'entity': 'B-NORMALIZABLES', 'index': 29, 'start': 163, 'end': 169}, {'word': 'Ġmagnesio', 'score': 0.996299147605896, 'entity': 'B-NORMALIZABLES', 'index': 32, 'start': 178, 'end': 186}, {'word': 'ĠPTH', 'score': 0.9950509667396545, 'entity': 'B-PROTEINAS', 'index': 34, 'start': 189, 'end': 192}
]
首先,克隆项目:
git clone https://github.com/PlanTL-GOB-ES/lm-biomedical-clinical-es/blob/master/README.md
设置Python虚拟环境并激活它
python3.8 -m venv venv; source venv/bin/activate
在从项目主文件夹中运行以下行的虚拟环境中安装所有所需的Python软件包: pip install -r requirements.txt 。
最后,在项目主文件夹上运行以下命令: bash ner.sh [MODEL_NAME] [DATASET_NAME] [SEED] ,其中
[MODEL_NAME] :HuggingFace的模型名称您要使用的验证型号。[DATASET_NAME] :HuggingFace'DATASET用于使用的NER数据集的名称。可以根据要使用的数据集从“ Plantl-Gob-es/cantemist-ner”和“ Plantl-Gob-es/Pharmaconer”中选择。[SEED] :您要使用的种子。这允许再现相同的结果。 ner.sh脚本微调了应用线性分类头的NER任务的验证语言模型。默认情况下,对10个时期的微调运行,对每个时期的开发集进行了评估。在开发集中实现最佳性能的模型被选为最终模型,并在测试集上进行了评估。最佳训练的模型是将存储在类型的输出路径中存储./output/model-$model_name/dataset-$dataset_name/seed-$seed以及Checkpoints文件夹和张板数据(在tb Directory内部)。
例如,要微调Pharmaconer数据集中的BSC-BIO-EHR-ES语言模型,请运行命令:
bash ner.sh PlanTL-GOB-ES/bsc-bio-ehr-es PlanTL-GOB-ES/pharmaconer 42
如果您使用这些模型,请引用我们的工作:
@inproceedings{carrino-etal-2022-pretrained,
title = "Pretrained Biomedical Language Models for Clinical {NLP} in {S}panish",
author = "Carrino, Casimiro Pio and
Llop, Joan and
P{`a}mies, Marc and
Guti{'e}rrez-Fandi{~n}o, Asier and
Armengol-Estap{'e}, Jordi and
Silveira-Ocampo, Joaqu{'i}n and
Valencia, Alfonso and
Gonzalez-Agirre, Aitor and
Villegas, Marta",
booktitle = "Proceedings of the 21st Workshop on Biomedical Language Processing",
month = may,
year = "2022",
address = "Dublin, Ireland",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2022.bionlp-1.19",
doi = "10.18653/v1/2022.bionlp-1.19",
pages = "193--199",
abstract = "This work presents the first large-scale biomedical Spanish language models trained from scratch, using large biomedical corpora consisting of a total of 1.1B tokens and an EHR corpus of 95M tokens. We compared them against general-domain and other domain-specific models for Spanish on three clinical NER tasks. As main results, our models are superior across the NER tasks, rendering them more convenient for clinical NLP applications. Furthermore, our findings indicate that when enough data is available, pre-training from scratch is better than continual pre-training when tested on clinical tasks, raising an exciting research question about which approach is optimal. Our models and fine-tuning scripts are publicly available at HuggingFace and GitHub.",
}
该项目已获得Apache许可证的许可,版本2.0
版权(c)2021秘书处deestadodemitionizacióne inteligencia人工(Sedia)
这项工作是由西班牙国家秘书处在Plan-TL的框架内资助的数字化和人工智能(Sedia)。
此存储库中发表的模型旨在用于通才目的,可供第三方使用。这些模型可能具有偏见和/或任何其他不良扭曲。
当第三方使用这些模型中的任何一个(或使用基于这些模型的系统)向其他方部署或提供系统和/或服务时,他们应该注意到,他们有责任减轻其使用而导致的风险,并且无论如何,无论如何,在任何情况下都遵守适用的法规,包括有关使用人工智能使用的法规。
在任何情况下,任何模型的所有者都不应对这些模型的第三方使用所产生的任何结果承担任何责任。
Los Modelos Publicados en este repositorio tienen una finalidad gentrista yestánadisposicióndeterceros。 Estos Modelos Pueden Tener sesgos y/u otro tipo de deStoriones不可估量。
Cuando terceros desplieguen o proporcionen sistemas y/o servicios a otras partes usando alguno de estos modelos (o utilizando sistemas basados en estos modelos) o se conviertan en usuarios de los modelos, deben tener en cuenta que es su responsabilidad mitigar los riesgos derivados de su uso y,en todo caso,cumplir con la normativa aplicable,normato la normativa en Materia de uso de uso de inteligencia人工。
En ningún caso el propietario de los modelos (SEDIA – Secretaría de Estado de Digitalización e Inteligencia Artificial) ni el creador (BSC – Barcelona Supercomputing Center) serán responsables de los resultados derivados del uso que hagan terceros de estos modelos.