From 3e5325fd0bb8dba17e24e6f339e3a141f9560112 Mon Sep 17 00:00:00 2001 From: Ye Jiachen <101981049+yjcexp@users.noreply.github.com> Date: Sun, 7 Jan 2024 01:46:08 +0800 Subject: [PATCH] Update __init__.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我觉得chat机器人应该不会需要把所有过程全输出来吧……只输出最终的句子似乎更合理? --- models/llama/__init__.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/models/llama/__init__.py b/models/llama/__init__.py index 085da15..59b4743 100644 --- a/models/llama/__init__.py +++ b/models/llama/__init__.py @@ -71,16 +71,12 @@ def run(self, input_text: str) -> str: return text_out def chat(self): - history = "" while True: - session = "用户输入: " input_text = input("用户输入: ") - session += input_text + "\n" - session += "LLaMA : " with jt.no_grad(): - for output_text in self.generator.generate([input_text], max_gen_len=256, temperature=0.8, top_p=0.95): - print(history + session + output_text, flush=True) - history += session + output_text + "\n" + output_text = self.generator.generate([input_text], max_gen_len=256, temperature=0.8, top_p=0.95) + output_text = list(output_text) + print("LLaMA : "+output_text[-1]) def run_web_demo(self, input_text, history=[]): response = self.run(input_text)