danielhanchen commited on
Commit
af7f9f9
·
verified ·
1 Parent(s): d6f66f0

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. chat_template.jinja +1 -1
  2. tokenizer_config.json +1 -1
chat_template.jinja CHANGED
@@ -42,7 +42,7 @@
42
  {%- endif %}
43
  {%- if message['role'] == 'assistant' %}
44
  {%- if '</think>' in content %}
45
- {%- set content = content.split('</think>')[-1] %}
46
  {%- endif %}
47
  {%- endif %}
48
  {%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}
 
42
  {%- endif %}
43
  {%- if message['role'] == 'assistant' %}
44
  {%- if '</think>' in content %}
45
+ {%- set content = (content.split('</think>')|last) %}
46
  {%- endif %}
47
  {%- endif %}
48
  {%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}
tokenizer_config.json CHANGED
@@ -240,5 +240,5 @@
240
  "tokenizer_class": "LlamaTokenizerFast",
241
  "unk_token": null,
242
  "use_default_system_prompt": false,
243
- "chat_template": "{%- if not add_generation_prompt is defined %}\n {%- set add_generation_prompt = false %}\n{%- endif %}\n{%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n {%- if ns.is_first_sp %}\n {%- set ns.system_prompt = ns.system_prompt + message['content'] %}\n {%- set ns.is_first_sp = false %}\n {%- else %}\n {%- set ns.system_prompt = ns.system_prompt + '\\n\\n' + message['content'] %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{#- Adapted from https://github.com/sgl-project/sglang/blob/main/examples/chat_template/tool_chat_template_deepseekr1.jinja #}\n{%- if tools is defined and tools is not none %}\n {%- set tool_ns = namespace(text='You are a helpful assistant with tool calling capabilities. ' + 'When a tool call is needed, you MUST use the following format to issue the call:\\n' + '<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>FUNCTION_NAME\\n' + '```json\\n{\"param1\": \"value1\", \"param2\": \"value2\"}\\n```<|tool▁call▁end|><|tool▁calls▁end|>\\n\\n' + 'Make sure the JSON is valid.' + '## Tools\\n\\n### Function\\n\\nYou have the following functions available:\\n\\n') %}\n {%- for tool in tools %}\n {%- set tool_ns.text = tool_ns.text + '\\n```json\\n' + (tool | tojson) + '\\n```\\n' %}\n {%- endfor %}\n {%- if ns.system_prompt|length != 0 %}\n {%- set ns.system_prompt = ns.system_prompt + '\\n\\n' + tool_ns.text %}\n {%- else %}\n {%- set ns.system_prompt = tool_ns.text %}\n {%- endif %}\n{%- endif %}\n{{- bos_token }}\n{{- ns.system_prompt }}\n{%- set last_index = (messages|length - 1) %}\n{%- for message in messages %}\n {%- set content = message['content'] %}\n {%- if message['role'] == 'user' %}\n {%- set ns.is_tool = false -%}\n {%- set ns.is_first = false -%}\n {%- set ns.is_last_user = true -%}\n {%- if loop.index0 == last_index %}\n {{- '<|User|>' + content }}\n {%- else %}\n {{- '<|User|>' + content + '<|Assistant|>'}}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'assistant' %}\n {%- if '</think>' in content %}\n {%- set content = content.split('</think>')[-1] %}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}\n {%- set ns.is_last_user = false -%}\n {%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>'}}\n {%- endif %}\n {%- set ns.is_first = false %}\n {%- set ns.is_tool = false -%}\n {%- set ns.is_output_first = true %}\n {%- for tool in message['tool_calls'] %}\n {%- set arguments = tool['function']['arguments'] %}\n {%- if arguments is not string %}\n {%- set arguments = arguments|tojson %}\n {%- endif %}\n {%- if not ns.is_first %}\n {%- if content is none %}\n {{- '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n }\n {%- else %}\n {{- content + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n {%- endif %}\n {%- set ns.is_first = true -%}\n {%- else %}\n {{- '\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n {%- endif %}\n {%- endfor %}\n {{- '<|tool▁calls▁end|><|end▁of▁sentence|>'}}\n {%- endif %}\n {%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}\n {%- set ns.is_last_user = false -%}\n {%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>' + content + '<|end▁of▁sentence|>'}}\n {%- set ns.is_tool = false -%}\n {%- else %}\n {{- content + '<|end▁of▁sentence|>'}}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'tool' %}\n {%- set ns.is_last_user = false -%}\n {%- set ns.is_tool = true -%}\n {%- if ns.is_output_first %}\n {{- '<|tool▁outputs▁begin|><|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}\n {%- set ns.is_output_first = false %}\n {%- else %}\n {{- '\\n<|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}\n {%- endif %}\n {%- endif %}\n{%- endfor -%}\n{%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>'}}\n{%- endif %}\n{#- if add_generation_prompt and not ns.is_last_user and not ns.is_tool #}\n{%- if add_generation_prompt and not ns.is_tool %}\n {{- '<|Assistant|>'}}\n{%- endif %}"
244
  }
 
