Fix qwen tool template to official format #2988
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR type
PR information
当前的 qwen-template(tool)在多个 tools 时,会被解析为如下的格式(例如 13 个工具)
... ## 你可以在回复中插入以下命令以调用这些工具: ✿FUNCTION✿:工具1的名称 ✿ARGS✿:工具1的输入 ✿RESULT✿:工具1的结果 ✿FUNCTION✿:工具2的名称 ✿ARGS✿:工具2的输入 ✿RESULT✿:工具2的结果 ✿FUNCTION✿:工具3的名称 ✿ARGS✿:工具3的输入 ✿RESULT✿:工具3的结果 ✿FUNCTION✿:工具4的名称 ✿ARGS✿:工具4的输入 ✿RESULT✿:工具4的结果 ✿FUNCTION✿:工具5的名称 ✿ARGS✿:工具5的输入 ✿RESULT✿:工具5的结果 ✿FUNCTION✿:工具6的名称 ✿ARGS✿:工具6的输入 ✿RESULT✿:工具6的结果 ✿FUNCTION✿:工具7的名称 ✿ARGS✿:工具7的输入 ✿RESULT✿:工具7的结果 ✿FUNCTION✿:工具8的名称 ✿ARGS✿:工具8的输入 ✿RESULT✿:工具8的结果 ✿FUNCTION✿:工具9的名称 ✿ARGS✿:工具9的输入 ✿RESULT✿:工具9的结果 ✿FUNCTION✿:工具10的名称 ✿ARGS✿:工具10的输入 ✿RESULT✿:工具10的结果 ✿FUNCTION✿:工具11的名称 ✿ARGS✿:工具11的输入 ✿RESULT✿:工具11的结果 ✿FUNCTION✿:工具12的名称 ✿ARGS✿:工具12的输入 ✿RESULT✿:工具12的结果 ✿FUNCTION✿:工具13的名称 ✿ARGS✿:工具13的输入 ✿RESULT✿:工具13的结果 ✿FUNCTION✿:工具14的名称 ✿ARGS✿:工具14的输入 ✿RESULT✿:工具14的结果
而正确的版本,参考如下链接:
可以看到相比较正确的格式,当前错误有几个:
✿RESULT✿
是放在模板最后的request
中的 tools 数量无关(否则会导致prefix-caching
不能完全发挥作用)json.dump
处理中文时,会转换为 ascii 格式,导致模型处理中文时出现莫名其妙的问题。需要加入ensure_ascii=False
来保证中文等字符的处理。这个 PR 修正以上错误,和官方版本对齐。
Experiment results
Paste your experiment result here(if needed).