Upload optimized ONNX model
#2
by
Xenova HF Staff - opened
- chat_template.jinja +7 -91
- config.json +15 -23
- generation_config.json +2 -6
- onnx/model.onnx +2 -2
- onnx/model.onnx_data +2 -2
- onnx/model_fp16.onnx +2 -2
- onnx/model_fp16.onnx_data +2 -2
- tokenizer.json +2 -2
- tokenizer_config.json +10 -10
chat_template.jinja
CHANGED
|
@@ -1,93 +1,9 @@
|
|
| 1 |
-
{{
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
{%- endif %}
|
| 5 |
-
{%- if not tools_in_user_message is defined %}
|
| 6 |
-
{%- set tools_in_user_message = true %}
|
| 7 |
-
{%- endif %}
|
| 8 |
-
{%- if not date_string is defined %}
|
| 9 |
-
{%- if strftime_now is defined %}
|
| 10 |
-
{%- set date_string = strftime_now("%d %b %Y") %}
|
| 11 |
-
{%- else %}
|
| 12 |
-
{%- set date_string = "26 Jul 2024" %}
|
| 13 |
-
{%- endif %}
|
| 14 |
-
{%- endif %}
|
| 15 |
-
{%- if not tools is defined %}
|
| 16 |
-
{%- set tools = none %}
|
| 17 |
-
{%- endif %}
|
| 18 |
|
| 19 |
-
{
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
{%- set messages = messages[1:] %}
|
| 23 |
-
{%- else %}
|
| 24 |
-
{%- set system_message = "" %}
|
| 25 |
-
{%- endif %}
|
| 26 |
|
| 27 |
-
{
|
| 28 |
-
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
| 29 |
-
{%- if tools is not none %}
|
| 30 |
-
{{- "Environment: ipython\n" }}
|
| 31 |
-
{%- endif %}
|
| 32 |
-
{{- "Cutting Knowledge Date: December 2023\n" }}
|
| 33 |
-
{{- "Today Date: " + date_string + "\n\n" }}
|
| 34 |
-
{%- if tools is not none and not tools_in_user_message %}
|
| 35 |
-
{{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
|
| 36 |
-
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 37 |
-
{{- "Do not use variables.\n\n" }}
|
| 38 |
-
{%- for t in tools %}
|
| 39 |
-
{{- t | tojson(indent=4) }}
|
| 40 |
-
{{- "\n\n" }}
|
| 41 |
-
{%- endfor %}
|
| 42 |
-
{%- endif %}
|
| 43 |
-
{{- system_message }}
|
| 44 |
-
{{- "<|eot_id|>" }}
|
| 45 |
-
|
| 46 |
-
{#- Custom tools are passed in a user message with some extra guidance #}
|
| 47 |
-
{%- if tools_in_user_message and not tools is none %}
|
| 48 |
-
{#- Extract the first user message so we can plug it in here #}
|
| 49 |
-
{%- if messages | length != 0 %}
|
| 50 |
-
{%- set first_user_message = messages[0]['content']|trim %}
|
| 51 |
-
{%- set messages = messages[1:] %}
|
| 52 |
-
{%- else %}
|
| 53 |
-
{{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }}
|
| 54 |
-
{%- endif %}
|
| 55 |
-
{{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}
|
| 56 |
-
{{- "Given the following functions, please respond with a JSON for a function call " }}
|
| 57 |
-
{{- "with its proper arguments that best answers the given prompt.\n\n" }}
|
| 58 |
-
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 59 |
-
{{- "Do not use variables.\n\n" }}
|
| 60 |
-
{%- for t in tools %}
|
| 61 |
-
{{- t | tojson(indent=4) }}
|
| 62 |
-
{{- "\n\n" }}
|
| 63 |
-
{%- endfor %}
|
| 64 |
-
{{- first_user_message + "<|eot_id|>"}}
|
| 65 |
-
{%- endif %}
|
| 66 |
-
|
| 67 |
-
{%- for message in messages %}
|
| 68 |
-
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
| 69 |
-
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}
|
| 70 |
-
{%- elif 'tool_calls' in message %}
|
| 71 |
-
{%- if not message.tool_calls|length == 1 %}
|
| 72 |
-
{{- raise_exception("This model only supports single tool-calls at once!") }}
|
| 73 |
-
{%- endif %}
|
| 74 |
-
{%- set tool_call = message.tool_calls[0].function %}
|
| 75 |
-
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 76 |
-
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 77 |
-
{{- '"parameters": ' }}
|
| 78 |
-
{{- tool_call.arguments | tojson }}
|
| 79 |
-
{{- "}" }}
|
| 80 |
-
{{- "<|eot_id|>" }}
|
| 81 |
-
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 82 |
-
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 83 |
-
{%- if message.content is mapping or message.content is iterable %}
|
| 84 |
-
{{- message.content | tojson }}
|
| 85 |
-
{%- else %}
|
| 86 |
-
{{- message.content }}
|
| 87 |
-
{%- endif %}
|
| 88 |
-
{{- "<|eot_id|>" }}
|
| 89 |
-
{%- endif %}
|
| 90 |
-
{%- endfor %}
|
| 91 |
-
{%- if add_generation_prompt %}
|
| 92 |
-
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 93 |
-
{%- endif %}
|
|
|
|
| 1 |
+
{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif USE_DEFAULT_PROMPT == true and not '<<SYS>>' in messages[0]['content'] %}{% set loop_messages = messages %}{% set system_message = 'DEFAULT_SYSTEM_MESSAGE' %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>
|
| 2 |
+
' + system_message + '
|
| 3 |
+
<</SYS>>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'system' %}{{ '<<SYS>>
|
| 6 |
+
' + content.strip() + '
|
| 7 |
+
<</SYS>>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
|
@@ -4,36 +4,31 @@
|
|
| 4 |
],
|
| 5 |
"attention_bias": false,
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
-
"bos_token_id":
|
| 8 |
"dtype": "float32",
|
| 9 |
-
"eos_token_id":
|
| 10 |
-
|
| 11 |
-
128008,
|
| 12 |
-
128009
|
| 13 |
-
],
|
| 14 |
-
"head_dim": 8,
|
| 15 |
"hidden_act": "silu",
|
| 16 |
-
"hidden_size":
|
| 17 |
"initializer_range": 0.02,
|
| 18 |
"intermediate_size": 64,
|
| 19 |
-
"max_position_embeddings":
|
| 20 |
"mlp_bias": false,
|
| 21 |
"model_type": "llama",
|
| 22 |
"num_attention_heads": 4,
|
| 23 |
"num_hidden_layers": 2,
|
| 24 |
-
"num_key_value_heads":
|
| 25 |
-
"pad_token_id":
|
| 26 |
"pretraining_tp": 1,
|
| 27 |
-
"rms_norm_eps": 1e-
|
| 28 |
"rope_parameters": {
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"low_freq_factor": 1.0,
|
| 32 |
-
"original_max_position_embeddings": 8192,
|
| 33 |
-
"rope_theta": 500000.0,
|
| 34 |
-
"rope_type": "llama3"
|
| 35 |
},
|
| 36 |
-
"tie_word_embeddings":
|
|
|
|
|
|
|
|
|
|
| 37 |
"transformers.js_config": {
|
| 38 |
"use_external_data_format": {
|
| 39 |
"model.onnx": 1,
|
|
@@ -43,8 +38,5 @@
|
|
| 43 |
"q4f16": "float16",
|
| 44 |
"fp16": "float16"
|
| 45 |
}
|
| 46 |
-
}
|
| 47 |
-
"transformers_version": "5.3.0.dev0",
|
| 48 |
-
"use_cache": true,
|
| 49 |
-
"vocab_size": 128256
|
| 50 |
}
|
|
|
|
| 4 |
],
|
| 5 |
"attention_bias": false,
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 1,
|
| 10 |
+
"head_dim": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 16,
|
| 13 |
"initializer_range": 0.02,
|
| 14 |
"intermediate_size": 64,
|
| 15 |
+
"max_position_embeddings": 2048,
|
| 16 |
"mlp_bias": false,
|
| 17 |
"model_type": "llama",
|
| 18 |
"num_attention_heads": 4,
|
| 19 |
"num_hidden_layers": 2,
|
| 20 |
+
"num_key_value_heads": 4,
|
| 21 |
+
"pad_token_id": -1,
|
| 22 |
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
"rope_parameters": {
|
| 25 |
+
"rope_theta": 10000.0,
|
| 26 |
+
"rope_type": "default"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
},
|
| 28 |
+
"tie_word_embeddings": false,
|
| 29 |
+
"transformers_version": "5.3.0.dev0",
|
| 30 |
+
"use_cache": true,
|
| 31 |
+
"vocab_size": 32000,
|
| 32 |
"transformers.js_config": {
|
| 33 |
"use_external_data_format": {
|
| 34 |
"model.onnx": 1,
|
|
|
|
| 38 |
"q4f16": "float16",
|
| 39 |
"fp16": "float16"
|
| 40 |
}
|
| 41 |
+
}
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
generation_config.json
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
-
"bos_token_id":
|
| 4 |
-
"eos_token_id":
|
| 5 |
-
128001,
|
| 6 |
-
128008,
|
| 7 |
-
128009
|
| 8 |
-
],
|
| 9 |
"transformers_version": "5.3.0.dev0"
|
| 10 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"transformers_version": "5.3.0.dev0"
|
| 6 |
}
|
onnx/model.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df31996713fd6e584f1e1961bb9f70674306447cd7362e8792e2ae51af529f38
|
| 3 |
+
size 21102
|
onnx/model.onnx_data
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc620771b792cf5c0667048c4157a34a90872c7c3e1da3a15bcce4a490b35857
|
| 3 |
+
size 4161536
|
onnx/model_fp16.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d7a87e856f8ffa899a806f5a65aa028d0183f4ebc295bf155b90c547872cffd
|
| 3 |
+
size 24553
|
onnx/model_fp16.onnx_data
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c70d822354c8df524bc3c2a9d98cae8e93667794006691709fede5118707a60b
|
| 3 |
+
size 2076672
|
tokenizer.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c5992569a6744ca7b5fa6807ec215340d7e0d7b5c4c6bc3d100f0e3469c7d83
|
| 3 |
+
size 1879442
|
tokenizer_config.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
{
|
|
|
|
| 2 |
"backend": "tokenizers",
|
| 3 |
-
"bos_token": "<
|
| 4 |
-
"clean_up_tokenization_spaces":
|
| 5 |
-
"eos_token": "<
|
| 6 |
"is_local": false,
|
| 7 |
-
"
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- if strftime_now is defined %}\n {%- set date_string = strftime_now(\"%d %b %Y\") %}\n {%- else %}\n {%- set date_string = \"26 Jul 2024\" %}\n {%- endif %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message #}\n{{- \"<|start_header_id|>system<|end_header_id|>\\n\\n\" }}\n{%- if tools is not none %}\n {{- \"Environment: ipython\\n\" }}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2023\\n\" }}\n{{- \"Today Date: \" + date_string + \"\\n\\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\\n\\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\\n\\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\\n\\n'+ message['content'] | trim + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {{- \"<|eot_id|>\" }}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\\n\\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' }}\n{%- endif %}\n"
|
| 14 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"add_prefix_space": null,
|
| 3 |
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
"is_local": false,
|
| 8 |
+
"model_max_length": 2048,
|
| 9 |
+
"pad_token": "<unk>",
|
| 10 |
+
"tokenizer_class": "LlamaTokenizer",
|
| 11 |
+
"unk_token": "<unk>",
|
| 12 |
+
"use_default_system_prompt": true,
|
| 13 |
+
"chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif USE_DEFAULT_PROMPT == true and not '<<SYS>>' in messages[0]['content'] %}{% set loop_messages = messages %}{% set system_message = 'DEFAULT_SYSTEM_MESSAGE' %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\n' + system_message + '\n<</SYS>>\n\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'system' %}{{ '<<SYS>>\n' + content.strip() + '\n<</SYS>>\n\n' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}"
|
|
|
|
| 14 |
}
|