Token Classification
Transformers
Safetensors
Spanish
bert
ner
named-entity-recognition
spanish
español
biomedical
clinical
medical
oncology
prostate-cancer
cancer-de-prostata
beto
Eval Results (legacy)
Instructions to use ralzate/beto-prostata-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ralzate/beto-prostata-ner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="ralzate/beto-prostata-ner")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("ralzate/beto-prostata-ner") model = AutoModelForTokenClassification.from_pretrained("ralzate/beto-prostata-ner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Tarjeta del modelo en español (reemplaza plantilla por defecto)
Browse files
README.md
CHANGED
|
@@ -1,199 +1,167 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 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 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
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).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: es
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
library_name: transformers
|
| 5 |
+
pipeline_tag: token-classification
|
| 6 |
+
base_model: dccuchile/bert-base-spanish-wwm-cased
|
| 7 |
+
tags:
|
| 8 |
+
- token-classification
|
| 9 |
+
- ner
|
| 10 |
+
- named-entity-recognition
|
| 11 |
+
- spanish
|
| 12 |
+
- español
|
| 13 |
+
- biomedical
|
| 14 |
+
- clinical
|
| 15 |
+
- medical
|
| 16 |
+
- oncology
|
| 17 |
+
- prostate-cancer
|
| 18 |
+
- cancer-de-prostata
|
| 19 |
+
- beto
|
| 20 |
+
metrics:
|
| 21 |
+
- f1
|
| 22 |
+
- precision
|
| 23 |
+
- recall
|
| 24 |
+
widget:
|
| 25 |
+
- text: "Paciente masculino de 72 años con adenocarcinoma de próstata, Gleason 3+3 y PSA de 9.9 ng/dL. Se inicia tratamiento con radioterapia y bicalutamida 50 mg diarios."
|
| 26 |
+
example_title: "Caso clínico de próstata"
|
| 27 |
+
- text: "Varón de 68 años con cáncer de próstata estadio T2N0M0, PSA 12.4. Prostatectomía radical en marzo de 2023."
|
| 28 |
+
example_title: "Estadificación y cirugía"
|
| 29 |
+
model-index:
|
| 30 |
+
- name: beto-prostata-ner
|
| 31 |
+
results:
|
| 32 |
+
- task:
|
| 33 |
+
type: token-classification
|
| 34 |
+
name: Named Entity Recognition
|
| 35 |
+
metrics:
|
| 36 |
+
- type: f1
|
| 37 |
+
value: 0.9757
|
| 38 |
+
name: F1 (micro, seqeval)
|
| 39 |
+
- type: precision
|
| 40 |
+
value: 0.9732
|
| 41 |
+
name: Precision
|
| 42 |
+
- type: recall
|
| 43 |
+
value: 0.9781
|
| 44 |
+
name: Recall
|
| 45 |
---
|
| 46 |
|
| 47 |
+
# BETO fine-tuned para NER de cáncer de próstata (español)
|
| 48 |
|
| 49 |
+
Modelo de **Reconocimiento de Entidades Nombradas (NER)** que extrae información clínica
|
| 50 |
+
de textos en **español** sobre **cáncer de próstata**. Es un fine-tuning de
|
| 51 |
+
[**BETO**](https://huggingface.co/dccuchile/bert-base-spanish-wwm-cased) (BERT entrenado
|
| 52 |
+
desde cero en español) para clasificación de tokens en formato **BIO** con 21 etiquetas.
|
| 53 |
|
| 54 |
+
> **F1 en test: 0.976** (seqeval, micro) · Precision 0.973 · Recall 0.978 · Accuracy 0.995
|
| 55 |
|
| 56 |
+
## 🎯 Para qué sirve
|
| 57 |
|
| 58 |
+
Detecta y clasifica, palabra por palabra, **10 tipos de entidades clínicas** en informes y
|
| 59 |
+
notas médicas de oncología prostática:
|
| 60 |
|
| 61 |
+
| Entidad | Qué captura | Ejemplo |
|
| 62 |
+
|---|---|---|
|
| 63 |
+
| `EDAD` | Edad del paciente | *72 años* |
|
| 64 |
+
| `CANCER` | Tipo/diagnóstico de cáncer | *adenocarcinoma de próstata* |
|
| 65 |
+
| `GLEASON` | Escala de Gleason | *Gleason 3+3* |
|
| 66 |
+
| `BIOMARCADOR` | Biomarcadores (PSA, etc.) | *PSA de 9.9 ng/dL* |
|
| 67 |
+
| `TNM` | Estadificación TNM | *T2N0M0* |
|
| 68 |
+
| `TRATAMIENTO` | Tratamientos | *radioterapia* |
|
| 69 |
+
| `MEDICAMENTO` | Fármacos | *bicalutamida* |
|
| 70 |
+
| `DOSIS` | Dosis | *50 mg diarios* |
|
| 71 |
+
| `CIRUGIA` | Procedimientos quirúrgicos | *prostatectomía radical* |
|
| 72 |
+
| `FECHA` | Fechas | *marzo de 2023* |
|
| 73 |
|
| 74 |
+
Cada entidad se etiqueta en esquema **BIO** (`B-` inicio, `I-` continuación, `O` fuera),
|
| 75 |
+
para 21 etiquetas en total.
|
| 76 |
|
| 77 |
+
## 🚀 Uso rápido
|
| 78 |
|
| 79 |
+
```python
|
| 80 |
+
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
ner = pipeline("token-classification", model="ralzate/beto-prostata-ner",
|
| 83 |
+
aggregation_strategy="simple")
|
| 84 |
|
| 85 |
+
texto = ("Paciente masculino de 72 años con adenocarcinoma de próstata, "
|
| 86 |
+
"Gleason 3+3 y PSA de 9.9 ng/dL. Se inicia radioterapia y bicalutamida 50 mg.")
|
| 87 |
|
| 88 |
+
for e in ner(texto):
|
| 89 |
+
print(f"{e['entity_group']:14s} {e['score']*100:5.1f}% {e['word']}")
|
| 90 |
+
```
|
| 91 |
|
| 92 |
+
Salida esperada (entidades como `EDAD`, `CANCER`, `GLEASON`, `BIOMARCADOR`,
|
| 93 |
+
`TRATAMIENTO`, `MEDICAMENTO`, `DOSIS`).
|
| 94 |
|
| 95 |
+
## 📊 Resultados (conjunto de test, seqeval)
|
| 96 |
|
| 97 |
+
Barrido de *batch size* con 6 épocas y *early stopping*:
|
| 98 |
|
| 99 |
+
| batch size | Precision | Recall | F1 |
|
| 100 |
+
|---|---|---|---|
|
| 101 |
+
| **8** (recomendado) | 0.9732 | 0.9781 | **0.9757** |
|
| 102 |
+
| 16 | 0.9627 | 0.9705 | 0.9666 |
|
| 103 |
+
| 32 | 0.9488 | 0.9603 | 0.9545 |
|
| 104 |
|
| 105 |
+
Este repositorio publica la **mejor configuración (batch size 8)**. El F1 baja levemente al
|
| 106 |
+
aumentar el lote porque, con 6 épocas, los lotes pequeños dan más pasos de optimización.
|
| 107 |
|
| 108 |
+
### Comparación con XLM-RoBERTa
|
| 109 |
|
| 110 |
+
En el mismo dataset, **BETO supera a XLM-RoBERTa-base** (multilingüe) en todo el barrido
|
| 111 |
+
(F1 0.955–0.976 vs 0.850–0.936). En NER clínico en español, un encoder **nativo en español**
|
| 112 |
+
y compacto rinde mejor que un multilingüe más grande: la especialización lingüística pesa
|
| 113 |
+
más que el tamaño.
|
| 114 |
|
| 115 |
+
## 🧠 Detalles de entrenamiento
|
| 116 |
|
| 117 |
+
| | |
|
| 118 |
+
|---|---|
|
| 119 |
+
| **Modelo base** | `dccuchile/bert-base-spanish-wwm-cased` (BETO, ~110M parámetros) |
|
| 120 |
+
| **Tarea** | Token Classification (NER), 21 etiquetas BIO |
|
| 121 |
+
| **Dominio** | Texto clínico de cáncer de próstata en español |
|
| 122 |
+
| **Épocas** | 6 (con *early stopping*, paciencia 2, métrica F1) |
|
| 123 |
+
| **Learning rate** | 2e-5 |
|
| 124 |
+
| **Batch size** | 8 (este checkpoint) |
|
| 125 |
+
| **Longitud máxima** | 128 subtokens |
|
| 126 |
+
| **Optimizador** | AdamW, weight decay 0.01, warmup 0.1 |
|
| 127 |
+
| **Métrica** | seqeval (precision/recall/F1 a nivel de entidad) |
|
| 128 |
+
| **Hardware** | Apple M1 Pro (MPS), entrenamiento local |
|
| 129 |
+
| **Alineación** | etiqueta en el primer subtoken de cada palabra; resto a `-100` |
|
| 130 |
|
| 131 |
+
## ⚠️ Limitaciones
|
| 132 |
|
| 133 |
+
- Entrenado en un **dominio específico** (cáncer de próstata en español); fuera de ese
|
| 134 |
+
dominio el rendimiento puede caer.
|
| 135 |
+
- El conjunto de datos es de tamaño moderado; entidades poco frecuentes pueden tener menor
|
| 136 |
+
recall.
|
| 137 |
+
- No sustituye el criterio clínico profesional. Pensado como apoyo a la extracción de
|
| 138 |
+
información, no para decisiones médicas autónomas.
|
| 139 |
+
- Hereda los posibles sesgos de BETO y del corpus clínico de entrenamiento.
|
| 140 |
|
| 141 |
+
## 🏷️ Etiquetas
|
| 142 |
|
| 143 |
+
```
|
| 144 |
+
O
|
| 145 |
+
B-EDAD, I-EDAD, B-CANCER, I-CANCER, B-GLEASON, I-GLEASON,
|
| 146 |
+
B-BIOMARCADOR, I-BIOMARCADOR, B-TNM, I-TNM, B-TRATAMIENTO, I-TRATAMIENTO,
|
| 147 |
+
B-MEDICAMENTO, I-MEDICAMENTO, B-DOSIS, I-DOSIS, B-CIRUGIA, I-CIRUGIA, B-FECHA, I-FECHA
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
## 📚 Cita
|
| 151 |
+
|
| 152 |
+
Si usas este modelo, cita también a BETO:
|
| 153 |
|
| 154 |
+
```bibtex
|
| 155 |
+
@inproceedings{canete2020beto,
|
| 156 |
+
title={Spanish Pre-Trained BERT Model and Evaluation Data},
|
| 157 |
+
author={Cañete, José and Chaperon, Gabriel and Fuentes, Rodrigo and Ho, Jou-Hui and Kang, Hojin and Pérez, Jorge},
|
| 158 |
+
booktitle={PML4DC at ICLR 2020},
|
| 159 |
+
year={2020}
|
| 160 |
+
}
|
| 161 |
+
```
|
| 162 |
|
| 163 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
+
*Modelo afinado y publicado como parte de un proyecto de PLN en español (clasificación y NER
|
| 166 |
+
con Transformers). Reproducible en hardware modesto (Apple Silicon) mediante fine-tuning
|
| 167 |
+
completo para BETO y LoRA para modelos grandes.*
|