File size: 3,475 Bytes
a310681
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language: es
tags:
  - sentiment-analysis
  - text-classification
  - spanish
  - xlm-roberta
license: mit
datasets:
  - custom
metrics:
  - accuracy
  - f1
library_name: transformers
pipeline_tag: text-classification
widget:
  - text: "Vamos milei!"
    example_title: "Ejemplo positivo"
  - text: "el otro día pensaba eso"
    example_title: "Ejemplo neutro"
  - text: "gatito mimoso"
    example_title: "Ejemplo negativo"
model-index:
  - name: bert-milei
    results:
      - task:
          type: text-classification
          name: Sentiment Analysis
        dataset:
          name: Custom Spanish Sentiment Dataset
          type: custom
        metrics:
          - type: accuracy
            value: 0.677
          - type: f1
            value: 0.664
architectures:
  - XLMRobertaForSequenceClassification
transformers_version: "4.41.2"
base_model: cardiffnlp/twitter-xlm-roberta-base-sentiment
inference:
  parameters:
    temperature: 1.0
    max_length: 512
    num_return_sequences: 1
---

# BERT-massa - Modelo de Análisis de Sentimientos en Español

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.

## Rendimiento del Modelo

•⁠  ⁠*Accuracy*: 0.
•⁠  ⁠*F1 Score*: 0.
•⁠  ⁠*Precision*: 0.
•⁠  ⁠*Recall*: 0.

### Métricas por Clase

| Clase    | Precision | Recall | F1-Score | Support |
|----------|-----------|--------|----------|---------|
| Negativo | 0.8718    | 0.7234 | 0.7907   | 47      |
| Neutro   | 0.0000    | 0.0000 | 0.0000   | 3       |
| Positivo | 0.6000    | 0.8750 | 0.7119   | 24      |

## Uso del Modelo

Este modelo puede ser utilizado para clasificar el sentimiento de textos en español en tres categorías: negativo, neutro y positivo.

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

model_name = "nmarinnn/bert-milei"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

def predict(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
    with torch.no_grad():
        outputs = model(**inputs)
    
    probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
    predicted_class = torch.argmax(probabilities, dim=-1).item()
    
    class_labels = {0: "negativo", 1: "neutro", 2: "positivo"}
    return class_labels[predicted_class]

# Ejemplo de uso
texto = "Vamos milei!"
sentimiento = predict(texto)
print(f"El sentimiento del texto es: {sentimiento}")
```
 

## Limitaciones

•⁠  ⁠El modelo muestra un rendimiento bajo en la clase "neutro", posiblemente debido a un desbalance en el dataset de entrenamiento.
•⁠  ⁠Se recomienda precaución al interpretar resultados para textos muy cortos o ambiguos.

## Información de Entrenamiento

•⁠  ⁠*Épocas*: 2
•⁠  ⁠*Pasos de entrenamiento*: 148
•⁠  ⁠*Pérdida de entrenamiento*: 0.6209

## Cita

Si utilizas este modelo en tu investigación, por favor cita:


@misc{marinnn2023bertmilei,
  author = {Marin, Natalia},
  title = {BERT Bregman - Modelo de Análisis de Sentimientos en Español},
  year = {2023},
  publisher = {HuggingFace},
  journal = {HuggingFace Model Hub},
  howpublished = {\url{https://huggingface.co/nmarinnn/bert-bregman}}
}