ccasimiro commited on
Commit
aaef8c5
1 Parent(s): df0c2c6

Upload model

Browse files
Files changed (11) hide show
  1. .gitattributes +1 -0
  2. README.md +180 -0
  3. args.json +28 -0
  4. config.json +25 -0
  5. dict.txt +0 -0
  6. merges.txt +0 -0
  7. process.log +8 -0
  8. pytorch_model.bin +3 -0
  9. special_tokens_map.json +1 -0
  10. tokenizer_config.json +1 -0
  11. vocab.json +0 -0
.gitattributes CHANGED
@@ -26,3 +26,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
26
  *.zip filter=lfs diff=lfs merge=lfs -text
27
  *.zstandard filter=lfs diff=lfs merge=lfs -text
28
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
26
  *.zip filter=lfs diff=lfs merge=lfs -text
27
  *.zstandard filter=lfs diff=lfs merge=lfs -text
28
  *tfevents* filter=lfs diff=lfs merge=lfs -text
29
+ pytorch_model.bin filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,183 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - es
4
+ tags:
5
+ - biomedical
6
+ - clinical
7
+ - spanish
8
  license: apache-2.0
9
+ metrics:
10
+ - ppl
11
+ widget:
12
+ - text: "El único antecedente personal a reseñar era la <mask> arterial."
13
+ - text: "Las radiologías óseas de cuerpo entero no detectan alteraciones <mask>, ni alteraciones vertebrales."
14
+ - text: "En el <mask> toraco-abdómino-pélvico no se encontraron hallazgos patológicos de interés."
15
  ---