240
  "tokenizer_class": "LlamaTokenizerFast",
241
  "unk_token": null,
242
  "use_default_system_prompt": false,
243
+ "chat_template": "{%- if not add_generation_prompt is defined %}\n {%- set add_generation_prompt = false %}\n{%- endif %}\n{%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}\n{%- for message in messages %}\n {%- if message['role'] == 'system' %}\n {%- if ns.is_first_sp %}\n {%- set ns.system_prompt = ns.system_prompt + message['content'] %}\n {%- set ns.is_first_sp = false %}\n {%- else %}\n {%- set ns.system_prompt = ns.system_prompt + '\\n\\n' + message['content'] %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{#- Adapted from https://github.com/sgl-project/sglang/blob/main/examples/chat_template/tool_chat_template_deepseekr1.jinja #}\n{%- if tools is defined and tools is not none %}\n {%- set tool_ns = namespace(text='You are a helpful assistant with tool calling capabilities. ' + 'When a tool call is needed, you MUST use the following format to issue the call:\\n' + '<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>FUNCTION_NAME\\n' + '```json\\n{\"param1\": \"value1\", \"param2\": \"value2\"}\\n```<|tool▁call▁end|><|tool▁calls▁end|>\\n\\n' + 'Make sure the JSON is valid.' + '## Tools\\n\\n### Function\\n\\nYou have the following functions available:\\n\\n') %}\n {%- for tool in tools %}\n {%- set tool_ns.text = tool_ns.text + '\\n```json\\n' + (tool | tojson) + '\\n```\\n' %}\n {%- endfor %}\n {%- if ns.system_prompt|length != 0 %}\n {%- set ns.system_prompt = ns.system_prompt + '\\n\\n' + tool_ns.text %}\n {%- else %}\n {%- set ns.system_prompt = tool_ns.text %}\n {%- endif %}\n{%- endif %}\n{{- bos_token }}\n{{- ns.system_prompt }}\n{%- set last_index = (messages|length - 1) %}\n{%- for message in messages %}\n {%- set content = message['content'] %}\n {%- if message['role'] == 'user' %}\n {%- set ns.is_tool = false -%}\n {%- set ns.is_first = false -%}\n {%- set ns.is_last_user = true -%}\n {%- if loop.index0 == last_index %}\n {{- '<|User|>' + content }}\n {%- else %}\n {{- '<|User|>' + content + '<|Assistant|>'}}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'assistant' %}\n {%- if '</think>' in content %}\n {%- set content = (content.split('</think>')|last) %}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}\n {%- set ns.is_last_user = false -%}\n {%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>'}}\n {%- endif %}\n {%- set ns.is_first = false %}\n {%- set ns.is_tool = false -%}\n {%- set ns.is_output_first = true %}\n {%- for tool in message['tool_calls'] %}\n {%- set arguments = tool['function']['arguments'] %}\n {%- if arguments is not string %}\n {%- set arguments = arguments|tojson %}\n {%- endif %}\n {%- if not ns.is_first %}\n {%- if content is none %}\n {{- '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n }\n {%- else %}\n {{- content + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n {%- endif %}\n {%- set ns.is_first = true -%}\n {%- else %}\n {{- '\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + arguments + '\\n' + '```' + '<|tool▁call▁end|>'}}\n {%- endif %}\n {%- endfor %}\n {{- '<|tool▁calls▁end|><|end▁of▁sentence|>'}}\n {%- endif %}\n {%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}\n {%- set ns.is_last_user = false -%}\n {%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>' + content + '<|end▁of▁sentence|>'}}\n {%- set ns.is_tool = false -%}\n {%- else %}\n {{- content + '<|end▁of▁sentence|>'}}\n {%- endif %}\n {%- endif %}\n {%- if message['role'] == 'tool' %}\n {%- set ns.is_last_user = false -%}\n {%- set ns.is_tool = true -%}\n {%- if ns.is_output_first %}\n {{- '<|tool▁outputs▁begin|><|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}\n {%- set ns.is_output_first = false %}\n {%- else %}\n {{- '\\n<|tool▁output▁begin|>' + content + '<|tool▁output▁end|>'}}\n {%- endif %}\n {%- endif %}\n{%- endfor -%}\n{%- if ns.is_tool %}\n {{- '<|tool▁outputs▁end|>'}}\n{%- endif %}\n{#- if add_generation_prompt and not ns.is_last_user and not ns.is_tool #}\n{%- if add_generation_prompt and not ns.is_tool %}\n {{- '<|Assistant|>'}}\n{%- endif %}"
244
  }