mikelalda commited on
Commit
0b65cb2
·
verified ·
1 Parent(s): 364dbeb

Qwen3.5-27B ALIA SFT LoRA merged (bf16)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
README.md ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/Qwen3.8-27B
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ license: cc-by-sa-4.0
6
+ language:
7
+ - eu
8
+ - es
9
+ - en
10
+ datasets:
11
+ - HiTZ/RAG_eu
12
+ - HiTZ/magpie-en-eu-reasoning-instructions-qwen3
13
+ - HiTZ/ALIA_syntethic_MT_V2
14
+ tags:
15
+ - unsloth
16
+ - trl
17
+ - sft
18
+ - lora
19
+ - peft
20
+ - qwen3_8
21
+ - basque
22
+ - euskara
23
+ - translation
24
+ ---
25
+
26
+ # qwen27b_alia_tuned
27
+
28
+ **Qwen3.8-27B** modeloaren doikuntza fina (SFT LoRArekin), **euskarara**
29
+ bideratua, gaztelania eta ingelesa laguntza-hizkuntza gisa erabilita.
30
+ [HiTZ](https://huggingface.co/HiTZ) taldearen corpusekin entrenatu da hiru
31
+ gaitasun lantzeko: elkarrizketa bidezko instrukzioak, norabide anitzeko
32
+ itzulpena eta testu batean oinarritutako lana (laburpena eta erantzun
33
+ daitekeen erabakitzea).
34
+
35
+ > **Egoera: ebaluatu gabe.** Ez da benchmarkik exekutatu modelo honekin.
36
+ > Errendimendu-atala nahita dago hutsik; oraindik ez dago kalitateari buruzko
37
+ > baieztapenik bermatuko duen daturik.
38
+
39
+ ---
40
+
41
+ ## Modeloaren xehetasunak
42
+
43
+ | | |
44
+ |---|---|
45
+ | Oinarrizko modeloa | [`unsloth/Qwen3.8-27B`](https://huggingface.co/unsloth/Qwen3.8-27B) (`Qwen3_5ForConditionalGeneration`) |
46
+ | Metodoa | LoRA (PEFT), [Unsloth](https://github.com/unslothai/unsloth) + TRL `SFTTrainer` bidez |
47
+ | Zehaztasuna | BF16 (entrenamenduan kuantizaziorik gabe) |
48
+ | Sekuentzia-luzera | 4096 |
49
+ | Hizkuntzak | euskara (eu), gaztelania (es), ingelesa (en) |
50
+
51
+ Qwen3.8-27B **arreta linealeko modelo hibridoa** da (*gated delta rule*).
52
+ Zentzuzko errendimenduarekin entrenatu edo zerbitzatzeko,
53
+ `flash-linear-attention` instalatuta edukitzea komeni da; hura gabe,
54
+ `transformers` PyTorch hutsezko inplementazio askoz motelago batera igarotzen
55
+ da.
56
+
57
+ Oinarrizko modeloa **multimodala** da (irudiak eta bideoak onartzen ditu).
58
+ Doikuntza honek testu-dorreko moduluak baino ez ditu ukitu, eta **ikusmen-bidea
59
+ ez da entrenatu edo egiaztatu**: oinarrizko modelotik heredatutakotzat hartu.
60
+
61
+ ### LoRA konfigurazioa
62
+
63
+ | Parametroa | Balioa |
64
+ |---|---|
65
+ | `r` | 32 |
66
+ | `lora_alpha` | 32 |
67
+ | `lora_dropout` | 0 |
68
+ | `bias` | `none` |
69
+ | Moduluak | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` |
70
+ | Gradient checkpointing | `True` |
71
+
72
+ ### Entrenamenduaren hiperparametroak
73
+
74
+ | Parametroa | Balioa |
75
+ |---|---|
76
+ | Epokak | 0,276 |
77
+ | Gailu bakoitzeko lotea | 8 |
78
+ | Gradiente-metaketa | 2 (lote eraginkorra: **8**) |
79
+ | Learning rate | 1.5e-4 |
80
+ | Scheduler | cosine, warmup 3 % |
81
+ | Optimizatzailea | `adamw_8bit` |
82
+ | Weight decay | 0.01 |
83
+ | Hazia | 3407 |
84
+ | Hardware | 1 × NVIDIA RTX PRO 6000 Blackwell (96 GB) |
85
+
86
+ ---
87
+
88
+ ## Entrenamendu-datuak
89
+
90
+ Hiru corpusak `text` eremu bakarrean homogeneizatzen dira, **modeloaren
91
+ berezko txat-txantiloia** aplikatuta, eta ausaz nahasten dira (3407 hazia).
92
+
93
+ ### 1. `HiTZ/magpie-en-eu-reasoning-instructions-qwen3` — instrukzioak
94
+
95
+ `accepted_eu` eta `accepted_en` splitak, bakoitzetik 25 000 adibide (~50 000).
96
+ `rejected_*` splitak baztertu egiten dira. Elkarrizketak `messages` eremutik
97
+ hartzen dira, txanda bakoitzeko `reasoning_content` kenduta.
98
+
99
+ ### 2. `HiTZ/ALIA_syntethic_MT_V2` — itzulpena
100
+
101
+ Hiru konfigurazioetako bakoitzetik 5 000 errenkada (`berria_eu_en_es`,
102
+ `bopv_eu_en_es`, `parliament_eu_en_es`). Errenkada bakoitzak norabide **bat**
103
+ sortzen du, indizearen arabera txandakatuz laurak neurri berean betetzeko:
104
+
105
+ `eu → es` · `es → eu` · `eu → en` · `en → eu`
106
+
107
+ `berria` konfigurazioan, SONAR puntuazioa < 0.6 duten itzulpenak baztertzen
108
+ dira.
109
+
110
+ ### 3. `HiTZ/RAG_eu` — testuan oinarritzea
111
+
112
+ `RAG_eu` **ebaluazio-bankua** da, ez entrenamendu-corpusa: ez du erantzunen
113
+ zutaberik. Daukan edukitik bi ataza gainbegiratu sortu ziren:
114
+
115
+ - **Testuan oinarritutako laburpena** — `documents` konfigurazioa (1 492
116
+ dokumentu): `text` → `summary`.
117
+ - **Erantzun daitekeen erabakitzea** — `QAP` konfigurazioa (~7 465 pare),
118
+ `documents` konfigurazioarekin `text_id` bidez lotuta, galdera bakoitzari
119
+ benetako testuingurua eransteko.
120
+
121
+ > ⚠️ **Ebaluazio-kutsadura.** Modeloak `HiTZ/RAG_eu` ikusi du entrenamenduan;
122
+ > beraz, **ez da baliozkoa benchmark horrekin ebaluatzea**. RAG_eu gainean
123
+ > neurtu behar baduzu, berriro entrenatu `train.py` fitxategian
124
+ > `USE_RAG_EU = False` ezarrita.
125
+
126
+ Guztira, gutxi gorabehera: **~74 000 adibide** (kalitate-iragazkiak aplikatu
127
+ eta `text_id` umezurtzak baztertu aurretik).
128
+
129
+ ---
130
+
131
+ ## Prompt-formatuak
132
+
133
+ Entrenamenduak Qwen3.5 modeloaren berezko txantiloia erabiltzen du
134
+ **`enable_thinking=False`** aukerarekin, target guztiak erantzun zuzenak baitira.
135
+ Arrazoiketa-moduan horrek duen eragina ikusteko, irakurri mugen atala.
136
+
137
+ **Itzulpena** — system:
138
+
139
+ ```
140
+ Itzultzaile profesionala zara. Eres un traductor profesional.
141
+ ```
142
+
143
+ user:
144
+
145
+ ```
146
+ Itzuli ondorengo testua euskarara / Traduce el siguiente texto al euskera:
147
+ {texto}
148
+ ```
149
+
150
+ (erabilitako hizkuntza-helburu pareak hauek izan ziren:
151
+ `euskarara`/`al euskera`, `gaztelaniara`/`al español`,
152
+ `ingelesera`/`al inglés`)
153
+
154
+ **Testuan oinarritzea** — system:
155
+
156
+ ```
157
+ Laguntzaile zehatza zara. Erantzun emandako testuan oinarrituta soilik.
158
+ Eres un asistente preciso. Responde basándote estrictamente en el texto proporcionado.
159
+ ```
160
+
161
+ user (laburpena):
162
+
163
+ ```
164
+ Testua / Texto:
165
+ """
166
+ {texto}
167
+ """
168
+
169
+ Laburtu testua / Resume el texto.
170
+ ```
171
+
172
+ user (erantzun daitekeen erabakitzea):
173
+
174
+ ```
175
+ Testua / Contexto:
176
+ """
177
+ {contexto}
178
+ """
179
+
180
+ Galdera / Pregunta: {pregunta}
181
+
182
+ Testuak galdera erantzun dezake? / ¿Puede el texto responder a la pregunta?
183
+ ```
184
+
185
+ **Instrukzio orokorrak**: sistema-mezurik gabe, elkarrizketa zuzena.
186
+
187
+ ---
188
+
189
+ ## Erabilera
190
+
191
+ ### Transformers
192
+
193
+ ```python
194
+ from transformers import AutoModelForCausalLM, AutoTokenizer
195
+
196
+ model_id = "TU_USUARIO/qwen27b_alia"
197
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
198
+ model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
199
+
200
+ messages = [
201
+ {"role": "system", "content": "Itzultzaile profesionala zara. Eres un traductor profesional."},
202
+ {"role": "user", "content": "Itzuli ondorengo testua euskarara / Traduce el siguiente texto al euskera:\nBuenos días a todos."},
203
+ ]
204
+
205
+ inputs = tokenizer.apply_chat_template(
206
+ messages,
207
+ add_generation_prompt=True,
208
+ enable_thinking=False, # entrenamenduarekin bat dator
209
+ return_tensors="pt",
210
+ ).to(model.device)
211
+
212
+ out = model.generate(inputs, max_new_tokens=512)
213
+ print(tokenizer.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))
214
+ ```
215
+
216
+ Arreta linealeko geruzak bizkortzeko:
217
+
218
+ ```bash
219
+ pip install flash-linear-attention
220
+ ```
221
+
222
+ ### GGUF (llama.cpp / Ollama)
223
+
224
+ **Q4_K_M** esportazio kuantizatu bat ere badago:
225
+
226
+ ```bash
227
+ llama-cli -m qwen27b_alia-q4_k_m.gguf -p "..." -cnv
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Mugak eta alborapenak
233
+
234
+ - **Ebaluatu gabe.** Ez dago metrikarik. Ez erabili modelo hau produkzioan
235
+ aurrez zeure atazan neurtu gabe.
236
+ - **Entrenatu gabeko arrazoiketa.** SFT osoa `enable_thinking=False` aukerarekin
237
+ eta target zuzenekin egin zen. Oinarrizko modeloaren arrazoiketa-modua ez da
238
+ indartu, eta baliteke okerrera egin izana; sortu edukia
239
+ `enable_thinking=False` erabilita, kontrakoa egiaztatu ezean.
240
+ - **Ezin da `HiTZ/RAG_eu` erabiliz ebaluatu**, kutsadura dela eta (ikus goian).
241
+ - **Epoka bakarra** ~74 000 adibiderekin: estiloaren eta formatuaren doikuntza
242
+ arina da, ez ezagutzaren injekzio sakona.
243
+ - **Itzulpen sintetikoa.** `ALIA_syntethic_MT_V2` datu-multzoak automatikoki
244
+ sortutako itzulpenak ditu; haien errore sistematikoak modelora hedatzen dira.
245
+ SONAR iragazkia `berria` partizioari soilik aplikatu zitzaion.
246
+ - **Domeinu-alborapena.** Corpusak prentsatik (*Berria*), aldizkari ofizialetik
247
+ (EHAA) eta Eusko Legebiltzarreko aktetatik datoz. Erregistroak formala eta
248
+ instituzionala izateko joera du, eta euskal politika garaikidean ardazten da.
249
+ - **Egiaztatu gabeko bide multimodala** (ikus goian).
250
+ - Qwen3.8-27B modeloaren alborapenak eta mugak heredatzen ditu.
251
+
252
+ ---
253
+
254
+ ## Lizentzia
255
+
256
+ Modelo honen lizentzia aukeratzea **ez da erraza**, eta berrikustea komeni da:
257
+
258
+ - Oinarrizko modeloa, `Qwen3.8-27B`, **Apache-2.0** lizentziapean dago.
259
+ - `HiTZ/RAG_eu` eta `HiTZ/ALIA_syntethic_MT_V2` **CC-BY-SA-4.0** dira
260
+ (*share-alike*); `HiTZ/magpie-...-qwen3`, berriz, **CC-BY-4.0** da.
261
+
262
+ Metadatu hauetan **CC-BY-SA-4.0** ezarri da, interpretazio kontserbadoreari
263
+ jarraituz: entrenamendu-datuen *share-alike* baldintza hedatzea. Kontrako
264
+ interpretazioa ere badago, pisuak ez direla corpusaren lan eratorria dioena;
265
+ kasu horretan, Apache-2.0 nahikoa litzateke. Adostasunik gabeko auzi juridikoa
266
+ da. **Erabaki eta egokitu `license` eremua horren arabera.**
267
+
268
+ Edonola ere, corpusengatik HiTZ aitortu behar da.
269
+
270
+ ---
271
+
272
+ ## Kredituak
273
+
274
+ - Corpusak: [HiTZ Zentroa](https://huggingface.co/HiTZ) (UPV/EHU), Eusko
275
+ Jaurlaritzak (IKER-GAITU proiektua) eta Eraldaketa Digitalerako Ministerioak /
276
+ NextGenerationEUk (ILENIA eta ALIA proiektuak) finantzatuak.
277
+ - Oinarrizko modeloa: Qwen Team,
278
+ [Unsloth](https://huggingface.co/unsloth)ek paketatua.
279
+ - Entrenamendua: Unsloth + TRL.
chat_template.jinja ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- set sysns = namespace(count=0, text='') %}
46
+ {%- for message in messages %}
47
+ {%- if sysns.count == loop.index0 and (message.role == 'system' or message.role == 'developer') %}
48
+ {%- set sys_content = render_content(message.content, false, true)|trim %}
49
+ {%- if sys_content %}
50
+ {%- set sysns.text = sysns.text + ('\n' if sysns.text else '') + sys_content %}
51
+ {%- endif %}
52
+ {%- set sysns.count = sysns.count + 1 %}
53
+ {%- endif %}
54
+ {%- endfor %}
55
+ {%- set num_sys = sysns.count %}
56
+ {%- set merged_system = sysns.text %}
57
+ {%- set reasoning_instructions = '' %}
58
+ {%- if enable_thinking is undefined or enable_thinking is true %}
59
+ {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}
60
+ {%- if resolved_reasoning_effort == 'high' %}
61
+ {%- set resolved_reasoning_effort = 'xhigh' %}
62
+ {%- endif %}
63
+ {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
64
+ {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}
65
+ {%- endif %}
66
+ {%- if resolved_reasoning_effort == 'xhigh' %}
67
+ {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
68
+ {%- elif resolved_reasoning_effort == 'low' %}
69
+ {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
70
+ {%- endif %}
71
+ {%- endif %}
72
+ {%- if tools and tools is iterable and tools is not mapping %}
73
+ {{- '<|im_start|>system\n' }}
74
+ {%- if reasoning_instructions %}
75
+ {{- reasoning_instructions + '\n\n' }}
76
+ {%- endif %}
77
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
78
+ {%- for tool in tools %}
79
+ {{- "\n" }}
80
+ {{- tool | tojson }}
81
+ {%- endfor %}
82
+ {{- "\n</tools>" }}
83
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
84
+ {%- if merged_system %}
85
+ {{- '\n\n' + merged_system }}
86
+ {%- endif %}
87
+ {{- '<|im_end|>\n' }}
88
+ {%- else %}
89
+ {%- if merged_system %}
90
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + merged_system + '<|im_end|>\n' }}
91
+ {%- elif reasoning_instructions %}
92
+ {{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
93
+ {%- endif %}
94
+ {%- endif %}
95
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
96
+ {%- for message in messages[::-1] %}
97
+ {%- set index = (messages|length - 1) - loop.index0 %}
98
+ {%- if ns.multi_step_tool and message.role == "user" %}
99
+ {%- set content = render_content(message.content, false)|trim %}
100
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
101
+ {%- set ns.multi_step_tool = false %}
102
+ {%- set ns.last_query_index = index %}
103
+ {%- endif %}
104
+ {%- endif %}
105
+ {%- endfor %}
106
+ {%- for message in messages %}
107
+ {%- if loop.index0 >= num_sys %}
108
+ {%- set content = render_content(message.content, true)|trim %}
109
+ {%- if message.role == "system" or message.role == "developer" %}
110
+ {{- raise_exception('System message must be at the beginning.') }}
111
+ {%- elif message.role == "user" %}
112
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
113
+ {%- elif message.role == "assistant" %}
114
+ {%- set reasoning_content = '' %}
115
+ {%- if message.reasoning_content is string %}
116
+ {%- set reasoning_content = message.reasoning_content %}
117
+ {%- endif %}
118
+ {%- set reasoning_content = reasoning_content|trim %}
119
+ {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}
120
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
121
+ {%- else %}
122
+ {{- '<|im_start|>' + message.role + '\n' + content }}
123
+ {%- endif %}
124
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
125
+ {%- for tool_call in message.tool_calls %}
126
+ {%- if tool_call.function is defined %}
127
+ {%- set tool_call = tool_call.function %}
128
+ {%- endif %}
129
+ {%- if tool_call.name is not defined or tool_call.name is none %}
130
+ {{- raise_exception('Tool call is missing a function name.') }}
131
+ {%- endif %}
132
+ {%- if loop.first %}
133
+ {%- if content|trim %}
134
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
135
+ {%- else %}
136
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
137
+ {%- endif %}
138
+ {%- else %}
139
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
140
+ {%- endif %}
141
+ {%- if tool_call.arguments is mapping %}
142
+ {%- for args_name, args_value in tool_call.arguments|items %}
143
+ {{- '<parameter=' + args_name + '>\n' }}
144
+ {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
145
+ {{- args_value }}
146
+ {{- '\n</parameter>\n' }}
147
+ {%- endfor %}
148
+ {%- elif tool_call.arguments is string %}
149
+ {%- if tool_call.arguments|trim %}
150
+ {{- raise_exception('Tool call arguments for function "' + (tool_call.name | string) + '" were passed as a JSON string. Parse them into an object before calling apply_chat_template.') }}
151
+ {%- endif %}
152
+ {%- elif tool_call.arguments is defined and tool_call.arguments is not none %}
153
+ {{- raise_exception('Tool call arguments for function "' + (tool_call.name | string) + '" must be an object/mapping or a JSON string.') }}
154
+ {%- endif %}
155
+ {{- '</function>\n</tool_call>' }}
156
+ {%- endfor %}
157
+ {%- endif %}
158
+ {{- '<|im_end|>\n' }}
159
+ {%- elif message.role == "tool" %}
160
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
161
+ {{- '<|im_start|>user' }}
162
+ {%- endif %}
163
+ {{- '\n<tool_response>\n' }}
164
+ {{- content }}
165
+ {{- '\n</tool_response>' }}
166
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
167
+ {{- '<|im_end|>\n' }}
168
+ {%- elif loop.last %}
169
+ {{- '<|im_end|>\n' }}
170
+ {%- endif %}
171
+ {%- else %}
172
+ {{- raise_exception('Unexpected message role.') }}
173
+ {%- endif %}
174
+ {%- endif %}
175
+ {%- endfor %}
176
+ {%- if add_generation_prompt %}
177
+ {{- '<|im_start|>assistant\n' }}
178
+ {%- if enable_thinking is defined and enable_thinking is false %}
179
+ {{- '<think>\n\n</think>\n\n' }}
180
+ {%- else %}
181
+ {{- '<think>\n' }}
182
+ {%- endif %}
183
+ {%- endif %}
184
+ {#- Unsloth fixes - developer role, merged system messages, tool calling #}
config.json ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "torch_dtype": "bfloat16",
6
+ "image_token_id": 248056,
7
+ "language_model_only": false,
8
+ "model_name": "unsloth/Qwen3.8-27B",
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": 248044,
16
+ "torch_dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 5120,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 17408,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention",
49
+ "linear_attention",
50
+ "linear_attention",
51
+ "linear_attention",
52
+ "full_attention",
53
+ "linear_attention",
54
+ "linear_attention",
55
+ "linear_attention",
56
+ "full_attention",
57
+ "linear_attention",
58
+ "linear_attention",
59
+ "linear_attention",
60
+ "full_attention",
61
+ "linear_attention",
62
+ "linear_attention",
63
+ "linear_attention",
64
+ "full_attention",
65
+ "linear_attention",
66
+ "linear_attention",
67
+ "linear_attention",
68
+ "full_attention",
69
+ "linear_attention",
70
+ "linear_attention",
71
+ "linear_attention",
72
+ "full_attention",
73
+ "linear_attention",
74
+ "linear_attention",
75
+ "linear_attention",
76
+ "full_attention",
77
+ "linear_attention",
78
+ "linear_attention",
79
+ "linear_attention",
80
+ "full_attention",
81
+ "linear_attention",
82
+ "linear_attention",
83
+ "linear_attention",
84
+ "full_attention",
85
+ "linear_attention",
86
+ "linear_attention",
87
+ "linear_attention",
88
+ "full_attention"
89
+ ],
90
+ "linear_conv_kernel_dim": 4,
91
+ "linear_key_head_dim": 128,
92
+ "linear_num_key_heads": 16,
93
+ "linear_num_value_heads": 48,
94
+ "linear_value_head_dim": 128,
95
+ "mamba_ssm_dtype": "float32",
96
+ "max_position_embeddings": 262144,
97
+ "model_type": "qwen3_5_text",
98
+ "mtp_num_hidden_layers": 1,
99
+ "mtp_use_dedicated_embeddings": false,
100
+ "num_attention_heads": 24,
101
+ "num_hidden_layers": 64,
102
+ "num_key_value_heads": 4,
103
+ "output_gate_type": "swish",
104
+ "pad_token_id": null,
105
+ "partial_rotary_factor": 0.25,
106
+ "rms_norm_eps": 1e-06,
107
+ "rope_parameters": {
108
+ "mrope_interleaved": true,
109
+ "mrope_section": [
110
+ 11,
111
+ 11,
112
+ 10
113
+ ],
114
+ "partial_rotary_factor": 0.25,
115
+ "rope_theta": 10000000,
116
+ "rope_type": "default"
117
+ },
118
+ "tie_word_embeddings": false,
119
+ "use_cache": false,
120
+ "vocab_size": 248320
121
+ },
122
+ "tie_word_embeddings": false,
123
+ "unsloth_version": "2026.8.18",
124
+ "video_token_id": 248057,
125
+ "vision_config": {
126
+ "deepstack_visual_indexes": [],
127
+ "depth": 27,
128
+ "torch_dtype": "bfloat16",
129
+ "hidden_act": "gelu_pytorch_tanh",
130
+ "hidden_size": 1152,
131
+ "in_channels": 3,
132
+ "initializer_range": 0.02,
133
+ "intermediate_size": 4304,
134
+ "model_type": "qwen3_5",
135
+ "num_heads": 16,
136
+ "num_position_embeddings": 2304,
137
+ "out_hidden_size": 5120,
138
+ "patch_size": 16,
139
+ "spatial_merge_size": 2,
140
+ "temporal_patch_size": 2
141
+ },
142
+ "vision_end_token_id": 248054,
143
+ "vision_start_token_id": 248053
144
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 248046,
6
+ 248044
7
+ ],
8
+ "pad_token_id": 248044,
9
+ "temperature": 1.0,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.5.0"
13
+ }
model-00001-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e3b451e51a96e2685cf3be6463a1c87749a75c20f31e1c669a9b12a5dd869df
3
+ size 3966730552
model-00002-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:942be2c3309ea0a8fdecc21fb6dfccf32bd2284ac0e852fce6299e9c9a07280d
3
+ size 3043080328
model-00003-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e1bf62cbcd406eaa64b60d10353e1f0ef4039d0976e56f05cabe953454f9968
3
+ size 2542796952
model-00004-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca54a322cd1c1c726cab4cf7492ff4e04ec4e8bba3957cd2d535d510a952f83e
3
+ size 3988973152
model-00005-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:933aaf442cc8d919fef3237e8ad22f72bd42fb088b203d6db2cd831cb3080307
3
+ size 2099339864
model-00006-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ccbb1595208f8afd8c1196e9300542e137be1438b5aad651ffbabde2bb46c43
3
+ size 3979553696
model-00007-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8942dba1f0e4f01f1d577ac937f048c424a356cf870f5ddc770f7d622501a2f5
3
+ size 2108759344
model-00008-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3e73cbb7120f256f13e39d26e25c75b3ac09af00ca20bfc68a327aa3d1ccce6
3
+ size 3979553696
model-00009-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98414820ad38032b1a2fc75aab777e45e3f0e8cf6990e9f09cdd8196778d5907
3
+ size 2108759344
model-00010-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11647a96a1a521694befc5305326e8c33cbf3233fcc7940f5da163f33147e148
3
+ size 3979553696
model-00011-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bba99ab93924166e385d3596705c1adc689dc9ca806c842392d9ec0bfe7f9559
3
+ size 2108759344
model-00012-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c9152a08d3fb54489da0afeea69acd897393a21fcb6ff387ad59a6d7bb83a9b
3
+ size 3979553696
model-00013-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d4288453a8abb301fd6b14328bbd7f3345e3a337b0ebf590693d27dacc8892a
3
+ size 2108759344
model-00014-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3deede5a76d14992ef997d9f4949726598c8d83a9d0b5d5e4410d2c7b106e7c3
3
+ size 3979553696
model-00015-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96524130aa3f595b459dbc12add942b6bd8bc0b4b2e1124e465d7228ba094d35
3
+ size 2108759344
model-00016-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:461b1bca474bf14f9ec5a7a9d8ce081bceb8be47a57403ead36c17e28054461f
3
+ size 3979564040
model-00017-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be67d3d098180a1bfe2f45669a63fd4cf3a51b30060f6e631bf3e6b71ec299cd
3
+ size 2108759344
model-00018-of-00018.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d3479509e21494658f9b64d317f5ea8e55c4025d28c702d6c4d0b356ce8ea06
3
+ size 3392197344
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
3
+ size 19989343
tokenizer_config.json ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": false,
13
+ "model_max_length": 262144,
14
+ "model_specific_special_tokens": {
15
+ "audio_bos_token": "<|audio_start|>",
16
+ "audio_eos_token": "<|audio_end|>",
17
+ "audio_token": "<|audio_pad|>",
18
+ "image_token": "<|image_pad|>",
19
+ "video_token": "<|video_pad|>",
20
+ "vision_bos_token": "<|vision_start|>",
21
+ "vision_eos_token": "<|vision_end|>"
22
+ },
23
+ "pad_token": "<|endoftext|>",
24
+ "padding_side": "left",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "TokenizersBackend",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>",
33
+ "added_tokens_decoder": {
34
+ "248044": {
35
+ "content": "<|endoftext|>",
36
+ "single_word": false,
37
+ "lstrip": false,
38
+ "rstrip": false,
39
+ "normalized": false,
40
+ "special": true
41
+ },
42
+ "248045": {
43
+ "content": "<|im_start|>",
44
+ "single_word": false,
45
+ "lstrip": false,
46
+ "rstrip": false,
47
+ "normalized": false,
48
+ "special": true
49
+ },
50
+ "248046": {
51
+ "content": "<|im_end|>",
52
+ "single_word": false,
53
+ "lstrip": false,
54
+ "rstrip": false,
55
+ "normalized": false,
56
+ "special": true
57
+ },
58
+ "248047": {
59
+ "content": "<|object_ref_start|>",
60
+ "single_word": false,
61
+ "lstrip": false,
62
+ "rstrip": false,
63
+ "normalized": false,
64
+ "special": true
65
+ },
66
+ "248048": {
67
+ "content": "<|object_ref_end|>",
68
+ "single_word": false,
69
+ "lstrip": false,
70
+ "rstrip": false,
71
+ "normalized": false,
72
+ "special": true
73
+ },
74
+ "248049": {
75
+ "content": "<|box_start|>",
76
+ "single_word": false,
77
+ "lstrip": false,
78
+ "rstrip": false,
79
+ "normalized": false,
80
+ "special": true
81
+ },
82
+ "248050": {
83
+ "content": "<|box_end|>",
84
+ "single_word": false,
85
+ "lstrip": false,
86
+ "rstrip": false,
87
+ "normalized": false,
88
+ "special": true
89
+ },
90
+ "248051": {
91
+ "content": "<|quad_start|>",
92
+ "single_word": false,
93
+ "lstrip": false,
94
+ "rstrip": false,
95
+ "normalized": false,
96
+ "special": true
97
+ },
98
+ "248052": {
99
+ "content": "<|quad_end|>",
100
+ "single_word": false,
101
+ "lstrip": false,
102
+ "rstrip": false,
103
+ "normalized": false,
104
+ "special": true
105
+ },
106
+ "248053": {
107
+ "content": "<|vision_start|>",
108
+ "single_word": false,
109
+ "lstrip": false,
110
+ "rstrip": false,
111
+ "normalized": false,
112
+ "special": true
113
+ },
114
+ "248054": {
115
+ "content": "<|vision_end|>",
116
+ "single_word": false,
117
+ "lstrip": false,
118
+ "rstrip": false,
119
+ "normalized": false,
120
+ "special": true
121
+ },
122
+ "248055": {
123
+ "content": "<|vision_pad|>",
124
+ "single_word": false,
125
+ "lstrip": false,
126
+ "rstrip": false,
127
+ "normalized": false,
128
+ "special": true
129
+ },
130
+ "248056": {
131
+ "content": "<|image_pad|>",
132
+ "single_word": false,
133
+ "lstrip": false,
134
+ "rstrip": false,
135
+ "normalized": false,
136
+ "special": true
137
+ },
138
+ "248057": {
139
+ "content": "<|video_pad|>",
140
+ "single_word": false,
141
+ "lstrip": false,
142
+ "rstrip": false,
143
+ "normalized": false,
144
+ "special": true
145
+ },
146
+ "248058": {
147
+ "content": "<tool_call>",
148
+ "single_word": false,
149
+ "lstrip": false,
150
+ "rstrip": false,
151
+ "normalized": false,
152
+ "special": false
153
+ },
154
+ "248059": {
155
+ "content": "</tool_call>",
156
+ "single_word": false,
157
+ "lstrip": false,
158
+ "rstrip": false,
159
+ "normalized": false,
160
+ "special": false
161
+ },
162
+ "248060": {
163
+ "content": "<|fim_prefix|>",
164
+ "single_word": false,
165
+ "lstrip": false,
166
+ "rstrip": false,
167
+ "normalized": false,
168
+ "special": false
169
+ },
170
+ "248061": {
171
+ "content": "<|fim_middle|>",
172
+ "single_word": false,
173
+ "lstrip": false,
174
+ "rstrip": false,
175
+ "normalized": false,
176
+ "special": false
177
+ },
178
+ "248062": {
179
+ "content": "<|fim_suffix|>",
180
+ "single_word": false,
181
+ "lstrip": false,
182
+ "rstrip": false,
183
+ "normalized": false,
184
+ "special": false
185
+ },
186
+ "248063": {
187
+ "content": "<|fim_pad|>",
188
+ "single_word": false,
189
+ "lstrip": false,
190
+ "rstrip": false,
191
+ "normalized": false,
192
+ "special": false
193
+ },
194
+ "248064": {
195
+ "content": "<|repo_name|>",
196
+ "single_word": false,
197
+ "lstrip": false,
198
+ "rstrip": false,
199
+ "normalized": false,
200
+ "special": false
201
+ },
202
+ "248065": {
203
+ "content": "<|file_sep|>",
204
+ "single_word": false,
205
+ "lstrip": false,
206
+ "rstrip": false,
207
+ "normalized": false,
208
+ "special": false
209
+ },
210
+ "248066": {
211
+ "content": "<tool_response>",
212
+ "single_word": false,
213
+ "lstrip": false,
214
+ "rstrip": false,
215
+ "normalized": false,
216
+ "special": false
217
+ },
218
+ "248067": {
219
+ "content": "</tool_response>",
220
+ "single_word": false,
221
+ "lstrip": false,
222
+ "rstrip": false,
223
+ "normalized": false,
224
+ "special": false
225
+ },
226
+ "248068": {
227
+ "content": "<think>",
228
+ "single_word": false,
229
+ "lstrip": false,
230
+ "rstrip": false,
231
+ "normalized": false,
232
+ "special": false
233
+ },
234
+ "248069": {
235
+ "content": "</think>",
236
+ "single_word": false,
237
+ "lstrip": false,
238
+ "rstrip": false,
239
+ "normalized": false,
240
+ "special": false
241
+ },
242
+ "248070": {
243
+ "content": "<|audio_start|>",
244
+ "single_word": false,
245
+ "lstrip": false,
246
+ "rstrip": false,
247
+ "normalized": false,
248
+ "special": true
249
+ },
250
+ "248071": {
251
+ "content": "<|audio_end|>",
252
+ "single_word": false,
253
+ "lstrip": false,
254
+ "rstrip": false,
255
+ "normalized": false,
256
+ "special": true
257
+ },
258
+ "248072": {
259
+ "content": "<tts_pad>",
260
+ "single_word": false,
261
+ "lstrip": false,
262
+ "rstrip": false,
263
+ "normalized": false,
264
+ "special": true
265
+ },
266
+ "248073": {
267
+ "content": "<tts_text_bos>",
268
+ "single_word": false,
269
+ "lstrip": false,
270
+ "rstrip": false,
271
+ "normalized": false,
272
+ "special": true
273
+ },
274
+ "248074": {
275
+ "content": "<tts_text_eod>",
276
+ "single_word": false,
277
+ "lstrip": false,
278
+ "rstrip": false,
279
+ "normalized": false,
280
+ "special": true
281
+ },
282
+ "248075": {
283
+ "content": "<tts_text_bos_single>",
284
+ "single_word": false,
285
+ "lstrip": false,
286
+ "rstrip": false,
287
+ "normalized": false,
288
+ "special": true
289
+ },
290
+ "248076": {
291
+ "content": "<|audio_pad|>",
292
+ "single_word": false,
293
+ "lstrip": false,
294
+ "rstrip": false,
295
+ "normalized": false,
296
+ "special": true
297
+ }
298
+ },
299
+ "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set sysns = namespace(count=0, text='') %}\n{%- for message in messages %}\n {%- if sysns.count == loop.index0 and (message.role == 'system' or message.role == 'developer') %}\n {%- set sys_content = render_content(message.content, false, true)|trim %}\n {%- if sys_content %}\n {%- set sysns.text = sysns.text + ('\\n' if sysns.text else '') + sys_content %}\n {%- endif %}\n {%- set sysns.count = sysns.count + 1 %}\n {%- endif %}\n{%- endfor %}\n{%- set num_sys = sysns.count %}\n{%- set merged_system = sysns.text %}\n{%- set reasoning_instructions = '' %}\n{%- if enable_thinking is undefined or enable_thinking is true %}\n {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}\n {%- if resolved_reasoning_effort == 'high' %}\n {%- set resolved_reasoning_effort = 'xhigh' %}\n {%- endif %}\n {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}\n {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}\n {%- endif %}\n {%- if resolved_reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif resolved_reasoning_effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if merged_system %}\n {{- '\\n\\n' + merged_system }}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if merged_system %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + merged_system + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if loop.index0 >= num_sys %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" or message.role == \"developer\" %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\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 {%- if tool_call.name is not defined or tool_call.name is none %}\n {{- raise_exception('Tool call is missing a function name.') }}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is mapping %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- elif tool_call.arguments is string %}\n {%- if tool_call.arguments|trim %}\n {{- raise_exception('Tool call arguments for function \"' + (tool_call.name | string) + '\" were passed as a JSON string. Parse them into an object before calling apply_chat_template.') }}\n {%- endif %}\n {%- elif tool_call.arguments is defined and tool_call.arguments is not none %}\n {{- raise_exception('Tool call arguments for function \"' + (tool_call.name | string) + '\" must be an object/mapping or a JSON string.') }}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}\n{#- Unsloth fixes - developer role, merged system messages, tool calling #}"
300
+ }