xu song commited on
Commit
b420ebd
1 Parent(s): c56ba55
Files changed (1) hide show
  1. models/cpp_qwen2.py +8 -7
models/cpp_qwen2.py CHANGED
@@ -47,7 +47,7 @@ class Qwen2Simulator(Simulator):
47
  n_ctx=config.MAX_SEQUENCE_LENGTH, #
48
  # n_threads=None, # 默认会根据cpu数来设置 n_threads
49
  use_mlock=True,
50
- verbose=False,
51
  )
52
  else:
53
  self.hf_tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct")
@@ -132,12 +132,13 @@ class Qwen2Simulator(Simulator):
132
  # TODO: 检测finish reason,如果是length,则shift,并继续生成。
133
  for out in output:
134
  stream = copy.deepcopy(out)
135
- generated_text += stream["choices"][0]["text"]
136
- if "all_text" in stream["choices"][0]:
137
- yield stream["choices"][0]["all_text"]
138
- else:
139
- logger.info("all_text not found")
140
- yield generated_text
 
141
 
142
 
143
  bot = Qwen2Simulator()
 
47
  n_ctx=config.MAX_SEQUENCE_LENGTH, #
48
  # n_threads=None, # 默认会根据cpu数来设置 n_threads
49
  use_mlock=True,
50
+ verbose=True,
51
  )
52
  else:
53
  self.hf_tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct")
 
132
  # TODO: 检测finish reason,如果是length,则shift,并继续生成。
133
  for out in output:
134
  stream = copy.deepcopy(out)
135
+ if stream["choices"][0]["finish_reason"] is not None:
136
+ generated_text += stream["choices"][0]["text"]
137
+ if "all_text" in stream["choices"][0]:
138
+ yield stream["choices"][0]["all_text"]
139
+ else:
140
+ logger.info("all_text not found")
141
+ yield generated_text
142
 
143
 
144
  bot = Qwen2Simulator()