Add tool use template

#2
by Rocketknight1 HF staff - opened
Files changed (3) hide show
  1. README.md +9 -11
  2. tokenizer.json +1 -0
  3. tokenizer_config.json +10 -1
README.md CHANGED
@@ -1,5 +1,6 @@
1
  ---
2
- base_model: NousResearch/Meta-Llama-3-70B
 
3
  tags:
4
  - Llama-3
5
  - instruct
@@ -13,24 +14,21 @@ tags:
13
  - function calling
14
  - json mode
15
  - axolotl
16
- model-index:
17
- - name: Hermes-2-Pro-Llama-3-70B
18
- results: []
19
- language:
20
- - en
21
  datasets:
22
  - teknium/OpenHermes-2.5
23
  widget:
24
  - example_title: Hermes 2 Pro
25
  messages:
26
  - role: system
27
- content: >-
28
- You are a sentient, superintelligent artificial general intelligence, here
29
- to teach and assist me.
30
  - role: user
31
- content: >-
32
- Write a short story about Goku discovering kirby has teamed up with Majin
33
  Buu to destroy the world.
 
 
 
34
  ---
35
 
36
  # Hermes 2 Pro - Llama-3 70B
 
1
  ---
2
+ language:
3
+ - en
4
  tags:
5
  - Llama-3
6
  - instruct
 
14
  - function calling
15
  - json mode
16
  - axolotl
17
+ base_model: NousResearch/Meta-Llama-3-70B
 
 
 
 
18
  datasets:
19
  - teknium/OpenHermes-2.5
20
  widget:
21
  - example_title: Hermes 2 Pro
22
  messages:
23
  - role: system
24
+ content: You are a sentient, superintelligent artificial general intelligence,
25
+ here to teach and assist me.
 
26
  - role: user
27
+ content: Write a short story about Goku discovering kirby has teamed up with Majin
 
28
  Buu to destroy the world.
29
+ model-index:
30
+ - name: Hermes-2-Pro-Llama-3-70B
31
+ results: []
32
  ---
33
 
34
  # Hermes 2 Pro - Llama-3 70B
tokenizer.json CHANGED
@@ -2407,6 +2407,7 @@
2407
  "end_of_word_suffix": null,
2408
  "fuse_unk": false,
2409
  "byte_fallback": false,
 
2410
  "vocab": {
2411
  "!": 0,
2412
  "\"": 1,
 
2407
  "end_of_word_suffix": null,
2408
  "fuse_unk": false,
2409
  "byte_fallback": false,
2410
+ "ignore_merges": false,
2411
  "vocab": {
2412
  "!": 0,
2413
  "\"": 1,
tokenizer_config.json CHANGED
@@ -2050,7 +2050,16 @@
2050
  }
2051
  },
2052
  "bos_token": "<|begin_of_text|>",
2053
- "chat_template": "{{bos_token}}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
 
 
 
 
 
 
 
 
 
2054
  "clean_up_tokenization_spaces": true,
2055
  "eos_token": "<|im_end|>",
2056
  "model_input_names": [
 
2050
  }
2051
  },
2052
  "bos_token": "<|begin_of_text|>",
