{
"bos_token": "",
"eos_token": "",
"pad_token": "",
"unk_token": "",
"cls_token": "<|begin_of_sentence|>",
"sep_token": "<|end_of_sentence|>",
"mask_token": "",
"sys_start_token": "",
"sys_end_token": "",
"header_start_token": "",
"header_end_token": "",
"additional_special_tokens": null,
"tokenizer_class": "Ernie4_5_VLTokenizer",
"auto_map": {
"AutoTokenizer": [
"processing_ernie4_5_vl.Ernie4_5_VLTokenizer",
null
]
},
"chat_template": "{%- if chat_template_kwargs is defined and chat_template_kwargs.options is defined -%}\n {%- set options = chat_template_kwargs.options -%}\n{%- endif -%}\n{#- 定义 options.thinking_mode 的默认值 -#}\n{%- if options is not defined -%}\n {%- set options = {'thinking_mode': true} -%}\n{%- endif -%}\n{%- set thinking_enabled = options.get('thinking_mode', true) in ['open', 'true', true] -%}\n{%- set image_count = namespace(value=0) -%}\n{%- set video_count = namespace(value=0) -%}\n{% macro render_content(content_list, accumulate=True, role=\"user\") %}\n {%- for content_item in content_list -%}\n {%- if content_item.type == 'text' -%}\n {{- content_item.text }}\n {%- elif content_item.type in ['image_url', 'image'] -%}\n {%- if accumulate -%}\n {%- set image_count.value = image_count.value + 1 -%}\n {%- endif -%}\n {{ ' ' }}Picture{{ ' ' ~ image_count.value if accumulate else '' }}:<|IMAGE_START|><|image@placeholder|><|IMAGE_END|>\n {%- elif content_item.type in ['video_url', 'video'] -%}\n {%- if accumulate -%}\n {%- set video_count.value = video_count.value + 1 -%}\n {%- endif -%}\n {{ ' ' }}Video{{ ' ' ~ video_count.value if accumulate else '' }}:<|VIDEO_START|><|video@placeholder|><|VIDEO_END|>\n {%- if content_item.video_url is defined and content_item.video_url.subtitles is defined and content_item.video_url.subtitles -%}\n {{ ' ' }}: {%- for subtitle in content_item.video_url.subtitles -%}\n [{{ \"%.1f\"|format(subtitle[1]) }},{{ \"%.1f\"|format(subtitle[2]) }}]{{ subtitle[0] }}\n {%- endfor -%} {{ ' ' }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n{% endmacro %}\n{#- ---- 定义 message 渲染 ---- -#}\n{%- macro build_messages(messages) -%}\n {#- ---- 初始化 多模态计数器 ---- -#}\n {%- for message in messages -%}\n {%- if message.content is string -%}\n {%- set content = message.content -%}\n {%- elif message.content is iterable -%}\n {%- set content = render_content(message.content, True, message.role) -%}\n {%- else -%}\n {%- set content = '' -%}\n {%- endif -%}\n {%- if (message.role == \"user\") -%}\n {{- 'User: ' + content-}}\n {%- elif (message.role == \"system\" and not loop.first) -%}\n {{- content + '\n' -}}\n {%- elif message.role == \"assistant\" -%}\n {{- '\nAssistant: ' -}}\n {%- set reasoning_content = '' -%}\n {%- if message.reasoning_content is defined and message.reasoning_content is string -%}\n {%- set reasoning_content = message.reasoning_content -%}\n {%- else -%}\n {%- if '' in content -%}\n {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') -%}\n {%- set content = content.split('')[-1].lstrip('\n') -%}\n {%- endif -%}\n {%- endif -%}\n {%- if loop.last or (not loop.last and reasoning_content) -%}\n {{- '\n' + '\n' -}}\n {{- reasoning_content.strip('\n') if options is defined and thinking_enabled else '' -}}\n {{- '\n\n\n' -}}\n {%- endif -%}\n {%- if content|length > 0 -%}\n {{- content -}}\n {%- endif -%}\n {%- if message.tool_calls -%}\n {%- for tool_call in message.tool_calls -%}\n {%- if (not loop.first) -%}\n {{- '\n' -}}\n {%- endif -%}\n {%- if tool_call.function -%}\n {%- set tool_call = tool_call.function -%}\n {%- endif -%}\n {{- '\n{\"name\": \"' -}}\n {{- tool_call.name -}}\n {{- '\", \"arguments\": ' -}}\n {%- if tool_call.arguments is string -%}\n {{- tool_call.arguments -}}\n {%- else -%}\n {{- tool_call.arguments | tojson -}}\n {%- endif -%}\n {{- '}\n\n' -}}\n {%- endfor -%}\n {%- endif -%}\n {{- '<|end_of_sentence|>' }}\n {%- elif message.role == \"tool\" -%}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") -%}\n {{- 'User: ' -}}\n {%- endif -%}\n {{- '\n\n' -}}\n {{- content -}}\n {{- '\n\n' -}}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{%- if not add_generation_prompt is defined -%}\n {%- set add_generation_prompt = true -%}\n{%- endif -%}\n{{- '<|begin_of_sentence|>' -}}\n{%- if messages[0].role == 'system' -%}\n {%- if messages and messages[0].role == 'system' -%}\n {%- if messages[0].content is string -%}\n {{- messages[0].content -}}\n {%- elif messages[0].content is iterable -%}\n {%- set sys_content = render_content(messages[0].content) %}\n {{- sys_content -}}\n {%- endif -%}\n {%- endif -%}\n {{- '\n' -}}\n{%- else -%}\n {{- 'You are a multimodal AI assistant called ERNIE developed by Baidu based on the PaddlePaddle framework.\n' -}}\n{%- endif -%}\n{%- if options is defined and options.parallel_tool_calls is defined and (options.parallel_tool_calls == \"true\" or options.parallel_tool_calls == True) -%}\n {{- '\nparallel_tool_calls=True\n' -}}\n{%- endif -%}\n{%- if tools -%}\n {{- \"\n\" -}}\n {{- '\n' -}}\n {{- '[' -}}\n {%- for tool in tools -%}\n {{- '{\"type\": \"function\", \"function\": ' -}}\n {{- (tool.function | tojson) -}}\n {{- '}' -}}\n {%- if not loop.last -%}\n {{- ', ' -}}\n {%- endif -%}\n {%- endfor -%}\n {{- ']' -}}\n {{- \"\n\" -}}\n {{- '\n' -}}\n{%- endif -%}\n{{- build_messages(messages) -}}\n{%- if add_generation_prompt -%}\n {%- set append_think_label=False -%}\n {%- if not thinking_enabled -%}\n {%- set append_think_label=True -%}\n {%- endif -%}\n {{- \"\nAssistant: \n\n\" -}}\n {%- if options is defined and options.tool_choice is defined -%}\n {%- if options.tool_choice.mode == \"required\" -%}\n {{- '系统要求我必须使用一个或多个工具,注意要认真填写参数,若必填参数存在信息缺失,需做出合理的假设,不可询问用户。' -}}\n {%- if not thinking_enabled -%}\n {{- '\n\n\n\n' -}}\n {%- set append_think_label=False -%}\n {%- else -%}\n {{- '现在开始分析用户需求,' -}}\n {%- endif -%}\n {%- endif -%}\n {%- if options.tool_choice.mode == \"force\" -%}\n {{- \"系统指定必须使用\" -}}\n {{- options.tool_choice.name -}}\n {{- '工具,因此我尝试填写合适的参数满足用户需求。\n\n\n\n{\"name\": \"' -}}\n {{- options.tool_choice.name -}}\n {{- '\", \"arguments\":' -}}\n {%- set append_think_label=False -%}\n {%- endif -%}\n {%- endif -%}\n {{- \"\n\n\n\" if append_think_label else '' -}}\n{%- endif -%}"
}