File size: 9,734 Bytes
cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 f1f9e07 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 2f55c73 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 2f55c73 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 2f55c73 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 036820a cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 552fe10 cb10f5c 2f55c73 cb10f5c 7549519 0ac5151 7549519 0ac5151 7549519 0ac5151 7549519 0ac5151 cb10f5c 0ac5151 7549519 0ac5151 cb10f5c 2f55c73 cb10f5c 552fe10 cb10f5c 2f55c73 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
---
library_name: transformers
tags:
- biology
- medical
license: cc-by-nc-nd-4.0
datasets:
- fundacionctic/DermatES
language:
- es
metrics:
- accuracy
- f1
pipeline_tag: text-classification
---
# Model Card for Model ID
This is a fine-tuned version of the pre-trained biomedical language model [bsc-bio-ehr-es](https://huggingface.co/PlanTL-GOB-ES/bsc-bio-ehr-es) in Spanish, tailored for text classification tasks. We used two NVIDIA GPUs for training.
## Model Details
### Model Description
This model has been fine-tuned for text classification on dermatological Spanish electronic health records (EHR). It leverages the pre-trained biomedical language understanding from the [bsc-bio-ehr-es](https://huggingface.co/PlanTL-GOB-ES/bsc-bio-ehr-es) model and adapts it to classify dermatology-related texts effectively.
The model is intended to predict among 25 different skin diseases from a medical record. It could be a first visit or a follow-up visit.
It takes as input four features:
- *textual medical record:* the EHR written by a doctor
- *disease type:* the type of disease associated with the EHR
- *disease location:* the location in the body of the disease
- *disease severity:* how severe or lethal is the disease
It is IMPORTANT to load and concatenate them in this specific order.
The details to reproduce the cascade predictions are available in the Training section.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
- **Developed by:** [Fundacion CTIC](https://www.fundacionctic.org)
- **Funded by [optional]:** [SATEC](https://www.satec.es)
- **Model type:** Fine-tuned LM Encoder
- **Language(s) (NLP):** Spanish
- **License:** CC-BY-NC
- **Finetuned from model [optional]:** [bsc-bio-ehr-es](https://huggingface.co/PlanTL-GOB-ES/bsc-bio-ehr-es)
### Model Sources [optional]
<!-- Provide the basic links for the model. -->
- **Repository:**
- **Paper [optional]:** Coming soon...
- **Demo [optional]:** [More Information Needed]
## Uses
The Model is industry-friendly and the best model of the **dermat** collection. The vanilla version of the model is called [vanilla-dermat](https://huggingface.co/fundacionctic/vanilla-dermat/) and is meant to predict not only the disease but also the 3 features mentionned above.
We DO NOT recommend to fine-tune this model. It is already meant to be a downstream task.
### Direct Use
This model can be directly used for classifying dermatological text data in Spanish EHRs.
### Downstream Use
The model can be integrated into healthcare applications for automatic classification of dermatological conditions from patient records.
### Out-of-Scope Use
The model is not suitable for non-medical text classification tasks or for texts in languages other than Spanish.
## Bias, Risks, and Limitations
This model is fine-tuned on a specific dataset and may not generalize well to other types of medical texts or conditions. Users should be cautious of biases in the training data that could affect the model's performance.
### Recommendations
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
Users should validate the model's performance on their specific data and consider any ethical implications of deploying a machine learning model in a healthcare setting.
## How to Get Started with the Model
```
from transformers import RobertaTokenizerFast, RobertaForSequenceClassification,
tokenizer = RobertaTokenizerFast.from_pretrained("fundacionctic/predict-dermat")
model = RobertaForSequenceClassification.from_pretrained("fundacionctic/predict-dermat")
inputs = tokenizer("Ejemplo de texto dermatológico + tipo + localizacion + gravedad".tolist(),
truncation=True,
padding='max_length',
max_length=max_length, # Replace with your desired maximum sequence length
return_tensors='pt',
return_attention_mask=True,
))
outputs = model(input_ids, attention_mask=attention_mask)
```
## Training Details
### Training Data
The model was fine-tuned on the DermatES dataset from Fundación CTIC, which contains Spanish dermatological EHRs.
### Training Procedure
In order to reproduce the experiment it is ESSENTIAL to respect the order of prediction of the three ontology-base features. More details in the original paper of *Dermat*
```
from transformers import RobertaTokenizerFast, RobertaForSequenceClassification,
tokenizer = RobertaTokenizerFast.from_pretrained("PlanTL-GOB-ES/bsc-bio-ehr-es")
model = RobertaForSequenceClassification.from_pretrained("PlanTL-GOB-ES/bsc-bio-ehr-es")
def reset_model():
model = RobertaForSequenceClassification.from_pretrained("PlanTL-GOB-ES/bsc-bio-ehr-es")
def cascade(inputs,information_list,model,tokenizer,predictions=None):
if not information_list:
return predictions
else :
inputs = tokenizer("Ejemplo de texto dermatológico".tolist(),
truncation=True,
padding='max_length',
max_length=max_length, # Replace with your desired maximum sequence length
return_tensors='pt',
return_attention_mask=True,
))
labels = information_list[0].tolist()
outputs = model(input_ids, attention_mask=attention_mask,labels=labels)
predictions = torch.argmax(outputs.logits,dim=1)
inputs = [tokenizer.decode(input+predictions[i]) for i,input in enumerate(inputs)]
model = reset_model()
return cascade(inputs,information_list[1:],model,tokenizer,predictions)
inputs = ["un informe,","otro informe"]
information_list = [[tipo1,tipo2],[sitio1,sitio2],[gravedad1,gravedad2]]
predicted_diseases = cascade(inputs,information_list,model,tokenizer)
```
#### Preprocessing
Lowercased, anonymized and accents removed texts
#### Training Hyperparameters
- **Training regime:** fp32
#### Speeds, Sizes, Times
Epochs: 7
Batch size: 64
Learning rate: 0.0001
## Evaluation
### Testing Data, Factors & Metrics
#### Testing Data
The evaluation was performed on 0.2 of the [DermatES](https://huggingface.co/datasets/fundacionctic/DermatES) dataset.
#### Factors
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
[More Information Needed]
#### Metrics
- *Accuracy:* 0.51
- *F1 Score:* 0.42
- *top-k (k=2) accuracy:* 0.67
- *top-k (k=2) f1 Score:* 0.61
#### Summary
The model achieves poor accuracy and F1 score on dermatological text classification, demonstrating the need of using ontologies (see [oracle-dermat](https://huggingface.co/fundacionctic/oracle-dermat) ) for this specific medical domain.
## Model Examination [optional]
<!-- Relevant interpretability work for the model goes here -->
[More Information Needed]
## Environmental Impact
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
- **Hardware Type:** GPU and CPU with avx
- **Hours used:** >96
- **Cloud Provider:** [More Information Needed]
- **Compute Region:** EU
- **Carbon Emitted:** [More Information Needed]
## Technical Specifications [optional]
### Model Architecture and Objective
The model is based on the [RoBERTa](https://huggingface.co/FacebookAI/roberta-base) architecture, fine-tuned for the objective of text classification in the biomedical domain.
### Compute Infrastructure
#### Hardware
Two NVIDIA GPUs were used for the fine-tuning process.
#### Software
The fine-tuning was performed using the 🤗 Transformers library.
## Citation
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
**BibTeX:**
#### Original paper
```
@inproceedings{schaub2024,
author = {L.-P. Schaub Torre and P. Quiros and H. Garcia-Mieres},
title = {Detección Automática de Patologías en Notas Clínicas en Español Combinando Modelos de Lenguaje y Ontologías Médicos},
booktitle = {SEPLN-2024: 40th Conference of the Spanish Society for Natural Language Processing},
year = {2024},
pages = {99--120},
publisher = {Universidad de Valladolid, ECA-SIMM Research Group, Departamento de Informática},
address = {Valladolid},
url = {https://ceur-ws.org/Vol-3846/},
}
```
#### English version
```
@misc{torre2024automaticdetectiondiseasesspanish,
title={Automatic detection of diseases in Spanish clinical notes combining medical language models and ontologies},
author={Leon-Paul Schaub Torre and Pelayo Quiros and Helena Garcia Mieres},
year={2024},
eprint={2412.03176},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.03176},
}
```
**APA:**
```
Schaub Torre, L.-P., Quiros, P., & Garcia-Mieres, H. (2024). Detección automática de patologías en notas clínicas en español combinando modelos de lenguaje y ontologías médicos. In SEPLN-2024: 40th Conference of the Spanish Society for Natural Language Processing (pp. 99–120). Universidad de Valladolid, ECA-SIMM Research Group, Departamento de Informática. https://ceur-ws.org/Vol-3846/
```
## Glossary [optional]
## More Information [optional]
[More Information Needed]
## Model Card Authors
Leon-Paul Schaub Torre, Pelayo Quiros and Helena Garcia-Mieres
## Model Card Contact
leon.schaub@fundacionctic.org
pelayo.quiros@fundacionctic.org |