Download chat_template.jinja from CMSManhattan/LlamaRoboticsTokenizer: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/CMSManhattan/LlamaRoboticsTokenizer/resolve/main/chat_template.jinja
- Command line
-
hf download hf://CMSManhattan/LlamaRoboticsTokenizer/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/CMSManhattan/LlamaRoboticsTokenizer/resolve/main/chat_template.jinja
2.36 kB
| {#- JiRack ternary Llama-3 tool format = tool_eval.py llama3_prompt / retok_precision_to_llama3.py (the SFT data) -#} | |
| {%- set ns = namespace(sys='', tools='', a='') -%} | |
| {%- if tools -%} | |
| {%- for t in tools -%} | |
| {%- set f = t.function if t.function is defined else t -%} | |
| {%- set ns.tools = ns.tools + (', ' if not loop.first else '') + ({'name': f.name, 'description': f.description, 'parameters': f.parameters} | tojson) -%} | |
| {%- endfor -%} | |
| {%- set ns.sys = 'You are a helpful assistant with access to the following tools.\nWhen you need to call one or more tools to answer the user, respond with ONE OR MORE blocks in exactly this format and nothing else:\n<tool_call>\n{"name": "<function name>", "arguments": {<JSON object of arguments>}}\n</tool_call>\nIf you need to call more than one tool, output multiple <tool_call> blocks back to back. If no tool is needed, answer normally in plain text with no <tool_call> tags.\n\nAvailable tools:\n[' + ns.tools + ']' -%} | |
| {%- endif -%} | |
| {%- for m in messages if m.role == 'system' -%} | |
| {%- set ns.sys = (ns.sys + '\n' if ns.sys else '') + m.content -%} | |
| {%- endfor -%} | |
| {%- if ns.sys -%} | |
| {{- '<|start_header_id|>system<|end_header_id|>\n\n' + ns.sys | trim + '<|eot_id|>' -}} | |
| {%- endif -%} | |
| {%- for m in messages if m.role != 'system' -%} | |
| {%- if m.role == 'user' -%} | |
| {{- '<|start_header_id|>user<|end_header_id|>\n\n' + m.content | trim + '<|eot_id|>' -}} | |
| {%- elif m.role == 'assistant' -%} | |
| {%- set ns.a = (m.content or '') -%} | |
| {%- if m.tool_calls is defined and m.tool_calls -%} | |
| {%- for c in m.tool_calls -%} | |
| {%- set fc = c.function if c.function is defined else c -%} | |
| {%- set args = fc.arguments if fc.arguments is string else (fc.arguments | tojson) -%} | |
| {%- set ns.a = ns.a + ('\n' if ns.a else '') + '<tool_call>\n{"name": ' + (fc.name | tojson) + ', "arguments": ' + args + '}\n</tool_call>' -%} | |
| {%- endfor -%} | |
| {%- endif -%} | |
| {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' + ns.a | trim + '<|eot_id|>' -}} | |
| {%- elif m.role == 'tool' -%} | |
| {{- '<|start_header_id|>user<|end_header_id|>\n\n<tool_response>\n[{"name": ' + (m.name | default('tool') | tojson) + ', "results": ' + (m.content if m.content is string else (m.content | tojson)) + '}]\n</tool_response><|eot_id|>' -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- if add_generation_prompt -%} | |
| {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}} | |
| {%- endif -%} | |