KLM-1.6-Chat / tokenizer_config.json
Eclipse-Senpai's picture
KLM 1.6-Chat
ec8e64b
Raw History Blame Contribute Delete
2.16 kB
{
"tokenizer_class": "PreTrainedTokenizerFast",
"model_max_length": 32768,
"pad_token": "<pad>",
"bos_token": "<bos>",
"eos_token": "<eos>",
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<think>",
"</think>"
],
"add_bos_token": false,
"add_eos_token": false,
"clean_up_tokenization_spaces": false,
"model_input_names": [
"input_ids",
"attention_mask"
],
"chat_template": "{%- set think = enable_thinking if enable_thinking is defined else true -%}\n{%- set ns = namespace(system='', last_user=-1) -%}\n{%- if messages and messages[0]['role'] == 'system' -%}\n {%- set ns.system = messages[0]['content'] -%}\n {%- set rest = messages[1:] -%}\n{%- else -%}\n {%- set rest = messages -%}\n{%- endif -%}\n{%- if tools -%}\n {%- set lines = namespace(text='You can use these tools:') -%}\n {%- for tool in tools -%}\n {%- set lines.text = lines.text + '\\n' + ((tool['function'] if tool['function'] is defined else tool) | tojson) -%}\n {%- endfor -%}\n {%- set lines.text = lines.text + '\\n\\nTo use one, write <tool_call>{\"name\": \"<tool name>\", \"arguments\": {...}}</tool_call> and stop. The result comes back in a tool message.' -%}\n {%- set ns.system = (ns.system + '\\n\\n' + lines.text) if ns.system else lines.text -%}\n{%- endif -%}\n{%- set flag = '/think' if think else '/no_think' -%}\n{%- set ns.system = (ns.system.rstrip() + '\\n\\n' + flag) if ns.system else flag -%}\n{{- '<|im_start|>system\\n' + ns.system + '<|im_end|>\\n' -}}\n{%- for m in rest -%}\n {%- if m['role'] == 'user' -%}{%- set ns.last_user = loop.index0 -%}{%- endif -%}\n{%- endfor -%}\n{%- for m in rest -%}\n {%- set content = m['content'] -%}\n {%- if m['role'] == 'assistant' and loop.index0 < ns.last_user and content.startswith('<think>') and '</think>' in content -%}\n {%- set content = content.split('</think>', 1)[1] | trim -%}\n {%- endif -%}\n {{- '<|im_start|>' + m['role'] + '\\n' + content + '<|im_end|>\\n' -}}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{- '<|im_start|>assistant\\n' + ('<think>\\n' if think else '<think>\\n\\n</think>\\n\\n') -}}\n{%- endif -%}"
}