QwenLM / Qwen

The official repo of Qwen (通义千问) chat & pretrained large language model proposed by Alibaba Cloud.
Apache License 2.0
13.59k stars 1.11k forks source link

[问题] vllm-wrapper中使用make_context引入了chatml template,这与直接使用llm.generate一致吗 #1117

Closed Davidgzx closed 6 months ago

Davidgzx commented 7 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

在https://qwen.readthedocs.io/en/latest/deployment/vllm.html 文档和 qwen-wrapper代码中,输入是被chatml template包装一下 在这篇(modelscope)[https://developer.aliyun.com/article/1380325] 中以及所有https://github.com/vllm-project/vllm/tree/main/examples的例子中,都是直接使用vllm的llm generate进行推理,没有使用模型对应的chat模版 image image image

我该如何正确在千问模型上使用vllm呢。

期望行为 | Expected Behavior

No response

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA (`python -c 'import torch; print(torch.version.cuda)'`):

备注 | Anything else?

No response

jklj077 commented 7 months ago

Please be advised that this is the Qwen(1.0) repository, and it appears you are using Qwen1.5 models.

请注意,这是Qwen(1.0)的存储库,而您希望使用的是Qwen1.5的模型。

Firstly, it's crucial to distinguish between base models (e.g., Qwen-7B) and chat models (e.g., Qwen-7B-Chat), as they are distinct model types. Base models only support text continuation, whereas chat models facilitate conversation through a specific template - in the case of Qwen, ChatML format is adopted for its chat models. Generally, for chat models, you need to apply this template to your input at some point during the process.

首先,必须明确区分基模型(例如Qwen-7B)和对话模型(例如Qwen-7B-Chat),它们是不同类型的模型。基础模型仅支持文本续写功能,而对话模型通过一种特殊的模板(Qwen-Chat采用ChatML格式)来支持对话。通常情况下,对于对话模型,需要在某个环节将此模板应用于输入内容。

Secondly, there are notable differences between Qwen 1.0 and Qwen 1.5, with each employing different methods to implement the chat template.

其次,Qwen 1.0和Qwen 1.5之间也存在显著差异,并且各自采用了不同的方法来应用对话模板。

In all, as of the current date, you should use apply_chat_template for latest chat models to enjoy the benefits from the broad support from the community.

总之,对于对话模型和最新版本的模型,您应使用apply_chat_template构造模型输入,以享受广泛的社区支持所带来的便利。