ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

使用PtEngine推理和vllm部署后推理,结果相差很大

Open flashcp opened this issue 1 year ago • 5 comments

你好,有一个推理问题想咨询下。

对qwen2.5-VL-7B进行rlhf训练,开启lora。对训练后得到的模型进行merge,模型地址为model_path。 swift export \ --adapters model_path \ --merge_lora true

两者的输入query简化如下 [{"role": "system", "content": "你是一个能够处理文字与图片信息的多模态智能助理。\n下面将给出用户的【输入信息】:"}, {"role": "user", "content": [{"type": "text", "text": "【原始问句】:帮我在app完成缴费,我的车牌号是#123456#。\n"}]}]

使用PtEngine进行推理,推理代码

request_config = RequestConfig(max_tokens=512, temperature=0)
metric = InferStats()
resp_list = engine.infer(query, request_config, metrics=[metric])
content = [i.choices[0].message.content for i in resp_list]
print(content)

打印结果如下: <think>首先需要打开app来开始缴费流程。</think><answer>打开app。</answer><action>{"open_app": {"app_name": "AA"}}</action>

使用vllm部署,部署脚本如下: vllm serve $model_path --port 8000 --host 0.0.0.0 --dtype float16 --served_model_name Qwen2.5-VL-7B-Instruct --max-model-len 12800

相同query请求vllm,请求参数max_tokens=512,temperature=0.0,和PtEngine保持一致,打印结果: <think>首先需要点击输入框,然后逐个字符输入车牌号“123456”。</think><answer>点击输入框的第一个字符位置,准备输入车牌号的第一个字符。</answer><action>{"click": {"coordinates": [175, 155]}}</action>

PtEngine推理结果符合预期,vllm推理结果偏差太大了,甚至没有输入图片,但是却输出了click。请问这个会是什么原因导致的

flashcp avatar Sep 25 '25 07:09 flashcp

你试试使用VllmEngine推理

Jintao-Huang avatar Sep 26 '25 06:09 Jintao-Huang

我的也是这个情况,sft后推理跟vllm部署结果差很多

fjw1049 avatar Sep 26 '25 10:09 fjw1049

我的也是pt推理似乎有bug,每次都只输出一个字符

faker52 avatar Sep 27 '25 14:09 faker52

This issue has been inactive for over 3 months and will be automatically closed in 7 days. If this issue is still relevant, please reply to this message.

github-actions[bot] avatar Dec 27 '25 00:12 github-actions[bot]

This issue has been automatically closed due to inactivity. If needed, it can be reopened.

github-actions[bot] avatar Jan 04 '26 00:01 github-actions[bot]