Godknows-nyandoro commited on
Commit
60a455d
·
verified ·
1 Parent(s): 8af69ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -21,9 +21,18 @@ def chatbot(message, history):
21
  prompt += f"User: {message}\nBot: "
22
 
23
  # Generate the response using the text-generation pipeline.
24
- # We use max_new_tokens to limit the length of the response for efficiency.
25
- # The return_full_text=False option ensures we only get the new text generated by the model.
26
- response = pipe(prompt, max_new_tokens=50, return_full_text=False)
 
 
 
 
 
 
 
 
 
27
 
28
  # Extract the generated text and clean up any extra whitespace or newlines.
29
  generated_text = response[0]['generated_text'].strip()
 
21
  prompt += f"User: {message}\nBot: "
22
 
23
  # Generate the response using the text-generation pipeline.
24
+ # We've increased max_new_tokens for longer responses and added other parameters
25
+ # to improve generation quality.
26
+ response = pipe(
27
+ prompt,
28
+ max_new_tokens=150,
29
+ return_full_text=False,
30
+ do_sample=True,
31
+ temperature=0.7,
32
+ top_k=50,
33
+ top_p=0.95,
34
+ repetition_penalty=1.2
35
+ )
36
 
37
  # Extract the generated text and clean up any extra whitespace or newlines.
38
  generated_text = response[0]['generated_text'].strip()