Add model card
Browse files
README.md
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language: es
|
4 |
+
tags:
|
5 |
+
- text-classification
|
6 |
+
- spanish
|
7 |
+
- email-classification
|
8 |
+
- bert
|
9 |
+
- multilingual
|
10 |
+
datasets:
|
11 |
+
- custom
|
12 |
+
metrics:
|
13 |
+
- accuracy
|
14 |
+
- f1
|
15 |
+
model-index:
|
16 |
+
- name: vertigoq3/email-classifier-bert
|
17 |
+
results:
|
18 |
+
- task:
|
19 |
+
type: text-classification
|
20 |
+
name: Email Classification
|
21 |
+
dataset:
|
22 |
+
type: custom
|
23 |
+
name: Email Dataset
|
24 |
+
metrics:
|
25 |
+
- type: accuracy
|
26 |
+
value: 0.0
|
27 |
+
- type: f1
|
28 |
+
value: 0.0
|
29 |
+
---
|
30 |
+
|
31 |
+
# email-classifier-bert
|
32 |
+
|
33 |
+
Modelo BERT multilingüe fine-tuneado para clasificación de emails en español.
|
34 |
+
|
35 |
+
## Descripción
|
36 |
+
|
37 |
+
Este modelo está basado en `bert-base-multilingual-cased` y ha sido entrenado para clasificar emails en diferentes categorías. El modelo puede identificar automáticamente el tipo de email basándose en su contenido.
|
38 |
+
|
39 |
+
## Uso
|
40 |
+
|
41 |
+
```python
|
42 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
43 |
+
import torch
|
44 |
+
import numpy as np
|
45 |
+
import pickle
|
46 |
+
|
47 |
+
# Cargar el modelo y tokenizer
|
48 |
+
model = AutoModelForSequenceClassification.from_pretrained("vertigoq3/email-classifier-bert")
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained("vertigoq3/email-classifier-bert")
|
50 |
+
|
51 |
+
# Cargar el encoder de etiquetas
|
52 |
+
with open("label_encoder.pkl", "rb") as f:
|
53 |
+
encoder = pickle.load(f)
|
54 |
+
|
55 |
+
def clasificar_email(texto):
|
56 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
57 |
+
model.to(device)
|
58 |
+
|
59 |
+
inputs = tokenizer(texto, return_tensors="pt", truncation=True, padding=True, max_length=512)
|
60 |
+
inputs = {k: v.to(device) for k, v in inputs.items()}
|
61 |
+
|
62 |
+
with torch.no_grad():
|
63 |
+
outputs = model(**inputs)
|
64 |
+
|
65 |
+
pred = np.argmax(outputs.logits.detach().cpu().numpy(), axis=1)
|
66 |
+
return encoder.inverse_transform(pred)[0]
|
67 |
+
|
68 |
+
# Ejemplo de uso
|
69 |
+
resultado = clasificar_email("¿Cuándo abren mañana?")
|
70 |
+
print(f"Categoría: {resultado}")
|
71 |
+
```
|
72 |
+
|
73 |
+
## Instalación
|
74 |
+
|
75 |
+
```bash
|
76 |
+
pip install transformers torch numpy scikit-learn
|
77 |
+
```
|
78 |
+
|
79 |
+
## Entrenamiento
|
80 |
+
|
81 |
+
El modelo fue entrenado con:
|
82 |
+
- **Base Model**: bert-base-multilingual-cased
|
83 |
+
- **Epochs**: 6
|
84 |
+
- **Learning Rate**: 2e-5
|
85 |
+
- **Batch Size**: 8
|
86 |
+
- **Weight Decay**: 0.01
|
87 |
+
|
88 |
+
## Limitaciones
|
89 |
+
|
90 |
+
- El modelo está optimizado para texto en español
|
91 |
+
- Requiere el archivo `label_encoder.pkl` para funcionar correctamente
|
92 |
+
- Las categorías de clasificación dependen del dataset de entrenamiento
|
93 |
+
|
94 |
+
## Contacto
|
95 |
+
|
96 |
+
Para preguntas o problemas, contacta al autor del modelo.
|