Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: es
|
3 |
+
tags:
|
4 |
+
- sentiment-analysis
|
5 |
+
- text-classification
|
6 |
+
- spanish
|
7 |
+
- xlm-roberta
|
8 |
+
license: mit
|
9 |
+
datasets:
|
10 |
+
- custom
|
11 |
+
metrics:
|
12 |
+
- accuracy
|
13 |
+
- f1
|
14 |
+
library_name: transformers
|
15 |
+
pipeline_tag: text-classification
|
16 |
+
widget:
|
17 |
+
- text: "Vamos schiaretti!"
|
18 |
+
example_title: "Ejemplo positivo"
|
19 |
+
- text: "el otro día pensaba eso"
|
20 |
+
example_title: "Ejemplo neutro"
|
21 |
+
- text: "no puede gobernar"
|
22 |
+
example_title: "Ejemplo negativo"
|
23 |
+
model-index:
|
24 |
+
- name: bert-schiaretti
|
25 |
+
results:
|
26 |
+
- task:
|
27 |
+
type: text-classification
|
28 |
+
name: Sentiment Analysis
|
29 |
+
dataset:
|
30 |
+
name: Custom Spanish Sentiment Dataset
|
31 |
+
type: custom
|
32 |
+
metrics:
|
33 |
+
- type: accuracy
|
34 |
+
value: 0.677
|
35 |
+
- type: f1
|
36 |
+
value: 0.664
|
37 |
+
architectures:
|
38 |
+
- XLMRobertaForSequenceClassification
|
39 |
+
transformers_version: "4.41.2"
|
40 |
+
base_model: cardiffnlp/twitter-xlm-roberta-base-sentiment
|
41 |
+
inference:
|
42 |
+
parameters:
|
43 |
+
temperature: 1.0
|
44 |
+
max_length: 512
|
45 |
+
num_return_sequences: 1
|
46 |
+
---
|
47 |
+
|
48 |
+
# BERT-massa - Modelo de Análisis de Sentimientos en Español
|
49 |
+
|
50 |
+
Este modelo está basado en XLM-RoBERTa y ha sido fine-tuned para realizar análisis de sentimientos en textos en español en comentarios sobre el candidato en redes sociales durante el primer debate presidencial de Argentina en 2023.
|
51 |
+
|
52 |
+
## Rendimiento del Modelo
|
53 |
+
|
54 |
+
• *Accuracy*: 0.815
|
55 |
+
• *F1 Score*: 0.767
|
56 |
+
• *Precision*: 0.729
|
57 |
+
• *Recall*: 0.814
|
58 |
+
|
59 |
+
### Métricas por Clase
|
60 |
+
|
61 |
+
| Clase | Precision | Recall | F1-Score | Support |
|
62 |
+
|----------|-----------|--------|----------|---------|
|
63 |
+
| Negativo | 0.8718 | 0.7234 | 0.7907 | 47 |
|
64 |
+
| Neutro | 0.0000 | 0.0000 | 0.0000 | 3 |
|
65 |
+
| Positivo | 0.6000 | 0.8750 | 0.7119 | 24 |
|
66 |
+
|
67 |
+
## Uso del Modelo
|
68 |
+
|
69 |
+
Este modelo puede ser utilizado para clasificar el sentimiento de textos en español en tres categorías: negativo, neutro y positivo.
|
70 |
+
|
71 |
+
```python
|
72 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
73 |
+
import torch
|
74 |
+
|
75 |
+
model_name = "nmarinnn/bert-schiaretti"
|
76 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
78 |
+
|
79 |
+
def predict(text):
|
80 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
|
81 |
+
with torch.no_grad():
|
82 |
+
outputs = model(**inputs)
|
83 |
+
|
84 |
+
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
85 |
+
predicted_class = torch.argmax(probabilities, dim=-1).item()
|
86 |
+
|
87 |
+
class_labels = {0: "negativo", 1: "neutro", 2: "positivo"}
|
88 |
+
return class_labels[predicted_class]
|
89 |
+
|
90 |
+
# Ejemplo de uso
|
91 |
+
texto = "Vamos schiaretti!"
|
92 |
+
sentimiento = predict(texto)
|
93 |
+
print(f"El sentimiento del texto es: {sentimiento}")
|
94 |
+
```
|
95 |
+
|
96 |
+
|
97 |
+
## Limitaciones
|
98 |
+
|
99 |
+
• El modelo muestra un rendimiento bajo en la clase "neutro", posiblemente debido a un desbalance en el dataset de entrenamiento.
|
100 |
+
• Se recomienda precaución al interpretar resultados para textos muy cortos o ambiguos.
|
101 |
+
|
102 |
+
## Información de Entrenamiento
|
103 |
+
|
104 |
+
• *Épocas*: 2
|
105 |
+
• *Pasos de entrenamiento*: 148
|
106 |
+
• *Pérdida de entrenamiento*: 0.6209
|
107 |
+
|
108 |
+
## Cita
|
109 |
+
|
110 |
+
Si utilizas este modelo en tu investigación, por favor cita:
|
111 |
+
|
112 |
+
|
113 |
+
@misc{marinnn2023bertschiaretti,
|
114 |
+
author = {Marin, Natalia},
|
115 |
+
title = {BERT Bregman - Modelo de Análisis de Sentimientos en Español},
|
116 |
+
year = {2023},
|
117 |
+
publisher = {HuggingFace},
|
118 |
+
journal = {HuggingFace Model Hub},
|
119 |
+
howpublished = {\url{https://huggingface.co/nmarinnn/bert-bregman}}
|
120 |
+
}
|