Update tiny models for NanoChatForCausalLM
Browse files- chat_template.jinja +51 -0
- config.json +31 -0
- generation_config.json +10 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +23 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token }}
|
| 2 |
+
{%- if messages[0]['role'] == 'system' -%}
|
| 3 |
+
{%- if messages[1] is not defined or messages[1]['role'] != 'user' -%}
|
| 4 |
+
{{- raise_exception("System message must be followed by a user message") }}
|
| 5 |
+
{%- endif -%}
|
| 6 |
+
{%- set system_content = messages[0]['content'] -%}
|
| 7 |
+
{%- set loop_messages = messages[1:] -%}
|
| 8 |
+
{%- set first_user_has_system = true -%}
|
| 9 |
+
{%- else -%}
|
| 10 |
+
{%- set system_content = "" -%}
|
| 11 |
+
{%- set loop_messages = messages -%}
|
| 12 |
+
{%- set first_user_has_system = false -%}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- for message in loop_messages -%}
|
| 15 |
+
{%- if message['role'] == 'user' -%}
|
| 16 |
+
{{- '<|user_start|>' }}
|
| 17 |
+
{%- if loop.first and first_user_has_system -%}
|
| 18 |
+
{{- system_content + '\n\n' }}
|
| 19 |
+
{%- endif -%}
|
| 20 |
+
{%- if message['content'] is not string -%}
|
| 21 |
+
{{- raise_exception("User messages must contain string content") }}
|
| 22 |
+
{%- endif -%}
|
| 23 |
+
{{- message['content'] }}
|
| 24 |
+
{{- '<|user_end|>' }}
|
| 25 |
+
{%- elif message['role'] == 'assistant' -%}
|
| 26 |
+
{{- '<|assistant_start|>' }}
|
| 27 |
+
{%- if message['content'] is string -%}
|
| 28 |
+
{{- message['content'] }}
|
| 29 |
+
{%- elif message['content'] is iterable -%}
|
| 30 |
+
{%- for part in message['content'] -%}
|
| 31 |
+
{%- if part['type'] == 'text' -%}
|
| 32 |
+
{{- part.get('text', '') }}
|
| 33 |
+
{%- elif part['type'] == 'python' -%}
|
| 34 |
+
{{- '<|python_start|>' + part.get('text', '') + '<|python_end|>' }}
|
| 35 |
+
{%- elif part['type'] == 'python_output' -%}
|
| 36 |
+
{{- '<|output_start|>' + part.get('text', '') + '<|output_end|>' }}
|
| 37 |
+
{%- else -%}
|
| 38 |
+
{{- raise_exception("Unknown assistant content part: " + part['type']) }}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{%- endfor -%}
|
| 41 |
+
{%- else -%}
|
| 42 |
+
{{- raise_exception("Unsupported assistant content type") }}
|
| 43 |
+
{%- endif -%}
|
| 44 |
+
{{- '<|assistant_end|>' }}
|
| 45 |
+
{%- else -%}
|
| 46 |
+
{{- raise_exception("Unexpected message role: " + message['role'] + ". Only 'user' and 'assistant' roles are supported after the optional initial system message.") }}
|
| 47 |
+
{%- endif -%}
|
| 48 |
+
{%- endfor -%}
|
| 49 |
+
{%- if add_generation_prompt -%}
|
| 50 |
+
{{- '<|assistant_start|>' }}
|
| 51 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"NanoChatForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 65527,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 65531,
|
| 10 |
+
"final_logit_softcapping": 15.0,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_size": 32,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 32,
|
| 15 |
+
"is_decoder": true,
|
| 16 |
+
"max_position_embeddings": 512,
|
| 17 |
+
"model_type": "nanochat",
|
| 18 |
+
"num_attention_heads": 2,
|
| 19 |
+
"num_hidden_layers": 2,
|
| 20 |
+
"num_key_value_heads": 2,
|
| 21 |
+
"pad_token_id": 65531,
|
| 22 |
+
"rms_norm_eps": 1e-06,
|
| 23 |
+
"rope_parameters": {
|
| 24 |
+
"rope_theta": 10000.0,
|
| 25 |
+
"rope_type": "default"
|
| 26 |
+
},
|
| 27 |
+
"tie_word_embeddings": false,
|
| 28 |
+
"transformers_version": "5.16.0.dev0",
|
| 29 |
+
"use_cache": true,
|
| 30 |
+
"vocab_size": 65536
|
| 31 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 65527,
|
| 4 |
+
"eos_token_id": 65531,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"pad_token_id": 65531,
|
| 8 |
+
"transformers_version": "5.16.0.dev0",
|
| 9 |
+
"use_cache": true
|
| 10 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b29359f53bd1f67f7182fe8e58a99316d959918d873100fe2bc00fb924c9c02b
|
| 3 |
+
size 16827848
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|bos|>",
|
| 4 |
+
"eos_token": "<|assistant_end|>",
|
| 5 |
+
"extra_special_tokens": [
|
| 6 |
+
"<|user_start|>",
|
| 7 |
+
"<|user_end|>",
|
| 8 |
+
"<|assistant_start|>",
|
| 9 |
+
"<|python_start|>",
|
| 10 |
+
"<|python_end|>",
|
| 11 |
+
"<|output_start|>",
|
| 12 |
+
"<|output_end|>"
|
| 13 |
+
],
|
| 14 |
+
"is_local": true,
|
| 15 |
+
"local_files_only": false,
|
| 16 |
+
"model_input_names": [
|
| 17 |
+
"input_ids",
|
| 18 |
+
"attention_mask"
|
| 19 |
+
],
|
| 20 |
+
"model_max_length": 512,
|
| 21 |
+
"pad_token": "<|assistant_end|>",
|
| 22 |
+
"tokenizer_class": "TokenizersBackend"
|
| 23 |
+
}
|