巴塞羅那超級計算中心(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.