Update app.py
Browse files
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
|
| 25 |
-
#
|
| 26 |
-
response = pipe(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|