Ivan000 commited on
Commit
5213619
·
verified ·
1 Parent(s): 55a3261

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
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
- stream=True
 
54
  )
55
 
56
  response = ""
57
- for new_token in generated_ids[0][len(model_inputs.input_ids[0]):]:
58
- response += tokenizer.decode([new_token], skip_special_tokens=True)
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