Skip to content

Tool Call Issues with Qwen2.5-VL Models (7B & 72B) under vLLM #1093

Description

@edwardzjl

Hi there, thanks for the awesome work!

I've been experimenting with the Qwen2.5-VL models to build agent workflows, but I’ve run into a few issues when combining the VLMs with tools.

Chat Template Compatibility

First of all, it seems that the default chat templates provided for Qwen2.5-VL-7B-Instruct, Qwen2.5-VL-32B-Instruct or Qwen2.5-VL-72B-Instruct don't seem to support tool usage out of the box.

To work around this, I created a custom chat template that merges the multi-modal input format with the tool call part used in the non-VLM Qwen models (like this one from tokenizer_config.json). Based on some unit tests, I believe it should render prompts correctly (we’ll see the results later).

Test Setup

I deployed the model using vllm (0.8.2) with the following command (simplified for clarity):

vllm serve Qwen/Qwen2.5-VL-7B-Instruct --enable-auto-tool-choice --tool-call-parser hermes --chat-template /etc/qwen2.5-vl-7b-instruct/chat_template.jinja

Then I ran this basic test case, trying both with and without the sampling args:

from openai import OpenAI

client = OpenAI(base_url="http://qwen2dot5-vl-72b-instruct.myns.svc/v1", api_key="dummy")

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current temperature for a given location.",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City and country e.g. Bogotá, Colombia"
                    }
                },
                "required": ["location"],
                "additionalProperties": "false"
            }
        }
    }
]

msgs = [
    {"role": "user", "content": "What is the weather like in London today?"}
]

response = client.chat.completions.create(
    model=client.models.list().data[0].id,
    messages=msgs,
    tools=tools
    # temperature=0.7,
    # top_p=0.8,
    # extra_body={"repetition_penalty": 1.05}
)

response.choices[0].message.content

Unexpected Behavior

Unfortunately, neither the 7B nor the 72B model handles tool usage properly:

  • 7B model ignores the tools entirely and always replies with something like:

    <tool_call>\n addCriterion\n<tool_call>\n\n\n\n\n\n\n\n\n\n
    
  • 72B model seems to recognize the tool but includes emojis and always without the closing XML tag:

    <tool_call>\n📐\n{"name": "get_weather", "arguments": {"location": "London, UK"}}\n📐
    

Additional Debug Info

Here’s the system prompt after the template is rendered (from server logs):

<|im_start|>system
You are Qwen, created by Alibaba Cloud. You are a helpful assistant.

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"type": "function", "function": {"name": "get_weather", "description": "Get current temperature for a given location.", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "City and country e.g. Bogotá, Colombia"}}, "required": ["location"], "additionalProperties": "false"}}}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call><|im_end|>
<|im_start|>user
What is the weather like in London today?<|im_end|>
<|im_start|>assistant
full log entry
INFO 04-10 18:48:20 [logger.py:39] Received request chatcmpl-7acf794f-d260-4ff0-9ff4-8d881055f507: prompt: '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{"type": "function", "function": {"name": "get_weather", "description": "Get current temperature for a given location.", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "City and country e.g. Bogotá, Colombia"}}, "required": ["location"], "additionalProperties": "false"}}}\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{"name": <function-name>, "arguments": <args-json-object>}\n</tool_call><|im_end|>\n<|im_start|>user\nWhat is the weather like in London today?<|im_end|>\n<|im_start|>assistant\n', params: SamplingParams(n=1, presence_penalty=0.0, frequency_penalty=0.0, repetition_penalty=1.05, temperature=1.0, top_p=0.001, top_k=1, min_p=0.0, seed=None, stop=[], stop_token_ids=[], bad_words=[], include_stop_str_in_output=False, ignore_eos=False, max_tokens=32573, min_tokens=0, logprobs=None, prompt_logprobs=None, skip_special_tokens=True, spaces_between_special_tokens=True, truncate_prompt_tokens=None, guided_decoding=None, extra_args=None), prompt_token_ids: None, lora_request: None, prompt_adapter_request: None.

Any ideas on what might be going wrong? Are there any recommended best practices or known limitations when using Qwen2.5-VL models with tools in this way?

Thanks again for the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions