Support for Qwen2.5-VL model in Multi-turn Sglang Rollout with Tool-Calling
I am using the multi-turn sglang rollout with tool-call feature. In the document, https://github.com/volcengine/verl/blob/main/docs/sglang_multiturn/multiturn.rst, I see that this feature supports multi-modal inputs for Qwen 2.5-VL model. However, the chat template related to tool call in Qwen 2.5-3B (for example) (in geo3k example) is very different from that of Qwen 2.5-VL-3B. This results in many differences when I build my tools for Qwen 2.5-VL-3B. For example, chat template of Qwen 2.5-3B will add a <tool_call>functions and arguments</too_lcall> message to show the tool-calling process (also for gradient computation), and add a <tool_response>some resp</tool_response> message for the . Also at the begining of the conversation, it automately prints many discriptions of the tools available. Actually, these features are not available for all the Qwen2.5-vl-3B, due to the differences in chat template. I wonder if you could provide us a example of "Support for Qwen2.5-VL model in Multi-turn Sglang Rollout with Tool-Calling". It seems that this is supported from yourn tutorial of handling multi-modal inputs and outputs (also the source codes), but I after I implement my own tools under your instructions, training fails (kl loss high, and rewards drop severely). Wondering if this difference in chat template results in bugs of multi-modal tool calling. Expecting more communications/elaborations, also feel free to add my WeChat in my homepage.
By the way, @eric-haibin-lin I also noticed your streaming in Pytorch community in 2:00 a.m., 7th, August. Will this streaming have a record online? Wish to see your explanation of these new features online.
Also, thank the verl team for supporting these tool calling features!
Hi @jackhu-bme, please make sure AutoProcessor.from_pretrained(actor_rollout_ref.model.path) is Qwen2_5_VLProcessor.
verl will automatically handle the template. FYI:
https://github.com/volcengine/verl/blob/05eb0c7a6d30e2246548be2dff44c8340178f92a/verl/workers/rollout/schemas.py#L221-L235
The processing class is specialized for VL model, correct.
What I mean is the difference within the red-boxed chat template.
One difference between Qwen-3B-VL and Qwen-3B is the tool_call behavior within this template, except for the logics of image/video processing.
If you compare vl-chat and plan-chat, you will see the tool_call differences.
The first url contains only two "tool_call" in json, and the second contains 16 "tool_call" in json-format chat templates.
This cause many differences related to message processing, including:
For example, chat template of Qwen 2.5-3B will add a <tool_call>functions and arguments</too_lcall> message to show the tool-calling process (also for gradient computation), and add a <tool_response>some resp</tool_response> message for the . Also at the begining of the conversation, it automately prints many discriptions of the tools available.
If you see the logged validation generations, you will see more differences. I will share some screenshots later, but the full code is not released. From my perspective, this will cause many many troubles (I rewrote the chat templates, still in-progress), including not backwarding gradients of the original <tool_call> message generated by the VLM.
It seems that the official processor of Qwen2.5-VL-7B-Instruct does not support tool calling, right? chat-template
Yes! Same thing for 3B-VL, I remember.
It seems that the official processor of
Qwen2.5-VL-7B-Instructdoes not support tool calling, right? chat-template
One Strange thing is that the processor has a special token for <tool_call>, but it does not make special processing to tool call messages. Can we just simply chaneg the chat template, from your suggestion? I guess just integrate original logics for processing image and video, and add the tool call features? Can you point/find something wrong with my suggestion/idea?
If the released chat_template does not handle tool calling, then it can be inferred that the model most likely was not trained for it either during pretraining.
So, it's not suitable to modify the template, as this could lead to a decline in instruction-following ability.
Possible solution might be one-shot prompt engineering. (Most of the VLMs tool calling do this from what I've seen)
I am using the multi-turn sglang rollout with tool-call feature. In the document, https://github.com/volcengine/verl/blob/main/docs/sglang_multiturn/multiturn.rst, I see that this feature supports multi-modal inputs for Qwen 2.5-VL model.
The doc is out-dated, I will submit a PR for that.
If the released chat_template does not handle tool calling, then it can be inferred that the model most likely was not trained for it either during pretraining.
So, it's not suitable to modify the template, as this could lead to a decline in instruction-following ability.
Possible solution might be one-shot prompt engineering. (Most of the VLMs tool calling do this from what I've seen)
One-shot prompt engineering is useful. From my experiments, without training, 3B VL models could correctly use my tools for over 50% cases, just by a very brief instruction at the begining. (similar to instructions in chat template of qwen 3b). However, the chat template is not supported currently. Any recommendations of other VLMs which support tool call? This doc and related code has supported VLMs, it is such a pity if all the VLMs are abandoned.
So, it's not suitable to modify the template, as this could lead to a decline in instruction-following ability.
I do not quite understand the reason, what if our research goal is to make the VLM learn to follow instructions and use the tools? By one-shot prompts, it can already successfully use the tool (just json format tool, just some locations which qwen models can do) in most of cases, and RL could help it perform better. In my perspective, if modify the chat template could make the experiments run normally without other bugs, this solution can be reasonable.
Any recommendations of other VLMs which support tool call? This doc and related code has supported VLMs, it is such a pity if all the VLMs are abandoned.
stepfun can: stepfun-ai/step3
what if our research goal is to make the VLM learn to follow instructions and use the tools?
You can use one-shot prompt to reach your goal, without modifying the chat-template.
if modify the chat template could make the experiments run normally without other bugs, this solution can be reasonable.
Yes you can modify the template for downstream finetuning. But this model might not be used as general any more.
Thanks a lot, for stepfun model, I do not need to modify the chat template. For qwen, I could modify, but the model will not be used as general. Right? Thanks a lot for clarifying this.
You got it.
Thanks a lot, for stepfun model, I do not need to modify the chat template. For qwen, I could modify, but the model will not be used as general. Right? Thanks a lot for clarifying this.
You can refer to #2398.
Thanks a lot, for stepfun model, I do not need to modify the chat template. For qwen, I could modify, but the model will not be used as general. Right? Thanks a lot for clarifying this.
You can refer to #2398.
Thanks a lot, this feature is so close to my project!