isbondarev bsfg commited on
Commit
df9cf77
·
0 Parent(s):

Duplicate from ai-sage/GigaChat3-10B-A1.8B-bf16

Browse files

Co-authored-by: Viacheslav <bsfg@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Salute Developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - ru
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - moe
9
+ ---
10
+ # GigaChat3-10B-A1.8B
11
+
12
+ Представляем `GigaChat3-10B-A1.8B` — диалоговую модель семейства GigaChat. Модель основана на архитектуре Mixture-of-Experts (MoE) с 10B общих и 1.8B активных параметров.
13
+ Архитектура включает **Multi-head Latent Attention (MLA)** и **Multi-Token Prediction (MTP)**, за счет чего модель оптимизирована для высокой пропускной способности (throughput) при инференсе.
14
+ Модель обучена поверх нашей базовой версии ([GigaChat3-10B-A1.8B-base](https://huggingface.co/ai-sage/GigaChat3-10B-A1.8B-base)) с помощью высококачественных SFT-данных.
15
+ Для высокопроизводительного инференса доступна версия модели в fp8 — [GigaChat3-10B-A1.8B-fp8](https://huggingface.co/ai-sage/GigaChat3-10B-A1.8B-fp8).
16
+
17
+ Поддерживает контекст до 256 тысяч токенов.
18
+
19
+ Больше подробностей [в хабр статье](https://habr.com/en/companies/sberdevices/articles/968904/).
20
+
21
+ ## Архитектура модели
22
+
23
+ `GigaChat3-10B-A1.8B` использует кастомную MoE-архитектуру:
24
+
25
+ ### Multi-head Latent Attention (MLA)
26
+
27
+ Вместо стандартного Multi-head Attention модель использует MLA. MLA обеспечивает эффективный инференс за счет сжатия Key-Value (KV) кэша в латентный вектор, что значительно снижает требования к памяти и ускоряет обработку.
28
+
29
+ ### Multi-Token Prediction (MTP)
30
+
31
+ Модель обучена с использованием задачи Multi-Token Prediction (MTP). Это позволяет модели предсказывать несколько токенов за один проход, что ускоряет генерацию до 40% с помощью техник спекулятивной/параллельной генерации.
32
+
33
+ ## Данные для обучения
34
+
35
+ Модель обучена на 20Т токенов.
36
+ Мы добавили 10 языков — от китайского и арабского до узбекского и казахского, а также расширили набор источников: книги, академические данные, датасеты по коду и математике. Все данные проходят дедупликацию, языковую фильтрацию и автоматические проверки качества при помощи эвристик и классификаторов.
37
+ Ключевой вклад в качество внесла синтетика: мы сгенерировали около 5,5 триллионов токенов синтетических данных. В корпус входят вопросы-ответы к текстам, цепочки reverse-prompt для структурирования данных, LLM-заметки с комментариями от модели внутри текстов, миллионы синтетических задач с решениями по математике и олимпиадному программированию (с синтетическими тестами) на основе PromptCot.
38
+
39
+ ## Инференс
40
+
41
+ Одно из ключевых преимуществ `GigaChat3-10B-A1.8B` — скорость инференса. Модель (особенно в режиме MTP) демонстрирует пропускную способность, сопоставимую с пропускной способностью значительно меньших dense‑моделей.
42
+ Мы измеряли с помощью vLLM v0.11.0, на типе bfloat16 c `batch_size=1`.
43
+ [Ссылка на код.](https://gist.github.com/ajpqs/ce941aa6f0f48ef36a65cb87a2a1d726)
44
+
45
+ |**Модель**|**request_throughput**|**output_throughput**|**total_token_throughput**|**mean_ttft_ms**|
46
+ |---|---|---|---|---|
47
+ |`Qwen3-1.7B`|1.689|357.308|726.093|11.824|
48
+ |**`mtp-GigaChat3-10B-A1.8B-base`**|**1.533**|**333.620**|**678.894**|**26.345**|
49
+ |**`GigaChat3-10B-A1.8B-base`**|**1.077**|**234.363**|**476.912**|**31.053**|
50
+ |`Qwen3-4B`|0.978|206.849|420.341|14.947|
51
+ |`Qwen3-8B`|0.664|140.432|285.375|16.663|
52
+ |`YandexGPT-5-Lite-8B-pretrain`|0.641|147.305|300.269|16.711|
53
+
54
+
55
+ ## Бенчмарки
56
+
57
+ Хотя модель имеет 10 миллиардов параметров, её прямые аналоги — модели размером 3–4 миллиарда параметров. Однако благодаря высокой скорости генерации мы также сравниваем её с ещё более компактными моделями.
58
+
59
+
60
+ | Метрика | GigaChat 3 Lightning | Qwen3-1.7B-Instruct | Qwen3-4B-Instruct-2507 | SmolLM3 |
61
+ | ------------------------- | ---------------------: | -----------------------: | ---------------------: | ------: |
62
+ | MMLU_RU_FIVE_SHOT | **0.6833** | 0.4876 | 0.5972 | 0.4998 |
63
+ | RUBQ_ZERO_SHOT | **0.6516** | 0.2557 | 0.3170 | 0.6363 |
64
+ | MMLU_PRO_EN_FIVE_SHOT | 0.6061 | 0.410 | **0.6849** | 0.5013 |
65
+ | MMLU_EN_FIVE_SHOT | **0.7403** | 0.60 | 0.7080 | 0.5992 |
66
+ | BBH_THREE_SHOT | 0.4525 | 0.3317 | **0.7165** | 0.4161 |
67
+ | SuperGPQA | 0.2731 | 0.2092 | **0.3745** | 0.2459 |
68
+ | MATH_500_FOUR_SHOT | 0.7000 | 0.7520 | **0.8880** | 0.8020 |
69
+ | GPQA_COT_ZERO_SHOT | 0.3502 | 0.2651 | **0.5370** | 0.3704 |
70
+ | LiveCodeBench_ZERO_SHOT | 0.2031 | 0.0794 | **0.3046** | 0.1656 |
71
+ | HUMAN_EVAL_PLUS_ZERO_SHOT | 0.6951 | 0.6280 | **0.8780** | 0.7012 |
72
+
73
+
74
+ ## Как проверить метрики модели
75
+
76
+ ```shell
77
+ # lm-eval[api]==0.4.9.1
78
+ # sglang[all]==0.5.5
79
+ # или
80
+ # vllm==0.11.2
81
+
82
+ export HF_ALLOW_CODE_EVAL=1
83
+
84
+ # sglang server up
85
+
86
+ # 10B
87
+ python -m sglang.launch_server --model-path <path_to_model> --host 127.0.0.1 --port 30000 --dtype auto --mem-fraction-static 0.88 --trust-remote-code --allow-auto-truncate --speculative-algorithm EAGLE --speculative-num-steps 1 --speculative-eagle-topk 1 --speculative-num-draft-tokens 2
88
+
89
+ # mmlu pro check
90
+ python -m lm_eval --model sglang-generate --output_path <path_to_model> --batch_size 16 --model_args base_url=http://127.0.0.1:30000/generate,num_concurrent=16,tokenized_requests=True,max_length=131072,tokenizer=<path_to_model> --trust_remote_code --confirm_run_unsafe_code --num_fewshot 5 --tasks mmlu_pro
91
+ ```
92
+
93
+
94
+
95
+ ## Пример использования (Quickstart)
96
+
97
+ ### 1. `transformers`
98
+
99
+ ```python
100
+ import torch
101
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
102
+
103
+ model_name = "ai-sage/GigaChat3-10B-A1.8B-bf16"
104
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
105
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
106
+ model.generation_config = GenerationConfig.from_pretrained(model_name)
107
+
108
+ messages = [
109
+ {"role": "user", "content": "Докажи теорему о неподвижной точке"}
110
+ ]
111
+ input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
112
+ outputs = model.generate(input_tensor.to(model.device), max_new_tokens=1000)
113
+
114
+ result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=False)
115
+ print(result)
116
+ ```
117
+
118
+ ### 2. `vLLM`
119
+
120
+ Запуск сервера
121
+ ```shell
122
+ vllm serve ai-sage/GigaChat3-10B-A1.8B-bf16 \
123
+ --dtype "auto" \
124
+ --speculative-config '{"method": "mtp", "num_speculative_tokens": 1, "disable_padded_drafter_batch": false}'
125
+ ```
126
+
127
+ Пример запроса
128
+ ```shell
129
+ curl http://localhost:8000/v1/chat/completions \
130
+ -H "Content-Type: application/json" \
131
+ -d '{
132
+ "model": "ai-sage/GigaChat3-10B-A1.8B-bf16",
133
+ "messages": [
134
+ {
135
+ "role": "user",
136
+ "content": "Докажи теорему о неподвижной точке"
137
+ }
138
+ ],
139
+ "max_tokens": 400,
140
+ "temperature": 0
141
+ }'
142
+ ```
143
+
144
+ ### 3. `SGLang`
145
+
146
+ Запуск сервера
147
+ ```shell
148
+ python -m sglang.launch_server \
149
+ --model-path ai-sage/GigaChat3-10B-A1.8B-bf16 \
150
+ --host 0.0.0.0 \
151
+ --port 30000 \
152
+ --dtype auto \
153
+ --mem-fraction-static 0.88 \
154
+ --speculative-algorithm EAGLE \
155
+ --speculative-num-steps 1 \
156
+ --speculative-eagle-topk 1 \
157
+ --speculative-num-draft-tokens 2
158
+ ```
159
+
160
+ Пример запроса
161
+ ```shell
162
+ curl http://localhost:30000/v1/chat/completions \
163
+ -H "Content-Type: application/json" \
164
+ -d '{
165
+ "model": "ai-sage/GigaChat3-10B-A1.8B-bf16",
166
+ "messages": [
167
+ {
168
+ "role": "user",
169
+ "content": "Докажи теорему о неподвижной точке"
170
+ }
171
+ ],
172
+ "max_tokens": 1000,
173
+ "temperature": 0
174
+ }'
175
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#--------TOOL RENDERING FUNCTIONS---------#}
2
+
3
+ {#---------------------------------------------------------------
4
+ Converts JSON Schema (dict) to a TypeScript type definition
5
+ ----------------------------------------------------------------#}
6
+ {%- macro json_schema_to_typescript(schema, indent="", indent_factor=2) -%}
7
+ {%- set ADDITIONAL_JSON_KEYS = ['format', 'maxItems', 'maximum', 'minItems', 'minimum', 'pattern'] -%}
8
+ {%- set ty = schema.get("type") -%}
9
+
10
+ {# ---------------- OBJECT ---------------- #}
11
+ {%- if ty == "object" -%}
12
+ {{- "{\n" -}}
13
+
14
+ {# Start building property list #}
15
+ {%- set props = schema.get("properties", {}) -%}
16
+ {%- set required = schema.get("required", []) -%}
17
+ {%- set has_additional_props = schema.get("additionalProperties") is defined -%}
18
+ {%- set additional_props_type = none -%}
19
+ {%- if has_additional_props -%}
20
+ {%- if schema.additionalProperties == true -%}
21
+ {%- set additional_props_type = {'type': 'any'} -%}
22
+ {%- elif schema.additionalProperties is mapping -%}
23
+ {%- set additional_props_type = schema.additionalProperties -%}
24
+ {%- endif -%}
25
+ {%- endif -%}
26
+
27
+ {%- for key, val in props.items() -%}
28
+ {# ---------- Description Comments ---------- #}
29
+ {%- if "description" in val -%}
30
+ {%- for line in val['description'].splitlines() -%}
31
+ {%- if line.strip() -%}
32
+ {{- indent + '// ' + line + '\n' -}}
33
+ {%- endif -%}
34
+ {%- endfor -%}
35
+ {%- endif -%}
36
+
37
+ {# ---------- Additional JSON Keys ---------- #}
38
+ {%- for add_key, add_val in val.items() -%}
39
+ {%- if add_key in ADDITIONAL_JSON_KEYS -%}
40
+ {%- if add_val is string -%}
41
+ {{- indent + '// ' + add_key + ': "' + add_val + '"' + '\n' -}}
42
+ {%- else -%}
43
+ {{- indent + '// ' + add_key + ': ' ~ add_val ~ '\n' -}}
44
+ {%- endif -%}
45
+ {%- endif -%}
46
+ {%- endfor -%}
47
+
48
+ {# ---------- Property Definition ---------- #}
49
+ {%- set type_str = json_schema_to_typescript(
50
+ val,
51
+ indent + (' ' * indent_factor),
52
+ indent_factor
53
+ ) -%}
54
+
55
+ {{- indent + key + ('' if key in required else '?') + ': ' + type_str + ',' -}}
56
+
57
+ {%- if "default" in val or "defalut_value" in val -%}
58
+ {%- set default = val.get("default", val.get("defalut_value")) -%}
59
+ {%- if default is string -%}
60
+ {{- ' // default: "' + default + '"' -}}
61
+ {%- else -%}
62
+ {{- ' // default: ' ~ default -}}
63
+ {%- endif -%}
64
+ {%- endif -%}
65
+
66
+ {{- "\n" -}}
67
+ {%- endfor -%}
68
+
69
+ {# Handle additionalProperties as index signature #}
70
+ {%- if has_additional_props and additional_props_type is not none -%}
71
+ {%- set additional_type_str = json_schema_to_typescript(
72
+ additional_props_type,
73
+ indent + (' ' * indent_factor),
74
+ indent_factor
75
+ ) -%}
76
+ {{- indent + '[key: string]: ' + additional_type_str + '\n' -}}
77
+ {%- endif -%}
78
+
79
+ {{- indent[:-indent_factor] + '}' -}}
80
+
81
+ {# ---------------- STRING ---------------- #}
82
+ {%- elif ty == "string" -%}
83
+ {%- if schema.get("enum") -%}
84
+ {%- set ns = namespace(enum = []) -%}
85
+ {%- for en in schema['enum'] -%}
86
+ {%- set ns.enum = ns.enum + ['"' ~ en ~ '"'] -%}
87
+ {%- endfor -%}
88
+ {{- ns.enum | join(' | ') -}}
89
+ {%- elif schema.get("format") in ['date-time', 'date'] -%}
90
+ {{- 'Date' -}}
91
+ {%- else -%}
92
+ {{- 'string' -}}
93
+ {%- endif -%}
94
+
95
+ {# ---------------- NUMBER / INTEGER ---------------- #}
96
+ {%- elif ty in ["number", "integer"] -%}
97
+ {%- if schema.get("enum") -%}
98
+ {{- schema.enum | join(' | ') -}}
99
+ {%- else -%}
100
+ {{- 'number' -}}
101
+ {%- endif -%}
102
+
103
+ {# ---------------- BOOLEAN ---------------- #}
104
+ {%- elif ty == "boolean" -%}
105
+ {{- 'boolean' -}}
106
+
107
+ {# ---------------- ARRAY ---------------- #}
108
+ {%- elif ty == "array" -%}
109
+ {%- if "items" in schema -%}
110
+ {{- json_schema_to_typescript(schema['items'], indent, indent_factor) + '[]' -}}
111
+ {%- else -%}
112
+ {{- 'Array<any>' -}}
113
+ {%- endif -%}
114
+
115
+ {# ---------------- FALLBACK ---------------- #}
116
+ {%- else -%}
117
+ {{- 'any' -}}
118
+ {%- endif -%}
119
+ {%- endmacro -%}
120
+
121
+ {#---------------------------------------------------------------
122
+ Renders a namespace and its tool definitions in TypeScript style
123
+ ----------------------------------------------------------------#}
124
+
125
+ {%- macro render_tool_namespace(namespace_name, tools) -%}
126
+ {%- set ns = namespace(sections = ['namespace ' ~ namespace_name ~ ' {']) -%}
127
+
128
+ {%- for tool in tools -%}
129
+ {%- if tool.function -%}
130
+ {%- set tool = tool.function -%}
131
+ {%- endif -%}
132
+
133
+ {%- set ns_tool = namespace(content_lines=[]) -%}
134
+
135
+ {# ---------- TOOL DESCRIPTION ---------- #}
136
+ {%- if tool.get('description') -%}
137
+ {%- for line in tool['description'].splitlines() -%}
138
+ {%- if line.strip() -%}
139
+ {%- set ns_tool.content_lines = ns_tool.content_lines + ['// ' ~ line] -%}
140
+ {%- endif -%}
141
+ {%- endfor -%}
142
+ {%- endif -%}
143
+
144
+ {# ---------- TOOL SIGNATURE ---------- #}
145
+ {%- set main_body = "" -%}
146
+ {%- set params = tool.get("parameters") -%}
147
+ {%- if params and params.get("properties") -%}
148
+ {%- set param_type = json_schema_to_typescript(params, " ") -%}
149
+ {%- set main_body = 'type ' ~ tool.name ~ ' = (_: ' ~ param_type ~ ') => ' -%}
150
+ {%- else -%}
151
+ {%- set main_body = 'type ' ~ tool.name ~ ' = () => ' -%}
152
+ {%- endif -%}
153
+
154
+ {# ---------- RETURN TYPE ---------- #}
155
+ {%- set return_params = tool.get("return_parameters") -%}
156
+ {%- if return_params and return_params.get("properties") -%}
157
+ {%- set return_type = json_schema_to_typescript(return_params, " ") -%}
158
+ {%- set main_body = main_body ~ return_type -%}
159
+ {%- else -%}
160
+ {%- set main_body = main_body ~ 'any' -%}
161
+ {%- endif -%}
162
+
163
+ {%- set main_body = main_body ~ ';\n' -%}
164
+
165
+ {%- set ns_tool.content_lines = ns_tool.content_lines + [main_body] -%}
166
+
167
+ {# ---------- ADD TOOL TO SECTIONS ---------- #}
168
+ {%- set ns.sections = ns.sections + [ns_tool.content_lines | join('\n')] -%}
169
+ {%- endfor -%}
170
+
171
+ {%- set ns.sections = ns.sections + ['} // namespace ' ~ namespace_name] -%}
172
+
173
+ {{- ns.sections | join('\n') -}}
174
+ {%- endmacro -%}
175
+
176
+
177
+ {# ----------- MESSAGE RENDERING HELPER FUNCTIONS ------------ #}
178
+
179
+ {%- macro render_role_message(message, role=None) -%}
180
+ {%- if not role -%}
181
+ {%- set role = message["role"] -%}
182
+ {%- endif -%}
183
+
184
+ {%- set message_content = message['content'] or '' -%}
185
+ {%- if message_content is not string -%}
186
+ {%- set message_content = message_content | tojson(ensure_ascii=False) -%}
187
+ {%- endif -%}
188
+
189
+ {{- role + add_tokens.role_sep + message_content + add_tokens.message_sep -}}
190
+
191
+ {%- endmacro -%}
192
+
193
+
194
+ {%- macro render_function_call(message) -%}
195
+ {%- set call = message['content'] -%}
196
+ {%- if call.function -%}
197
+ {%- set call = call.function -%}
198
+ {%- endif -%}
199
+
200
+ {%- set arguments = call['arguments'] -%}
201
+ {%- if arguments is not string -%}
202
+ {%- set arguments = arguments| tojson(ensure_ascii=False) -%}
203
+ {%- endif -%}
204
+
205
+ {{- render_role_message(
206
+ {
207
+ 'role': 'function call',
208
+ 'content': '{"name": "' ~ call['name'] ~ '", "arguments": ' ~ arguments ~ '}'
209
+ }
210
+ ) -}}
211
+ {%- endmacro -%}
212
+
213
+ {# ----- SPECIAL TOKENS ----- #}
214
+
215
+ {%- set add_tokens = namespace(
216
+ role_sep="<|role_sep|>\n",
217
+ message_sep="<|message_sep|>\n\n"
218
+ ) -%}
219
+
220
+ {# ----- DEFAULT DEVSYSTEM ----- #}
221
+
222
+ {%- set DEVSYSTEM -%}
223
+ <role_description>
224
+ Description of the roles available in the dialog.
225
+
226
+ `developer system`
227
+ A message added by Sber before the main dialog. It has the highest priority and sets global, non-overridable conditions (for example, conversation rules, the safety policy, the assistant's overall response style, etc.).
228
+
229
+ `system`
230
+ A system instruction added by developers or by the user, but with a lower priority than `developer system`. It usually describes the assistant's instructions, a specific response style, and other conditions for this particular dialog.
231
+
232
+ `user`
233
+ A message or request from the user. The assistant follows it if it does not conflict with higher-priority instructions (see <instruction_priority>).
234
+
235
+ `user memory`
236
+ A sequence of the most up-to-date long-term facts about the user at the time of their request, presented as a JSON list of strings. Facts are listed in chronological order, meaning newer facts are appended to the end of the sequence. When facts are changed or deleted, records of previous facts remain in the sequence. The assistant saves facts using a function and uses them in accordance with the <memory_guidelines> block below.
237
+
238
+ `added files`
239
+ Metadata about files available for use in the dialog, presented in JSON format. It contains the following keys: id (a unique file identifier), name (file name), type (file type).
240
+
241
+ `assistant`
242
+ The assistant's reply to the user's request. If the system instruction or the user does not set additional rules for `assistant`, this reply must comply with the instructions in the <assistant_guidelines> block below. The list of functions available to call is contained in `function descriptions`. The name of the required function and its arguments will be generated next by the `function call` role. In its replies, the assistant follows the instructions in accordance with <instruction_priority>.
243
+
244
+ `function descriptions`
245
+ Function descriptions in TypeScript format. A function is a special tool (or a set of instructions) that the assistant can call to perform specific actions, computations, or obtain data needed to solve the user's task. Each function description contains blocks with the name, description, and arguments. Sometimes the description contains separate blocks with return parameters and usage examples that illustrate the correct call and arguments.
246
+
247
+ `function call`
248
+ The function that `assistant` calls based on the dialog context, and its arguments. The function is invoked in strict accordance with the instructions in the <function_usage> block.
249
+
250
+ `function result`
251
+ The result of the last function call.
252
+ </role_description>
253
+
254
+ <available_modalities>
255
+ The assistant can work with the following modalities: text, available functions.
256
+ </available_modalities>
257
+
258
+ <instruction_priority>
259
+ If instructions from different roles conflict within the dialog context, observe the following priorities:
260
+ `developer system` > `system` > `user` > `function descriptions` > `function result` > `user memory`
261
+ </instruction_priority>
262
+
263
+ <function_usage>
264
+ Basic instructions for working with functions.
265
+
266
+ Only call those functions that are described in `function descriptions`.
267
+
268
+ Call available functions when, according to their description, such a call will help provide a more complete and/or accurate answer to the user's request. Fill in function arguments using information from the dialog context. If a function could help answer the request but a required argument is missing from the context, ask the user for the missing data before calling the function. If a necessary function is unavailable or an error occurs, briefly inform the user and, if possible, suggest an alternative.
269
+ </function_usage>
270
+
271
+ <memory_guidelines>
272
+ Rules for using facts in long-term memory:
273
+
274
+ If there is no message under the `user memory` role in the dialog, this is equivalent to the absence of long-term facts about the user in memory. In that case, information about the user is limited to the current dialog, and no new facts should be saved.
275
+ </memory_guidelines>
276
+
277
+ <assistant_guidelines>
278
+ You are a helpful assistant.
279
+
280
+ # Instructions
281
+ - Strictly follow the instruction priority.
282
+ - Maintain a logical chain of reasoning when answering the user's question.
283
+ - For complex questions (for example, STEM), try to answer in detail unless the system message or dialog context limits the response length.
284
+ - Be helpful, truthful, and avoid unsafe or prohibited content in your responses.
285
+ - Try to reply in the language in which the user asked their question.
286
+ </assistant_guidelines>
287
+
288
+ A dialog will follow below.
289
+ The dialog may include various roles described in the <role_description> block.
290
+ Each turn begins with the role name and a special token that marks the end of the role's full name, and ends with a special end-of-turn token.
291
+ Your task is to continue the dialog from the last specified role in accordance with the dialog context.
292
+ {%- endset -%}
293
+
294
+
295
+ {#- ---------------------- RENDERING STARTS HERE ---------------------- -#}
296
+
297
+
298
+ {# ----- RENDER BOS TOKEN ----- #}
299
+ {{- bos_token -}}
300
+
301
+
302
+ {# ----- RENDER DEVSYSTEM ----- #}
303
+ {{- render_role_message({"role": "developer system", "content": DEVSYSTEM}) -}}
304
+
305
+ {# ----- RENDER SYSTEM IF PRESENT ----- #}
306
+ {%- if messages and messages[0]['role'] == 'system' -%}
307
+ {{- render_role_message(messages[0]) -}}
308
+ {%- set messages = messages[1:] -%}
309
+ {%- endif -%}
310
+
311
+ {# ----- RENDER TOOLS ----- #}
312
+ {%- if tools -%}
313
+ {%- set tools_content = (
314
+ render_tool_namespace('functions', tools)
315
+ + "\n\n"
316
+ ) -%}
317
+ {{- render_role_message({'role': 'function descriptions', 'content': tools_content}) -}}
318
+ {%- endif -%}
319
+
320
+ {# ----- MAIN MESSAGE LOOP ----- #}
321
+ {%- for message in messages -%}
322
+
323
+ {# ----- TOOL MESSAGE -------#}
324
+ {%- if message['role'] == 'tool' -%}
325
+ {{- render_role_message(message, role='function result') -}}
326
+
327
+
328
+ {# ----- ASSISTANT MESSAGE ----- #}
329
+ {%- elif message['role'] == 'assistant' -%}
330
+
331
+ {# ----- FUNCTION CALL PART CHECKING: SINGLE CALL SETUP ----- #}
332
+ {%- if message.tool_calls is defined and message.tool_calls -%}
333
+ {%- set function_call = message.tool_calls[0] -%}
334
+ {%- else -%}
335
+ {%- set function_call = None -%}
336
+ {%- endif -%}
337
+
338
+ {# ----- MAIN ASSISTANT RENDERING ----- #}
339
+
340
+ {{- render_role_message({'role': 'assistant', 'content': message.content}) -}}
341
+ {%- if function_call -%}
342
+ {{- render_function_call({'role': 'function call', 'content': function_call}) -}}
343
+ {%- endif -%}
344
+
345
+
346
+ {# ----- OTHER MESSAGES ----- #}
347
+ {%- else -%}
348
+ {{- render_role_message(message) -}}
349
+ {%- endif -%}
350
+
351
+ {# ----- ADDING GENERATION PROMPT ----- #}
352
+
353
+ {%- if loop.last and add_generation_prompt and message['role'] != 'assistant' -%}
354
+ {{- 'assistant' + add_tokens.role_sep -}}
355
+ {%- endif -%}
356
+
357
+ {%- endfor -%}
config.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "vocab_size": 128256,
3
+ "max_position_embeddings": 262144,
4
+ "hidden_size": 1536,
5
+ "intermediate_size": 8960,
6
+ "moe_intermediate_size": 1280,
7
+ "num_hidden_layers": 26,
8
+ "num_nextn_predict_layers": 1,
9
+ "num_attention_heads": 32,
10
+ "n_shared_experts": 1,
11
+ "n_routed_experts": 64,
12
+ "ep_size": 1,
13
+ "routed_scaling_factor": 1,
14
+ "kv_lora_rank": 512,
15
+ "q_lora_rank": null,
16
+ "qk_rope_head_dim": 64,
17
+ "v_head_dim": 192,
18
+ "qk_nope_head_dim": 128,
19
+ "topk_method": "noaux_tc",
20
+ "n_group": 1,
21
+ "topk_group": 1,
22
+ "num_experts_per_tok": 4,
23
+ "moe_layer_freq": 1,
24
+ "first_k_dense_replace": 1,
25
+ "norm_topk_prob": true,
26
+ "scoring_func": "sigmoid",
27
+ "num_key_value_heads": 32,
28
+ "hidden_act": "silu",
29
+ "initializer_range": 0.006,
30
+ "rms_norm_eps": 1e-06,
31
+ "use_cache": true,
32
+ "rope_theta": 100000,
33
+ "rope_scaling": {
34
+ "beta_fast": 32,
35
+ "beta_slow": 1,
36
+ "factor": 64.0,
37
+ "mscale": 1.0,
38
+ "mscale_all_dim": 1.0,
39
+ "original_max_position_embeddings": 4096,
40
+ "type": "yarn"
41
+ },
42
+ "attention_bias": false,
43
+ "attention_dropout": 0.0,
44
+ "tie_word_embeddings": false,
45
+ "architectures": [
46
+ "DeepseekV3ForCausalLM"
47
+ ],
48
+ "bos_token_id": 1,
49
+ "eos_token_id": 2,
50
+ "transformers_version": "4.57.1",
51
+ "model_type": "deepseek_v3",
52
+ "dtype": "bfloat16"
53
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "temperature": 0.7,
3
+ "top_p": 0.3,
4
+ "repetition_penalty": 1.1,
5
+ "do_sample": true,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "pad_token_id": 2
9
+ }
model-00000-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da25ceee4caf0713346bd4c63b726b1550c41d130b796e9330eb4427917bec98
3
+ size 4986065392
model-00001-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f005b3cd335d1b77b8275abd171da1c9bb951ccf707b4145e1be1462074f228a
3
+ size 37440
model-00002-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56617279611142173dac0e467a6183f7be09440ac1b2b30df9fa3e127b2e83cd
3
+ size 37456
model-00003-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0599c2553a9c72a1b59ea784a42114d0481587021756a64cdf7fd9f7e447e5ea
3
+ size 37456
model-00004-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d36588fce12b9a3d75c00e59a58ec0189d23e10e33104b50223bfacdec288e92
3
+ size 37456
model-00005-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ef8cd08aaacca0e8ec8acacb9cfc929dcfe88090902f2251160a22729e42c80
3
+ size 14984
model-00006-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:917df3f27b16cebbb3ef32cf325898c03935124d60d5f5fb240eb5328c6f6d11
3
+ size 4084983648
model-00007-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8dabf07c95d3da8b4077cfd73b07b2705a17ce920fc674c41e931f2579af169f
3
+ size 4084984456
model-00008-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f377b6d944fb168966ccac4d2941417e683edca991db40fcdfc4831d8222390a
3
+ size 4084984656
model-00009-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:039ca2878f2074f27a4bcfd121581f02ab7e36f54c927d5a0ca2b1f8da221f66
3
+ size 4084984656
model-00010-of-00010.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa3c7d6e8246e60508f713ce6e0e09f206ee9726cd8e9a4aa8362afac685b91a
3
+ size 1633993536
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ }
16
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fdb3c045850a565109244ef3b89475cc2582769417647a41c46da14a3782aa5
3
+ size 10680605
tokenizer_config.json ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "1": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "2": {
12
+ "content": "</s>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "128000": {
20
+ "content": "<|role_sep|>\n",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "128001": {
28
+ "content": "<|message_sep|>\n\n",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128002": {
36
+ "content": "<|file|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "128003": {
44
+ "content": "<|/file|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "128004": {
52
+ "content": "[image_token]",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "128005": {
60
+ "content": "[video_image_token]",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "128006": {
68
+ "content": "[audio_token]",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "128007": {
76
+ "content": "[video_audio_token]",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "128008": {
84
+ "content": "<point>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "128009": {
92
+ "content": "</point>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "128010": {
100
+ "content": "<bbox>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "128011": {
108
+ "content": "</bbox>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ }
115
+ },
116
+ "bos_token": "<s>",
117
+ "clean_up_tokenization_spaces": true,
118
+ "eos_token": "</s>",
119
+ "extra_special_tokens": {},
120
+ "model_max_length": 1000000000000000019884624838656,
121
+ "tokenizer_class": "PreTrainedTokenizer",
122
+ "unk_token": null
123
+ }