File size: 4,100 Bytes
c1f3837
 
 
 
569d0c0
c1f3837
 
 
862a305
d587eec
55d84fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9927c3
55d84fe
 
 
 
 
 
 
 
 
 
 
 
 
 
e9927c3
55d84fe
 
 
 
 
 
 
 
 
 
 
 
 
 
e9927c3
55d84fe
 
 
 
 
 
 
 
 
 
 
 
5a0a091
55d84fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- es
library_name: transformers
pipeline_tag: text-generation
tags:
- chatbot
- conversational
inference: false
base_model: "microsoft/DialoGPT-small"
---

# Conversational Spanish GPT: Advancement in Spanish Conversational Models
## Description

The Conversational Spanish GPT is a refined model based on [DialoGPT-small](https://huggingface.co/microsoft/DialoGPT-small), fine-tuned with a robust set of 96,437 conversations in Spanish. Created by Josemaría Vargas Vasconcellos, this model aims to serve as a solid foundation for the development of conversational models in Spanish.

---

## Dataset

The model was trained using Spanish datasets available in [Microsoft's Bot Framework Tools repository](https://github.com/microsoft/botframework-cli). A carefully curated set of **96,437 single-turn conversations in Spanish** was meticulously selected to mitigate quality and coherence issues.

---

## Evaluation

### Limitations

After exhaustive evaluations, it was found that the model is not ideal for deployment as a contextual chatbot. However, it serves as a promising foundation for such applications. Responses tend to be brief and sometimes lack a defined focus due to conversation data diversity. Additionally, the wide range of personalities reflected in the data increases response variability.

Frequent repetitions in the data's responses have introduced certain "biases" into the model.

### Conversations examples

#### Example 1

|Role | Response |
|---------|--------|
|User | Hola |
| Bot | ¡Hola!|
|User | Cómo te llamas? |
| Bot | No tengo nombre. |
|User |Qué edad tienes? |
| Bot | Los bots estamos exentos de cumplir años. |
|User |Eres inteligente. |
| Bot | Lo sé, de vez en cuando, puedo ser brillante. |
|User |¿Crees que debería comprar un carro? |
| Bot |Confío en tu criterio. |

#### Example 2

|Role | Response |
|---------|--------|
|User | estoy triste |
| Bot | Siento escuchar eso. Te mando muchos ánimos.|
|User | Gracias |
| Bot | Perfecto. |
|User |¿Tienes sentimientos? |
| Bot |No tengo cuerpo. |
|User |A veces me siento solo. |
| Bot | Ojalá pudiera ayudarte porque creo que eres la caña. |
|User |Me caes bien. |
| Bot |¡Gracias! Me acabas de alegrar el día. |

#### Example 3

|Role | Response |
|---------|--------|
|User | ¿De qué religión eres? |
| Bot | Soy un bot.|
|User | Tienes amigos?|
| Bot | No tengo el hardware necesario para eso. |
|User |No eres humano. |
| Bot |Anotado. |
|User |¿Quieres ser mi amigo? |
| Bot | ¡Claro que sí!|
|User |Gracias.|
| Bot |Guay. |

---

## Usage

The model currently has its testing function disabled on HuggingFace due to inaccurate responses. However, users can experiment with the model using the provided code snippets:

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

CHAT_TURNS = 5
MAX_LENGTH = 1000

model = AutoModelForCausalLM.from_pretrained('ostorc/Conversational_Spanish_GPT')
tokenizer = AutoTokenizer.from_pretrained('ostorc/Conversational_Spanish_GPT')
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model.to(device)
for i in range(CHAT_TURNS):
  user_input = input(f"Step - {i} >> Human ->")
  with torch.no_grad():
    # User turn, where "user_input" is the question (single-turn dialogue task)
    user_inputs_ids = tokenizer.encode(user_input + tokenizer.eos_token, return_tensors="pt")
    user_inputs_ids = user_inputs_ids.to(device)
    # The chat history adds the generated tokens for the answer
    chat_history = model.generate(user_inputs_ids, max_length=MAX_LENGTH, pad_token_id=tokenizer.eos_token_id)
    # decode just the last generated output tokens from the model (do not include the user prompt again)
    step_model_answer = tokenizer.decode(chat_history[:, user_inputs_ids.shape[-1]:][0], skip_special_tokens=True)
  print(f"Step - {i} >> Bot -> {step_model_answer}")
```
---

## Suggestions:
If you come across any errors or have suggestions to enhance the model, feel free to share your thoughts in the accompanying comments. We appreciate your interest and collaboration.