QwenLM / Qwen2.5-Coder

Qwen2.5-Coder is the code version of Qwen2.5, the large language model series developed by Qwen team, Alibaba Cloud.
3.1k stars 210 forks source link

Does qwen2.5-coder support function calling? #180

Closed Muuut closed 1 day ago

Muuut commented 4 days ago

According to the documentation, I use VLLM to build a openai compatible server for qwen2.5-coder-7b-instruct.

That is my code

messages = [
    {
        "role": "user",
        "content": "Calculate how many r's are in the word 'strawberry'"
    }
]

# Define the tools
tools = [{
    "type": "function",
    "function": {
        "name": "execute_python",
        "description": "Execute python code in a Jupyter notebook cell and return result",
        "parameters": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string",
                    "description": "The python code to execute in a single cell"
                }
            },
            "required": ["code"]
        }
    }
}]

# Generate text with OpenAI
response = client.chat.completions.create(
    model="qwen2.5-7B-coder",
    messages=messages,
    tools=tools,
)

However, I got this: 屏幕截图 2024-11-26 124247 The finish_reason is "stop" instead of "tool_calls", and the tool_calls is empty. So I wonder whether qwen2.5-coder series support function calling?

sagarey commented 3 days ago

same problem recurred on Qwen2.5-Coder-32B-instruct deployed by vllm, while Qwen2.5-32B-instruct support function calling as expected.

Muuut commented 1 day ago

same problem recurred on Qwen2.5-Coder-32B-instruct deployed by vllm, while Qwen2.5-32B-instruct support function calling as expected.

I did not set the system content in the message before. After setting, function calling works normally.

sagarey commented 1 day ago

same problem recurred on Qwen2.5-Coder-32B-instruct deployed by vllm, while Qwen2.5-32B-instruct support function calling as expected.

I did not set the system content in the message before. After setting, function calling works normally.

Default qwen system prompt? I tried it, and still the problem that tool_calls is empty and content returns tool call string. Whether it is Qwen2.5-Coder-32B-instruct or Qwen2.5-Coder-7B-instruct, without any adjustments, only model switch to Qwen2.5-32B-instruct or Qwen2.5-7B-instruct can tool_calls be obtained correctly.