
# Biomedical Longformer base for Spanish

## Table of contents
<details>
<summary>Click to expand</summary>

- [Model description](#model-description)
- [Intended uses and limitations](#intended-use)
- [How to use](#how-to-use)
- [Limitations and bias](#limitations-and-bias)
- [Training](#training)
- [Evaluation](#evaluation)
- [Additional information](#additional-information)
  - [Author](#author)
  - [Contact information](#contact-information)
  - [Copyright](#copyright)
  - [Licensing information](#licensing-information)
  - [Funding](#funding)
  - [Disclaimer](#disclaimer)
  
</details>

## Model description
The **longformer-base-4096-biomedical-clinical-es** is the [Longformer](https://huggingface.co/allenai/longformer-base-4096) version of the [roberta-base-biomedical-clinical-es](https://huggingface.co/PlanTL-GOB-ES/roberta-base-biomedical-clinical-es) model. The model started from the **roberta-base-biomedical-clinical-es** checkpoint and was pretrained for MLM on long documents from our biomedical and clinical corpora.

Longformer uses a combination of sliding window (local) attention and global attention. Global attention is user-configured based on the task to allow the model to learn task-specific representations. Please refer to the original [paper](https://arxiv.org/abs/2004.05150) for more details on how to set global attention.

For more details about the corpus, the pretraining, and the evaluation, check the official [repository](https://github.com/TeMU-BSC/longformer-es).


## Intended uses and limitations
The **longformer-base-4096-biomedical-clinical-es** model is ready-to-use only for masked language modeling to perform the Fill Mask task (try the inference API or read the next section). However, it is intended to be fine-tuned on non-generative downstream tasks such as Question Answering, Text Classification, or Named Entity Recognition.

## How to use
Here is how to use this model:

```python
from transformers import AutoModelForMaskedLM
from transformers import AutoTokenizer, FillMaskPipeline
from pprint import pprint
tokenizer_hf = AutoTokenizer.from_pretrained('PlanTL-GOB-ES/longformer-base-4096-biomedical-clinical-es')
model = AutoModelForMaskedLM.from_pretrained('PlanTL-GOB-ES/longformer-base-4096-biomedical-clinical-es')
model.eval()
pipeline = FillMaskPipeline(model, tokenizer_hf)
text = f"El único antecedente personal a reseñar era la <mask> arterial."
res_hf = pipeline(text)
pprint([r['token_str'] for r in res_hf])
```

## Limitations and bias
At the time of submission, no measures have been taken to estimate the bias embedded in the model. However, we are well aware that our models may be biased since the corpora have been collected using crawling techniques on multiple web sources. We intend to conduct research in these areas in the future, and if completed, this model card will be updated.

## Training
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:

  - data parsing in different formats
  - sentence splitting
  - language detection
  - filtering of ill-formed sentences 
  - deduplication of repetitive contents
  - keep the original document boundaries

Then, the biomedical corpora are concatenated and further global deduplication among the biomedical corpora have been applied.
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:

    
| Name                                                                                    | No. tokens  | Description                                                                                                                                                                                                                                          |
|-----------------------------------------------------------------------------------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Medical crawler](https://zenodo.org/record/4561970)                                    | 745,705,946 | Crawler of more than 3,000 URLs belonging to Spanish biomedical and health domains.                                                                                                                                                                                 |
| 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.                                                                                                                                                                                 |
| 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.                                                                                                                                                                                 |
| [Scielo](https://github.com/PlanTL-SANIDAD/SciELO-Spain-Crawler)                        | 60,007,289  | Publications written in Spanish crawled from the Spanish SciELO server in 2017.                                                                                                                                       |
| [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.                                                                                       |
| 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.                                                                                                                                                                    |
| 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".                                                        |
| [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.                                                                                                                            |
| [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. |
| PubMed                                                                                  | 1,858,966   | Open-access articles from the PubMed repository crawled in 2017.                                                                                                                                              |


For more details about the corpus, the pretraining, and the evaluation, check the official [repository](https://github.com/TeMU-BSC/longformer-es).

## Evaluation
The **longformer-base-4096-biomedical-clinical-es** was succesfully evaluated in a clinical coding task of discharge reports that do not fit in a standard 512 token sequence. The longformer version clearly outperformed the regular RoBERTa model. Currently, due to legal restrictions, we cannot distribute the evaluation corpus or the results.

## Additional information

### Author
Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@bsc.es)

### Contact information
For further information, send an email to <plantl-gob-es@bsc.es>

### Copyright
Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022)

### Licensing information
[Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)

### Funding
This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL.

### Disclaimer

<details>
<summary>Click to expand</summary>

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.

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.

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.


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.

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.

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.
</details>
{"language": ["es"], "license": "apache-2.0", "tags": ["longformer", "spanish", "biomedical", "clinical", "longformer-base-4096-biomedical-clinical-es"], "widget": [{"text": "El \u00fanico antecedente personal a rese\u00f1ar era la <mask> arterial."}, {"text": "Las radiolog\u00edas \u00f3seas de cuerpo entero no detectan alteraciones <mask>, ni alteraciones vertebrales."}, {"text": "En el <mask> toraco-abd\u00f3mino-p\u00e9lvico no se encontraron hallazgos patol\u00f3gicos de inter\u00e9s."}, {"text": "Insuficiencia a\u00f3rtica significativa, sin otras valvulopat\u00edas. Ventr\u00edculo derecho de tama\u00f1o y funci\u00f3n normales. Ra\u00edz a\u00f3rtica de di\u00e1metros aumentados (45 mm), sin apreciarse clara imagen de flap. Vena cava inferior (VCI) normal. Derrame peric\u00e1rdico ligero. Angio-TAC de aorta: disecci\u00f3n a\u00f3rtica tipo A con afectaci\u00f3n de ra\u00edz a\u00f3rtica que se extiende por la vertiente ant erior de la pared a\u00f3rtica pr\u00f3xima al tronco coronario izquierdo (TCI) desde el plano valvular hasta el origen de arteria mesent\u00e9rica inferior con afectaci\u00f3n del origen proximal de TSA. Dilataci\u00f3n de ra\u00edz a\u00f3rtica y de porci\u00f3n tubular de aorta ascendente (47 mm). Cayado 37 mm. Aorta descendente 31 mm. A nivel de aorta toraco-abdominal la luz verdadera presenta un calibre re ducido. Tronco celiaco, mesent\u00e9rica superior y renal derecha tienen su origen en la luz verdadera. Renal izquierda se origina en una puerta de comunicaci\u00f3n entre la luz verdadera y la falsa luz con buena perfusi \u00f3n renal. Aorta distal y sector iliofemoral normal. Conclusi\u00f3n: disecci\u00f3n tipo A que se extiende desde ra\u00edz a\u00f3rtica hasta el segmento a\u00f3rtico proximal al origen de mesent\u00e9rica inferior. EVOLUCI\u00d3N CL\u00cdNICA Ante un paciente con dolor tor\u00e1cico opresivo intenso, sin alteraciones significativas a nivel de ECG sugestivas de isquemia, se decidi\u00f3 realizar ETT urgente, objetivando una dilataci\u00f3n de ra\u00edz a\u00f3rtica con insuficiencia signi ficativa. Ante estos hallazgos, se decidi\u00f3 solicitar angio-TAC que confirm\u00f3 el diagn\u00f3stico de disecci\u00f3n a\u00f3rtica tipo A. Co n los resultados de las exploraciones complementarias y el diagn\u00f3stico, se contact\u00f3 con el servicio de cirug\u00eda c ardiaca, realiz\u00e1ndose intervenci\u00f3n quir\u00fargica de forma emergente con t\u00e9cnica de Bono-Bentall mec\u00e1nico (Carboseal 29 mm) (consiste en realizar en una misma intervenci\u00f3n quir\u00fargica un reemplazo valvular a\u00f3rtico, un reemplazo d e ra\u00edz a\u00f3rtica y aorta ascendente, as\u00ed como el reimplante de ostium coronarios), bajo circulaci\u00f3n extracorp\u00f3rea, parada electromec\u00e1nica del coraz\u00f3n y parada circulatoria con perfusi\u00f3n cerebral selectiva bicarot\u00eddea. No se realiz\u00f3 recambio de arco <mask> ni aorta descendente dada la situaci\u00f3n cr\u00edtica del paciente, la complejid ad de la intervenci\u00f3n y la mejor\u00eda tras eliminar el desgarro principal y reinstauraci\u00f3n de flujo a luz verdadera."}]}
transformers pytorch longformer fill-mask spanish biomedical clinical longformer-base-4096-biomedical-clinical-es es arxiv:2004.05150 license:apache-2.0 autotrain_compatible endpoints_compatible region:us
TAGS
#transformers #pytorch #longformer #fill-mask #spanish #biomedical #clinical #longformer-base-4096-biomedical-clinical-es #es #arxiv-2004.05150 #license-apache-2.0 #autotrain_compatible #endpoints_compatible #region-us 

Biomedical Longformer base for Spanish
======================================


Table of contents
-----------------



Click to expand
* Model description
* Intended uses and limitations
* How to use
* Limitations and bias
* Training
* Evaluation
* Additional information
	+ Author
	+ Contact information
	+ Copyright
	+ Licensing information
	+ Funding
	+ Disclaimer



Model description
-----------------


The longformer-base-4096-biomedical-clinical-es is the Longformer version of the roberta-base-biomedical-clinical-es model. The model started from the roberta-base-biomedical-clinical-es checkpoint and was pretrained for MLM on long documents from our biomedical and clinical corpora.


Longformer uses a combination of sliding window (local) attention and global attention. Global attention is user-configured based on the task to allow the model to learn task-specific representations. Please refer to the original paper for more details on how to set global attention.


For more details about the corpus, the pretraining, and the evaluation, check the official repository.


Intended uses and limitations
-----------------------------


The longformer-base-4096-biomedical-clinical-es model is ready-to-use only for masked language modeling to perform the Fill Mask task (try the inference API or read the next section). However, it is intended to be fine-tuned on non-generative downstream tasks such as Question Answering, Text Classification, or Named Entity Recognition.


How to use
----------


Here is how to use this model:


Limitations and bias
--------------------


At the time of submission, no measures have been taken to estimate the bias embedded in the model. However, we are well aware that our models may be biased since the corpora have been collected using crawling techniques on multiple web sources. We intend to conduct research in these areas in the future, and if completed, this model card will be updated.


Training
--------


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:


* data parsing in different formats
* sentence splitting
* language detection
* filtering of ill-formed sentences
* deduplication of repetitive contents
* keep the original document boundaries


Then, the biomedical corpora are concatenated and further global deduplication among the biomedical corpora have been applied.
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:


Name: Medical crawler, No. tokens: 745,705,946, Description: Crawler of more than 3,000 URLs belonging to Spanish biomedical and health domains.
Name: Clinical cases misc., No. tokens: 102,855,267, Description: 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.
Name: Clinical notes/documents, No. tokens: 91,250,080, Description: Collection of more than 278K clinical documents, including discharge reports, clinical course notes and X-ray reports, for a total of 91M tokens.
Name: Scielo, No. tokens: 60,007,289, Description: Publications written in Spanish crawled from the Spanish SciELO server in 2017.
Name: BARR2\_background, No. tokens: 24,516,442, Description: Biomedical Abbreviation Recognition and Resolution (BARR2) containing Spanish clinical case study sections from a variety of clinical disciplines.
Name: Wikipedia\_life\_sciences, No. tokens: 13,890,501, Description: Wikipedia articles crawled 04/01/2021 with the Wikipedia API python library 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.
Name: Patents, No. tokens: 13,463,387, Description: 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".
Name: EMEA, No. tokens: 5,377,448, Description: Spanish-side documents extracted from parallel corpora made out of PDF documents from the European Medicines Agency.
Name: mespen\_Medline, No. tokens: 4,166,077, Description: 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.
Name: PubMed, No. tokens: 1,858,966, Description: Open-access articles from the PubMed repository crawled in 2017.


For more details about the corpus, the pretraining, and the evaluation, check the official repository.


Evaluation
----------


The longformer-base-4096-biomedical-clinical-es was succesfully evaluated in a clinical coding task of discharge reports that do not fit in a standard 512 token sequence. The longformer version clearly outperformed the regular RoBERTa model. Currently, due to legal restrictions, we cannot distribute the evaluation corpus or the results.


Additional information
----------------------


### Author


Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@URL)


### Contact information


For further information, send an email to [plantl-gob-es@URL](mailto:plantl-gob-es@URL)


### Copyright


Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022)


### Licensing information


Apache License, Version 2.0


### Funding


This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL.


### Disclaimer



Click to expand
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.


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.


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.


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.


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.


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.



### Author


Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@URL) ### Contact information


For further information, send an email to [plantl-gob-es@URL](mailto:plantl-gob-es@URL) ### Copyright


Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022) ### Licensing information


Apache License, Version 2.0 ### Funding


This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL. ### Disclaimer



Click to expand
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.


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.


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.


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.


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.


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.
TAGS
#transformers #pytorch #longformer #fill-mask #spanish #biomedical #clinical #longformer-base-4096-biomedical-clinical-es #es #arxiv-2004.05150 #license-apache-2.0 #autotrain_compatible #endpoints_compatible #region-us 
 ### Author


Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@URL) ### Contact information


For further information, send an email to [plantl-gob-es@URL](mailto:plantl-gob-es@URL) ### Copyright


Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022) ### Licensing information


Apache License, Version 2.0 ### Funding


This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL. ### Disclaimer



Click to expand
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.


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.


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.


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.


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.


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.
passage: TAGS
#transformers #pytorch #longformer #fill-mask #spanish #biomedical #clinical #longformer-base-4096-biomedical-clinical-es #es #arxiv-2004.05150 #license-apache-2.0 #autotrain_compatible #endpoints_compatible #region-us 
### Author


Text Mining Unit (TeMU) at the Barcelona Supercomputing Center (bsc-temu@URL)### Contact information


For further information, send an email to [plantl-gob-es@URL](mailto:plantl-gob-es@URL)### Copyright


Copyright by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) (2022)### Licensing information


Apache License, Version 2.0### Funding


This work was funded by the Spanish State Secretariat for Digitalization and Artificial Intelligence (SEDIA) within the framework of the Plan-TL.