Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat Template 更新后 vLLM reasoning-parser 无法正确处理 #350

Open
haowang-cqu opened this issue Feb 10, 2025 · 3 comments
Open

Comments

@haowang-cqu
Copy link

注意到昨天 HuggingFace Hub 中 DeepSeek-R1 包括其蒸馏版本的 Chat Template (tokenizer_config.json 中) 有所更新,主要是在其末尾增加了 <think>\\n。我猜测这个更新是为了强制 DeepSeek-R1 从思考内容开始生成,从而避免其绕过思考。

遗憾的是这个更新导致 vLLM 中的 reasoning-parser 不再按预期工作。

不知道 vLLM 中的 deepseek_r1 reasoning-parser 是哪边在维护,希望能尽快修复。

谢谢!

@deepsicker
Copy link

deepsicker commented Feb 10, 2025

不再按预期工作 是什么意思报错了? 还是?show your code,
我的代码这里没问题啊https://www.yuque.com/unreal/gpynrn/so9tml5v3dv9x6ra#UlZwT

@haowang-cqu
Copy link
Author

您好,这是我启动 vLLM 的命令:

vllm serve deepseek-ai/DeepSeek-R1-Distill-Llama-70B \
  --tensor-parallel-size 4 \
  --max-model-len 32768 \
  --enforce-eager \
  --enable-reasoning \
  --reasoning-parser deepseek_r1

成功启动后我用以下命令尝试对话:

curl http://127.0.0.1:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer 123" \
  -d '{
     "model": "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
     "messages": [{"role": "user", "content": "11.11和11.8哪个大?"}],
     "temperature": 0.6
   }'

以下是 vLLM 的返回结果:

{
  "id": "chatcmpl-a0ffb8160ecc4416890273d949345123",
  "object": "chat.completion",
  "created": 1739170216,
  "model": "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "reasoning_content": null,
        "content": "首先,比较两个数的整数部分。11.11和11.8的整数部分都是11,因此整数部分相同。\n\n接下来,比较小数部分。11.11的小数部分是0.11,11.8的小数部分是0.8。\n\n将0.8转换为相同的小数位数,即0.80,与0.11进行比较。\n\n显然,0.80大于0.11。\n\n因此,11.8大于11.11。\n</think>\n\n**问题**:11.11 和 11.8 哪个大?\n\n**解答**:\n\n1. **比较整数部分**:\n   - 11.11 的整数部分是 **11**\n   - 11.8 的整数部分也是 **11**\n   \n   整数部分相同,继续比较小数部分。\n\n2. **比较小数部分**:\n   - 11.11 的 小数部分是 **0.11**\n   - 11.8 的小数部分是 **0.8**(可以写成 **0.80** 以便比较)\n   \n   比较 **0.11** 和 **0.80**:\n   \\[\n   0.11 < 0.80\n   \\]\n   \n   因此,11.8 的小数部分大于 11.11 的小数部分。\n\n**结论**:\n\\[\n11.8 > 11.11\n\\]\n\n最终答案:\\(\\boxed{11.8}\\)",
        "tool_calls": []
      },
      "logprobs": null,
      "finish_reason": "stop",
      "stop_reason": null
    }
  ],
  "usage": {
    "prompt_tokens": 16,
    "total_tokens": 339,
    "completion_tokens": 323,
    "prompt_tokens_details": null
  },
  "prompt_logprobs": null
}

可以看到 reasoning_content 字段为 null,而实际的思考内容包括 </think> 标签都被包含在 content 字段中。
我想这是预期的,因为在 HuggingFace Hub 中的 Chat Template 被更新前思考的内容能顺利被解析到 reasoning_content 字段中。

以下是我的系统信息:

vllm                              0.7.2
transformers                      4.48.3

@ariesfish
Copy link

ariesfish commented Feb 10, 2025

注意到昨天 HuggingFace Hub 中 DeepSeek-R1 包括其蒸馏版本的 Chat Template (tokenizer_config.json 中) 有所更新,主要是在其末尾增加了 <think>\\n。我猜测这个更新是为了强制 DeepSeek-R1 从思考内容开始生成,从而避免其绕过思考。

遗憾的是这个更新导致 vLLM 中的 reasoning-parser 不再按预期工作。

不知道 vLLM 中的 deepseek_r1 reasoning-parser 是哪边在维护,希望能尽快修复。

谢谢!

参考
#352 (comment)
可以解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants