mirror of
https://github.com/QwenLM/Qwen.git
synced 2026-05-20 16:35:47 +08:00
Update transformers_agent.md
This commit is contained in:
@@ -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,请多次尝试
|
||||
网络原因偶尔连不上HuggingFace,请多次尝试
|
||||
|
||||
Reference in New Issue
Block a user