-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add DeepSeek-R1-0528 function call chat template #18874
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
Add DeepSeek-R1-0528 function call chat template #18874
Conversation
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
I use the following command to start server
and curl the server with the body
but I got the result as follows:
it seems like tool parser failed to contract the tool_calls parameters, have I use the wrong command ? |
@markluofd you can add tool_choice="required" in your request. |
failed too, seems like the response is not a json format😂
response as:
I extract the prompt from vllm log as:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me, thanks
I'm encountering an issue when trying to use the DeepSeek-R1-0528-Qwen3-8B model. It appears unsupported, returning Error 400:
|
Thanks for adding the support, @Xu-Wenqing. Btw, could you paste the test results in the PR description? Also do you want to include the updated version in this PR? It's fine to have another one to include the updated template. |
I'm experiencing the same with DeepSeek-R1-0528-Qwen3-8B as @NaiveYan is. IDK if it helps, but here's an ollama chat template that has tool calling working with this model: https://ollama.com/okamototk/deepseek-r1:8b/blobs/e94a8ecb9327 |
@alllexx88 my understanding of DeepSeek-R1-0528-Qwen3-8B is actually not DeepSeek R1 model, but Qwen3-8B model instead. Could you try Qwen3's function call chat template? |
@houseroad Thanks for the reply! I assume you're right, but it doesn't work for me with Qwen3's function call template:
I'm getting a response without any tools. My test code and outputfrom langchain.chat_models import init_chat_model
from pydantic import BaseModel, Field
llm = init_chat_model(
**{
"model": "deepseek-ai/DeepSeek-R1-0528-Qwen3-8B",
"base_url": "http://localhost:5003/v1",
"api_key": "NONE",
"model_provider": "openai",
"temperature": 0,
}
)
class GetWeather(BaseModel):
"""Get weather for a location"""
location: str = Field(description="The location to get the weather for")
llm_with_tools = llm.bind_tools([GetWeather])
res = llm_with_tools.invoke(
[{"role": "user", "content": "What's the weather like in Paris?"}]
)
print(res) Output:
The same code works fine with the ollama model:
P.S. Since it's probably a different model, should I open an issue for it instead of writing in this PR? Thanks! |
@alllexx88, yeah, I think creating another issue is a better choice, since we consider it as a separate issue. |
Not sure if it is a intentional, but this chat-template has some spaces at the beginning of some lines.. should we clean it up? the current version looks like this and here is my cleaned version. Let me know if it is helpful. |
@Xu-Wenqing I just tested with llama-stack-eval on your PR and it seems the non_streaming tool call failed as well, can you double check if it is a model problem or chat_template problem? CC: @houseroad
|
@houseroad @wukaixingxp @markluofd @NaiveYan @alllexx88 Sorry for the late reply. The past few days were Chinese Dragon Boat Festival, I didn’t check messages. I’ll try out the chat template on some test datasets again. Meanwhile, seems DeepSeek update DeepSeek-R1-0528 chat template: https://huggingface.co/deepseek-ai/DeepSeek-R1-0528/commit/4236a6af538feda4548eca9ab308586007567f52#d2h-846292 I will also update the template here. |
Error code: 400 - {'object': 'error', 'message': 'DeepSeek-V3 Tool parser could not locate tool call start/end tokens in the tokenizer! None', 'type': 'BadRequestError', 'param': None, 'code': 400}, if i use langchain will tool call agent, it will get the following error. vllm serve /deepseek-ai/DeepSeek-R1-0528-Qwen3-8B --tensor-parallel-size 8 --host 0.0.0.0 --port 10001 --api-key none --rope-scaling '{"factor": 2.0, "original_max_position_embeddings": 32768, "rope_type": "yarn"}' --gpu-memory-utilization 0.9 --enable-reasoning --reasoning-parser deepseek_r1 --guided_decoding_backend guidance --enable-auto-tool-choice --tool-call-parser deepseek_v3 --chat-template /home/ubuntu/wzr/LLM-MODELS/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B/tool_chat_template_deepseekr1.jinja --served-model-name DeepSeek-R1 |
I tried --tool-call-parser deepseek_v3 --chat-template examples/tool_chat_template_deepseekr1.jinja, and got Error code: 400 - {'object': 'error', 'message': 'DeepSeek-V3 Tool parser could not locate tool call start/end tokens in the tokenizer! None', 'type': 'BadRequestError', 'param': None, 'code': 400}, if I use --tool-call-parser hermes, vllm backend shows: The following fields were present in the request but ignored: {'function_call'}. I am using langchain agent to make tool calls, QWQ-32B, Qwen3 serires works fine for me. |
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
docs/features/tool_calling.md
Outdated
* `deepseek-ai/DeepSeek-V3-0324` | ||
* `deepseek-ai/DeepSeek-R1-0528` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this look in the docs?
* `deepseek-ai/DeepSeek-V3-0324` | |
* `deepseek-ai/DeepSeek-R1-0528` | |
* `deepseek-ai/DeepSeek-V3-0324` (`--tool-call-parser deepseek_v3 --chat-template examples/tool_chat_template_deepseekv3.jinja`) | |
* `deepseek-ai/DeepSeek-R1-0528` (`--tool-call-parser deepseek_v3 --chat-template examples/tool_chat_template_deepseekr1.jinja`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hmellor Updated the markdown file.
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
Signed-off-by: 许文卿 <xwq391974@alibaba-inc.com>
@houseroad Updated the chat template, and added test results in description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi,
Is anybody got success using this model and this PR ? |
DeepSeek-R1-0528 model support function call, add function call chat template.
Usage:
Function Call Test
Use Berkeley Function Calling Leaderboard to evaluate function call template here.
Evaluation Result:
🦍 Model: DeepSeek-R1-0528
🔍 Running test: simple
✅ Test completed: simple. 🎯 Accuracy: 0.9325
Number of models evaluated: 100%|███████████████████████████████████████████| 1/1 [00:00<00:00, 41.24it/s]
📈 Aggregating data to generate leaderboard score table...
🏁 Evaluation completed. See /Users/xuwenqing/function_call_eval/score/data_overall.csv for overall evaluation results on BFCL V3.