M4sterStudy commited on
Commit
65e1e1f
verified
1 Parent(s): 4bad5f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
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(**inputs, max_length=200, num_beams=4, early_stopping=True)
 
 
 
 
 
 
 
 
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()