File size: 3,399 Bytes
4308771
68007cd
b792806
522bd5b
 
 
 
68007cd
 
 
 
 
 
 
 
522bd5b
ab3edcc
522bd5b
 
 
ab3edcc
522bd5b
68007cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4308771
7f9c6bd
ab3edcc
7f9c6bd
4308771
7f9c6bd
4308771
7f9c6bd
4308771
 
 
 
 
 
7f9c6bd
4308771
 
 
 
 
7f9c6bd
4308771
 
 
 
9b841fb
4308771
 
 
9b841fb
4308771
 
7f9c6bd
 
4308771
7f9c6bd
 
 
 
 
 
 
4308771
7f9c6bd
 
9b841fb
4308771
 
ef02d04
4308771
9b841fb
4308771
 
 
 
 
 
 
 
 
 
 
 
7f9c6bd
98dbc2e
4308771
 
 
 
 
 
 
 
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
---
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: "Bregman presidente!"
    example_title: "Ejemplo positivo"
  - text: "No estoy seguro si me gusta o no."
    example_title: "Ejemplo neutro"
  - text: "No saca más del 2%"
    example_title: "Ejemplo negativo"
model-index:
  - name: bert-bregman
    results:
      - task:
          type: text-classification
          name: Sentiment Analysis
        dataset:
          name: Custom Spanish Sentiment Dataset
          type: custom
        metrics:
          - type: accuracy
            value: 0.7432432432432432
          - type: f1
            value: 0.7330748170322471
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-bregman - 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.

## Rendimiento del Modelo

•⁠  ⁠*Accuracy*: 0.7432
•⁠  ⁠*F1 Score*: 0.7331
•⁠  ⁠*Precision*: 0.7483
•⁠  ⁠*Recall*: 0.7432

### 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-bullrich"
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 pato!"
sentimiento = predict(texto)
print(f"El sentimiento del texto es: {sentimiento}")
```

- 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{marinnn2023bertbregman,
  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}}
}