From 4e1b09dde193557175dda4687ad70dd78d09ef7c Mon Sep 17 00:00:00 2001 From: Jianxin Ma Date: Thu, 3 Aug 2023 21:29:56 +0800 Subject: [PATCH] Update transformers_agent.md --- examples/transformers_agent.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/transformers_agent.md b/examples/transformers_agent.md index 017fcc4..17165a4 100644 --- a/examples/transformers_agent.md +++ b/examples/transformers_agent.md @@ -56,10 +56,16 @@ class QWenAgent(Agent): ) def generate_one(self, prompt, stop): + # "Human:" 和 "Assistant:" 曾为通义千问的特殊保留字,需要替换为 "_HUMAN_:" 和 "_ASSISTANT_:"。这一问题将在未来版本修复。 + prompt = prompt.replace("Human:", "_HUMAN_:").replace("Assistant:", "_ASSISTANT_:") + stop = [item.replace("Human:", "_HUMAN_:").replace("Assistant:", "_ASSISTANT_:") for item in stop] + result, _ = self.model.chat(self.tokenizer, prompt, history=None) for stop_seq in stop: if result.endswith(stop_seq): result = result[: -len(stop_seq)] + + result = result.replace("_HUMAN_:", "Human:").replace("_ASSISTANT_:", "Assistant:") return result @@ -99,4 +105,4 @@ HuggingFace Agent官方14个tool: > agent.run(xxx, remote=True) HuggingFace没有在线部署的模型会自动下载checkpoint进行本地inference -网络原因偶尔连不上HuggingFace,请多次尝试 \ No newline at end of file +网络原因偶尔连不上HuggingFace,请多次尝试