Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,7 @@ def load_model_and_tokenizer():
|
|
27 |
)
|
28 |
return model, tokenizer
|
29 |
|
|
|
30 |
model, tokenizer = load_model_and_tokenizer()
|
31 |
|
32 |
# Generate Response
|
@@ -50,12 +51,13 @@ def generate_response(prompt, chat_history):
|
|
50 |
top_k=50,
|
51 |
top_p=0.95,
|
52 |
temperature=0.7,
|
53 |
-
|
|
|
54 |
)
|
55 |
|
56 |
response = ""
|
57 |
-
for
|
58 |
-
response += tokenizer.decode([
|
59 |
yield response
|
60 |
|
61 |
# Clear Chat History
|
|
|
27 |
)
|
28 |
return model, tokenizer
|
29 |
|
30 |
+
# Ensure the model and tokenizer are loaded
|
31 |
model, tokenizer = load_model_and_tokenizer()
|
32 |
|
33 |
# Generate Response
|
|
|
51 |
top_k=50,
|
52 |
top_p=0.95,
|
53 |
temperature=0.7,
|
54 |
+
output_scores=True,
|
55 |
+
return_dict_in_generate=True
|
56 |
)
|
57 |
|
58 |
response = ""
|
59 |
+
for token_id in generated_ids.sequences[0][len(model_inputs.input_ids[0]):]:
|
60 |
+
response += tokenizer.decode([token_id], skip_special_tokens=True)
|
61 |
yield response
|
62 |
|
63 |
# Clear Chat History
|