Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,15 @@ model = AutoModelForCausalLM.from_pretrained(model_name)
|
|
| 14 |
|
| 15 |
def chat_with_gpt2_spanish(input_text):
|
| 16 |
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
|
| 17 |
-
outputs = model.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 19 |
return response
|
| 20 |
|
|
@@ -27,4 +35,4 @@ iface = gr.Interface(
|
|
| 27 |
description="Interfaz simple para comunicarte con el modelo GPT-2 en espa帽ol."
|
| 28 |
)
|
| 29 |
|
| 30 |
-
iface.launch()
|
|
|
|
| 14 |
|
| 15 |
def chat_with_gpt2_spanish(input_text):
|
| 16 |
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
|
| 17 |
+
outputs = model.generate(
|
| 18 |
+
**inputs,
|
| 19 |
+
max_length=100, # Limitar la longitud de la respuesta
|
| 20 |
+
num_beams=1, # Usar solo un haz para velocidad
|
| 21 |
+
temperature=0.7, # Ajustar la temperatura para respuestas menos repetitivas
|
| 22 |
+
top_p=0.9, # Usar top-p (nucleus sampling) para variedad
|
| 23 |
+
no_repeat_ngram_size=2, # Evitar la repetici贸n de n-gramas
|
| 24 |
+
early_stopping=True
|
| 25 |
+
)
|
| 26 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 27 |
return response
|
| 28 |
|
|
|
|
| 35 |
description="Interfaz simple para comunicarte con el modelo GPT-2 en espa帽ol."
|
| 36 |
)
|
| 37 |
|
| 38 |
+
iface.launch()
|