2053
+ "chat_template": [
2054
+ {
2055
+ "name": "default",
2056
+ "template": "{{bos_token}}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
2057
+ },
2058
+ {
2059
+ "name": "tool_use",
2060
+ "template": "{%- macro json_to_python_type(json_spec) %}\n{%- set basic_type_map = {\n \"string\": \"str\",\n \"number\": \"float\",\n \"integer\": \"int\",\n \"boolean\": \"bool\"\n} %}\n\n{%- if basic_type_map[json_spec.type] is defined %}\n {{- basic_type_map[json_spec.type] }}\n{%- elif json_spec.type == \"array\" %}\n {{- \"list[\" + json_to_python_type(json_spec|items) + \"]\"}}\n{%- elif json_spec.type == \"object\" %}\n {%- if json_spec.additionalProperties is defined %}\n {{- \"dict[str, \" + json_to_python_type(json_spec.additionalProperties) + ']'}}\n {%- else %}\n {{- \"dict\" }}\n {%- endif %}\n{%- elif json_spec.type is iterable %}\n {{- \"Union[\" }}\n {%- for t in json_spec.type %}\n {{- json_to_python_type({\"type\": t}) }}\n {%- if not loop.last %}\n {{- \",\" }} \n {%- endif %}\n {%- endfor %}\n {{- \"]\" }}\n{%- else %}\n {{- \"Any\" }}\n{%- endif %}\n{%- endmacro %}\n\n\n{{- bos_token }}\n{{- \"You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> \" }}\n{%- for tool in tools %}\n {%- if tool.function is defined %}\n {%- set tool = tool.function %}\n {%- endif %}\n {{- '{\"type\": \"function\", \"function\": ' }}\n {{- '{\"name\": ' + tool.name + '\", ' }}\n {{- '\"description\": \"' + tool.name + '(' }}\n {%- for param_name, param_fields in tool.parameters.properties|items %}\n {{- param_name + \": \" + json_to_python_type(param_fields) }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \")\" }}\n {%- if tool.return is defined %}\n {{- \" -> \" + json_to_python_type(tool.return) }}\n {%- endif %}\n {{- \" - \" + tool.description + \"\\n\\n\" }}\n {%- for param_name, param_fields in tool.parameters.properties|items %}\n {%- if loop.first %}\n {{- \" Args:\\n\" }}\n {%- endif %}\n {{- \" \" + param_name + \"(\" + json_to_python_type(param_fields) + \"): \" + param_fields.description|trim }}\n {%- endfor %}\n {%- if tool.return is defined and tool.return.description is defined %}\n {{- \"\\n Returns:\\n \" + tool.return.description }}\n {%- endif %}\n {{- '\"' }}\n {{- ', \"parameters\": ' }}\n {%- if tool.parameters.properties | length == 0 %}\n {{- \"{}\" }}\n {%- else %}\n {{- tool.parameters|tojson }}\n {%- endif %}\n {{- \"}\" }}\n {%- if not loop.last %}\n {{- \"\\n\" }}\n {%- endif %}\n{%- endfor %}\n{{- \" </tools>\" }}\n{{- 'Use the following pydantic model json schema for each tool call you will make: {\"properties\": {\"arguments\": {\"title\": \"Arguments\", \"type\": \"object\"}, \"name\": {\"title\": \"Name\", \"type\": \"string\"}}, \"required\": [\"arguments\", \"name\"], \"title\": \"FunctionCall\", \"type\": \"object\"}\n' }}\n{{- \"For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:\n\" }}\n{{- \"<tool_call>\n\" }}\n{{- '{\"arguments\": <args-dict>, \"name\": <function-name>}\n' }}\n{{- '</tool_call><|im_end|>' }}\n{%- for message in messages %}\n {%- if message.role == \"user\" or message.role == \"system\" or (message.role == \"assistant\" and message.tool_calls is not defined) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role + '\\n<tool_call>\\n' }}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '{ ' }}\n {%- if tool_call.arguments is defined %}\n {{- '\"arguments\": ' }}\n {{- tool_call.arguments|tojson }}\n {{- ', '}}\n {%- endif %}\n {{- '\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\"}' }}\n {{- '\\n</tool_call> ' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if not message.name is defined %}\n {{- raise_exception(\"Tool response dicts require a 'name' key indicating the name of the called function!\") }}\n {%- endif %}\n {{- '<|im_start|>' + message.role + '\\n<tool_response>\\n' }}\n {{- '{\"name\": \"' }}\n {{- message.name }}\n {{- '\", \"content\": ' }}\n {{- message.content|tojson + '}' }}\n {{- '\\n</tool_response> <|im_end|>\\n' }} \n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n"
2061
+ }
2062
+ ],
2063
  "clean_up_tokenization_spaces": true,
2064
  "eos_token": "<|im_end|>",
2065
  "model_input_names": [