nikravan commited on
Commit
5a07c64
·
verified ·
1 Parent(s): a259ca0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -55,7 +55,8 @@ latex_delimiters_set = [{
55
  def predict(message, history, system_prompt, temperature, max_new_tokens, top_k, repetition_penalty, top_p):
56
  # Format history with a given chat template
57
 
58
- #stop_tokens = [tokenizer.eos_token_id]
 
59
  instruction = system_prompt + "\n\n"
60
  for user, assistant in history:
61
  instruction += f"<|User|>{user}<|Assistant|>{assistant}\n"
@@ -87,8 +88,8 @@ def predict(message, history, system_prompt, temperature, max_new_tokens, top_k,
87
  outputs = []
88
  for new_token in streamer:
89
  outputs.append(new_token)
90
- #if new_token in stop_tokens:
91
- #break
92
  yield "".join(outputs)
93
 
94
 
 
55
  def predict(message, history, system_prompt, temperature, max_new_tokens, top_k, repetition_penalty, top_p):
56
  # Format history with a given chat template
57
 
58
+ stop_tokens = [tokenizer.eos_token_id]
59
+ pad_token_id=[tokenizer.eos_token_id] #151643
60
  instruction = system_prompt + "\n\n"
61
  for user, assistant in history:
62
  instruction += f"<|User|>{user}<|Assistant|>{assistant}\n"
 
88
  outputs = []
89
  for new_token in streamer:
90
  outputs.append(new_token)
91
+ if new_token in stop_tokens:
92
+ break
93
  yield "".join(outputs)
94
 
95