16
+
17
+ # Biomedical-clinical language model for Spanish
18
+ Biomedical pretrained language model for Spanish. For more details about the corpus, the pretraining and the evaluation, check the official [repository](https://github.com/PlanTL-GOB-ES/lm-biomedical-clinical-es) and read our [preprint](https://arxiv.org/abs/2109.03570) "_Carrino, C. P., Armengol-Estapé, J., Gutiérrez-Fandiño, A., Llop-Palao, J., Pàmies, M., Gonzalez-Agirre, A., & Villegas, M. (2021). Biomedical and Clinical Language Models for Spanish: On the Benefits of Domain-Specific Pretraining in a Mid-Resource Scenario._".
19
+
20
+ ## Tokenization and model pretraining
21
+ This model is a [RoBERTa-based](https://github.com/pytorch/fairseq/tree/master/examples/roberta) model trained on a
22
+ **biomedical-clinical** corpus in Spanish collected from several sources (see next section).
23
+ The training corpus has been tokenized using a byte version of [Byte-Pair Encoding (BPE)](https://github.com/openai/gpt-2)
24
+ used in the original [RoBERTA](https://github.com/pytorch/fairseq/tree/master/examples/roberta) model with a vocabulary size of 52,000 tokens. The pretraining consists of a masked language model training at the subword level following the approach employed for the RoBERTa base model with the same hyperparameters as in the original work. The training lasted a total of 48 hours with 16 NVIDIA V100 GPUs of 16GB DDRAM, using Adam optimizer with a peak learning rate of 0.0005 and an effective batch size of 2,048 sentences.
25
+
26
+ ## Training corpora and preprocessing
27
+
28
+ The training corpus is composed of several biomedical corpora in Spanish, collected from publicly available corpora and crawlers, and a real-world clinical corpus collected from more than 278K clinical documents and notes. To obtain a high-quality training corpus while retaining the idiosyncrasies of the clinical language, a cleaning pipeline has been applied only to the biomedical corpora, keeping the clinical corpus uncleaned. Essentially, the cleaning operations used are:
29
+
30
+ - data parsing in different formats
31
+ - sentence splitting
32
+ - language detection
33
+ - filtering of ill-formed sentences
34
+ - deduplication of repetitive contents
35
+ - keep the original document boundaries
36
+
37
+ Then, the biomedical corpora are concatenated and further global deduplication among the biomedical corpora have been applied.
38
+ Eventually, the clinical corpus is concatenated to the cleaned biomedical corpus resulting in a medium-size biomedical-clinical corpus for Spanish composed of more than 1B tokens. The table below shows some basic statistics of the individual cleaned corpora:
39
+
40
+
41
+ | Name | No. tokens | Description |
42
+ |-----------------------------------------------------------------------------------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
43
+ | [Medical crawler](https://zenodo.org/record/4561970) | 745,705,946 | Crawler of more than 3,000 URLs belonging to Spanish biomedical and health domains. |
44
+ | Clinical cases misc. | 102,855,267 | A miscellany of medical content, essentially clinical cases. Note that a clinical case report is a scientific publication where medical practitioners share patient cases and it is different from a clinical note or document. |
45
+ | Clinical notes/documents | 91,250,080 | Collection of more than 278K clinical documents, including discharge reports, clinical course notes and X-ray reports, for a total of 91M tokens. |
46
+ | [Scielo](https://github.com/PlanTL-GOB-ES/SciELO-Spain-Crawler) | 60,007,289 | Publications written in Spanish crawled from the Spanish SciELO server in 2017. |
47
+ | [BARR2_background](https://temu.bsc.es/BARR2/downloads/background_set.raw_text.tar.bz2) | 24,516,442 | Biomedical Abbreviation Recognition and Resolution (BARR2) containing Spanish clinical case study sections from a variety of clinical disciplines. |
48
+ | Wikipedia_life_sciences | 13,890,501 | Wikipedia articles crawled 04/01/2021 with the [Wikipedia API python library](https://pypi.org/project/Wikipedia-API/) starting from the "Ciencias\_de\_la\_vida" category up to a maximum of 5 subcategories. Multiple links to the same articles are then discarded to avoid repeating content. |
49
+ | Patents | 13,463,387 | Google Patent in Medical Domain for Spain (Spanish). The accepted codes (Medical Domain) for Json files of patents are: "A61B", "A61C","A61F", "A61H", "A61K", "A61L","A61M", "A61B", "A61P". |
50
+ | [EMEA](http://opus.nlpl.eu/download.php?f=EMEA/v3/moses/en-es.txt.zip) | 5,377,448 | Spanish-side documents extracted from parallel corpora made out of PDF documents from the European Medicines Agency. |
51
+ | [mespen_Medline](https://zenodo.org/record/3562536#.YTt1fH2xXbR) | 4,166,077 | Spanish-side articles extracted from a collection of Spanish-English parallel corpus consisting of biomedical scientific literature. The collection of parallel resources are aggregated from the MedlinePlus source. |
52
+ | PubMed | 1,858,966 | Open-access articles from the PubMed repository crawled in 2017. |
53
+
54
+
55
+
56
+ ## Evaluation and results
57
+
58
+ The model has been evaluated on the Named Entity Recognition (NER) using the following datasets:
59
+
60
+ - [PharmaCoNER](https://zenodo.org/record/4270158): is a track on chemical and drug mention recognition from Spanish medical texts (for more info see: https://temu.bsc.es/pharmaconer/).
61
+
62
+ - [CANTEMIST](https://zenodo.org/record/3978041#.YTt5qH2xXbQ): is a shared task specifically focusing on named entity recognition of tumor morphology, in Spanish (for more info see: https://zenodo.org/record/3978041#.YTt5qH2xXbQ).
63
+
64
+ - ICTUSnet: consists of 1,006 hospital discharge reports of patients admitted for stroke from 18 different Spanish hospitals. It contains more than 79,000 annotations for 51 different kinds of variables.
65
+
66
+ The evaluation results are compared against the [mBERT](https://huggingface.co/bert-base-multilingual-cased) and [BETO](https://huggingface.co/dccuchile/bert-base-spanish-wwm-cased) models:
67
+
68
+ | F1 - Precision - Recall | roberta-base-biomedical-clinical-es | mBERT | BETO |
69
+ |---------------------------|----------------------------|-------------------------------|-------------------------|
70
+ | PharmaCoNER | **90.04** - **88.92** - **91.18** | 87.46 - 86.50 - 88.46 | 88.18 - 87.12 - 89.28 |
71
+ | CANTEMIST | **83.34** - **81.48** - **85.30** | 82.61 - 81.12 - 84.15 | 82.42 - 80.91 - 84.00 |
72
+ | ICTUSnet | **88.08** - **84.92** - **91.50** | 86.75 - 83.53 - 90.23 | 85.95 - 83.10 - 89.02 |
73
+
74
+
75
+ ## Intended uses & limitations
76
+
77
+ The model is ready-to-use only for masked language modelling to perform the Fill Mask task (try the inference API or read the next section)
78
+
79
+ However, the is intended to be fine-tuned on downstream tasks such as Named Entity Recognition or Text Classification.
80
+
81
+ ## Cite
82
+ If you use our models, please cite our latest preprint:
83
+
84
+ ```bibtex
85
+
86
+ @misc{carrino2021biomedical,
87
+ title={Biomedical and Clinical Language Models for Spanish: On the Benefits of Domain-Specific Pretraining in a Mid-Resource Scenario},
88
+ author={Casimiro Pio Carrino and Jordi Armengol-Estapé and Asier Gutiérrez-Fandiño and Joan Llop-Palao and Marc Pàmies and Aitor Gonzalez-Agirre and Marta Villegas},
89
+ year={2021},
90
+ eprint={2109.03570},
91
+ archivePrefix={arXiv},
92
+ primaryClass={cs.CL}
93
+ }
94
+
95
+ ```
96
+
97
+ If you use our Medical Crawler corpus, please cite the preprint:
98
+
99
+ ```bibtex
100
+
101
+ @misc{carrino2021spanish,
102
+ title={Spanish Biomedical Crawled Corpus: A Large, Diverse Dataset for Spanish Biomedical Language Models},
103
+ author={Casimiro Pio Carrino and Jordi Armengol-Estapé and Ona de Gibert Bonet and Asier Gutiérrez-Fandiño and Aitor Gonzalez-Agirre and Martin Krallinger and Marta Villegas},
104
+ year={2021},
105
+ eprint={2109.07765},
106
+ archivePrefix={arXiv},
107
+ primaryClass={cs.CL}
108
+ }
109
+
110
+ ```
111
+
112
+ ---
113
+
114
+ ---
115
+
116
+ ## How to use
117
+
118
+ ```python
119
+ from transformers import AutoTokenizer, AutoModelForMaskedLM
120
+
121
+ tokenizer = AutoTokenizer.from_pretrained("PlanTL-GOB-ES/roberta-base-biomedical-es")
122
+
123
+ model = AutoModelForMaskedLM.from_pretrained("PlanTL-GOB-ES/roberta-base-biomedical-es")
124
+
125
+ from transformers import pipeline
126
+
127
+ unmasker = pipeline('fill-mask', model="PlanTL-GOB-ES/roberta-base-biomedical-es")
128
+
129
+ unmasker("El único antecedente personal a reseñar era la <mask> arterial.")
130
+ ```
131
+ ```
132
+ # Output
133
+ [
134
+ {
135
+ "sequence": " El único antecedente personal a reseñar era la hipertensión arterial.",
136
+ "score": 0.9855039715766907,
137
+ "token": 3529,
138
+ "token_str": " hipertensión"
139
+ },
140
+ {
141
+ "sequence": " El único antecedente personal a reseñar era la diabetes arterial.",
142
+ "score": 0.0039140828885138035,
143
+ "token": 1945,
144
+ "token_str": " diabetes"
145
+ },
146
+ {
147
+ "sequence": " El único antecedente personal a reseñar era la hipotensión arterial.",
148
+ "score": 0.002484665485098958,
149
+ "token": 11483,
150
+ "token_str": " hipotensión"
151
+ },
152
+ {
153
+ "sequence": " El único antecedente personal a reseñar era la Hipertensión arterial.",
154
+ "score": 0.0023484621196985245,
155
+ "token": 12238,
156
+ "token_str": " Hipertensión"
157
+ },
158
+ {
159
+ "sequence": " El único antecedente personal a reseñar era la presión arterial.",
160
+ "score": 0.0008009297889657319,
161
+ "token": 2267,
162
+ "token_str": " presión"
163
+ }
164
+ ]
165
+ ```
166
+
167
+ ## Funding
168
+ This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL.
169
+
170
+ ## Disclaimer
171
+
172
+ The models published in this repository are intended for a generalist purpose and are available to third parties. These models may have bias and/or any other undesirable distortions.
173
+
174
+ When third parties, deploy or provide systems and/or services to other parties using any of these models (or using systems based on these models) or become users of the models, they should note that it is their responsibility to mitigate the risks arising from their use and, in any event, to comply with applicable regulations, including regulations regarding the use of artificial intelligence.
175
+
176
+ In no event shall the owner of the models (SEDIA – State Secretariat for digitalization and artificial intelligence) nor the creator (BSC – Barcelona Supercomputing Center) be liable for any results arising from the use made by third parties of these models.
177
+
178
+
179
+ Los modelos publicados en este repositorio tienen una finalidad generalista y están a disposición de terceros. Estos modelos pueden tener sesgos y/u otro tipo de distorsiones indeseables.
180
+
181
+ 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, incluyendo la normativa en materia de uso de inteligencia artificial.
182
+
183
+ 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.
args.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_path_name": null,
3
+ "vocab_name": "bio-clinical",
4
+ "tokenizer": "bbpe-roberta",
5
+ "lowercase": false,
6
+ "vocab_size": 50262,
7
+ "min_frequency": 6,
8
+ "extra_tokens": [],
9
+ "limit_alphabet": 1000,
10
+ "max_len": 512,
11
+ "no_show_progress": false,
12
+ "strip_accents": false,
13
+ "no_handle_chinese_chars": false,
14
+ "no_clean_text": false,
15
+ "reserve_tokens": 0,
16
+ "use_tokenizers": false,
17
+ "no_fairseq": false,
18
+ "bbpe_add_prefix_space": true,
19
+ "single_paragraph_add_punct": true,
20
+ "tok_batch_size": 100000000,
21
+ "files": [
22
+ "/home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_valid_test_split_output/bio-clinical-2021-12-07-1608-d1d3-fb2f/train.txt",
23
+ "/home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_valid_test_split_output/bio-clinical-2021-12-07-1608-d1d3-fb2f/valid.txt",
24
+ "/home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_valid_test_split_output/bio-clinical-2021-12-07-1608-d1d3-fb2f/test.txt"
25
+ ],
26
+ "output_root_path": "/home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e",
27
+ "commit_hash": "d1d3920e7012caf14c9d6968fded36e0dd719a51"
28
+ }
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "eos_token_id": 2,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-05,
15
+ "max_position_embeddings": 514,
16
+ "model_type": "roberta",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 1,
20
+ "position_embedding_type": "absolute",
21
+ "transformers_version": "4.6.0",
22
+ "type_vocab_size": 1,
23
+ "use_cache": true,
24
+ "vocab_size": 50262
25
+ }
dict.txt ADDED
The diff for this file is too large to render. See raw diff
merges.txt ADDED
The diff for this file is too large to render. See raw diff
process.log ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ Executing train_tokenizer.py
2
+ ------------------------------
3
+ training bbpe tokenizer
4
+ Initialize an empty tokenizer
5
+ training
6
+ saving model tokenizer to /home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_tokenizer_output/train-tokenizer-2021-12-07-1625-d1d3-74b8
7
+ saving pretrained to /home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_tokenizer_output/train-tokenizer-2021-12-07-1625-d1d3-74b8
8
+ saving config to /home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_tokenizer_output/train-tokenizer-2021-12-07-1625-d1d3-74b8
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8465af10873f1fff9361fd90d493db06f130f7065c0c9122951f0225b860b42c
3
+ size 499067539
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
1
+ {"bos_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "eos_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "unk_token": {"content": "<unk>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "sep_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "pad_token": {"content": "<pad>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "cls_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true}, "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true}}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
1
+ {"unk_token": {"content": "<unk>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "bos_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "eos_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "add_prefix_space": true, "errors": "replace", "sep_token": {"content": "</s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "cls_token": {"content": "<s>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "pad_token": {"content": "<pad>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "mask_token": {"content": "<mask>", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "max_len": 512, "special_tokens_map_file": null, "name_or_path": "/home/shared/dt01/temutauro/ccasimiro/corpus-utils-lm/output/model-ready_output/bio-clinical-vocab-50262-2021-12-07-1604-d1d3-849e/train_tokenizer_output/train-tokenizer-2021-12-07-1625-d1d3-74b8"}
vocab.json ADDED
The diff for this file is too large to render. See raw diff