Colby commited on
Commit
2eedbe0
·
verified ·
1 Parent(s): 7c03134

Training in progress, step 100

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,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: swiss-ai/Apertus-8B-Instruct-2509
3
+ library_name: transformers
4
+ model_name: apertus-8b-coding
5
+ tags:
6
+ - generated_from_trainer
7
+ - hf_jobs
8
+ - sft
9
+ - trl
10
+ licence: license
11
+ ---
12
+
13
+ # Model Card for apertus-8b-coding
14
+
15
+ This model is a fine-tuned version of [swiss-ai/Apertus-8B-Instruct-2509](https://huggingface.co/swiss-ai/Apertus-8B-Instruct-2509).
16
+ It has been trained using [TRL](https://github.com/huggingface/trl).
17
+
18
+ ## Quick start
19
+
20
+ ```python
21
+ from transformers import pipeline
22
+
23
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
24
+ generator = pipeline("text-generation", model="Colby/apertus-8b-coding", device="cuda")
25
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
26
+ print(output["generated_text"])
27
+ ```
28
+
29
+ ## Training procedure
30
+
31
+
32
+
33
+
34
+
35
+ This model was trained with SFT.
36
+
37
+ ### Framework versions
38
+
39
+ - TRL: 1.4.0
40
+ - Transformers: 5.8.0
41
+ - Pytorch: 2.11.0
42
+ - Datasets: 4.8.5
43
+ - Tokenizers: 0.22.2
44
+
45
+ ## Citations
46
+
47
+
48
+
49
+ Cite TRL as:
50
+
51
+ ```bibtex
52
+ @software{vonwerra2020trl,
53
+ title = {{TRL: Transformers Reinforcement Learning}},
54
+ author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
55
+ license = {Apache-2.0},
56
+ url = {https://github.com/huggingface/trl},
57
+ year = {2020}
58
+ }
59
+ ```
adapter_config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "swiss-ai/Apertus-8B-Instruct-2509",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 32,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.05,
22
+ "lora_ga_config": null,
23
+ "megatron_config": null,
24
+ "megatron_core": "megatron.core",
25
+ "modules_to_save": null,
26
+ "peft_type": "LORA",
27
+ "peft_version": "0.19.1",
28
+ "qalora_group_size": 16,
29
+ "r": 16,
30
+ "rank_pattern": {},
31
+ "revision": null,
32
+ "target_modules": [
33
+ "o_proj",
34
+ "down_proj",
35
+ "up_proj",
36
+ "k_proj",
37
+ "q_proj",
38
+ "v_proj"
39
+ ],
40
+ "target_parameters": null,
41
+ "task_type": "CAUSAL_LM",
42
+ "trainable_token_indices": null,
43
+ "use_bdlora": null,
44
+ "use_dora": false,
45
+ "use_qalora": false,
46
+ "use_rslora": false
47
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:480e454a9e4359d40506048a2374c9089f0be48c84a72dcc40257150a087f546
3
+ size 79743368
chat_template.jinja ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
2
+ {%- if param_spec.type == "array" -%}
3
+ {%- if param_spec['items'] -%}
4
+ {%- if param_spec['items']['type'] == "string" -%}
5
+ {{- "string[]" }}
6
+ {%- elif param_spec['items']['type'] == "number" -%}
7
+ {{- "number[]" }}
8
+ {%- elif param_spec['items']['type'] == "integer" -%}
9
+ {{- "number[]" }}
10
+ {%- elif param_spec['items']['type'] == "boolean" -%}
11
+ {{- "boolean[]" }}
12
+ {%- else -%}
13
+ {%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%}
14
+ {%- if inner_type == "object | object" or inner_type|length > 50 -%}
15
+ {{- "any[]" }}
16
+ {%- else -%}
17
+ {{- inner_type + "[]" }}
18
+ {%- endif -%}
19
+ {%- endif -%}
20
+ {%- if param_spec.nullable -%}
21
+ {{- " | null" }}
22
+ {%- endif -%}
23
+ {%- else -%}
24
+ {{- "any[]" }}
25
+ {%- if param_spec.nullable -%}
26
+ {{- " | null" }}
27
+ {%- endif -%}
28
+ {%- endif -%}
29
+ {%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%}
30
+ {#- Handle array of types like ["object", "object"] from Union[dict, list] #}
31
+ {%- if param_spec.type | length > 1 -%}
32
+ {{- param_spec.type | join(" | ") }}
33
+ {%- else -%}
34
+ {{- param_spec.type[0] }}
35
+ {%- endif -%}
36
+ {%- elif param_spec.oneOf -%}
37
+ {#- Handle oneOf schemas - check for complex unions and fallback to any #}
38
+ {%- set has_object_variants = false -%}
39
+ {%- for variant in param_spec.oneOf -%}
40
+ {%- if variant.type == "object" -%}
41
+ {%- set has_object_variants = true -%}
42
+ {%- endif -%}
43
+ {%- endfor -%}
44
+ {%- if has_object_variants and param_spec.oneOf|length > 1 -%}
45
+ {{- "any" }}
46
+ {%- else -%}
47
+ {%- for variant in param_spec.oneOf -%}
48
+ {{- render_typescript_type(variant, required_params) -}}
49
+ {%- if variant.description %}
50
+ {{- "// " + variant.description }}
51
+ {%- endif -%}
52
+ {%- if variant.default is defined %}
53
+ {{ "// default: " + variant.default|tojson }}
54
+ {%- endif -%}
55
+ {%- if not loop.last %}
56
+ {{- " | " }}
57
+ {% endif -%}
58
+ {%- endfor -%}
59
+ {%- endif -%}
60
+ {%- elif param_spec.type == "string" -%}
61
+ {%- if param_spec.enum -%}
62
+ {{- '"' + param_spec.enum|join('" | "') + '"' -}}
63
+ {%- else -%}
64
+ {{- "string" }}
65
+ {%- if param_spec.nullable %}
66
+ {{- " | null" }}
67
+ {%- endif -%}
68
+ {%- endif -%}
69
+ {%- elif param_spec.type == "number" -%}
70
+ {{- "number" }}
71
+ {%- elif param_spec.type == "integer" -%}
72
+ {{- "number" }}
73
+ {%- elif param_spec.type == "boolean" -%}
74
+ {{- "boolean" }}
75
+ {%- elif param_spec.type == "object" -%}
76
+ {%- if param_spec.properties -%}
77
+ {{- "{\n" }}
78
+ {%- for prop_name, prop_spec in param_spec.properties.items() -%}
79
+ {{- prop_name -}}
80
+ {%- if prop_name not in (param_spec.required or []) -%}
81
+ {{- "?" }}
82
+ {%- endif -%}
83
+ {{- ": " }}
84
+ {{ render_typescript_type(prop_spec, param_spec.required or []) }}
85
+ {%- if not loop.last -%}
86
+ {{-", " }}
87
+ {%- endif -%}
88
+ {%- endfor -%}
89
+ {{- "}" }}
90
+ {%- else -%}
91
+ {{- "object" }}
92
+ {%- endif -%}
93
+ {%- else -%}
94
+ {{- "any" }}
95
+ {%- endif -%}
96
+ {%- endmacro -%}
97
+
98
+ {%- macro render_tools(tools) -%}
99
+ {%- for tool in tools %}
100
+ {{- "// " + tool.description + "\n" }}
101
+ {{- "type "+ tool.name + " = " }}
102
+ {%- if tool.parameters and tool.parameters.properties %}
103
+ {{- "(_: {\n" }}
104
+ {%- for param_name, param_spec in tool.parameters.properties.items() %}
105
+ {%- if param_spec.description %}
106
+ {{- "// " + param_spec.description + "\n" }}
107
+ {%- endif %}
108
+ {{- param_name }}
109
+ {%- if param_name not in (tool.parameters.required or []) -%}
110
+ {{- "?" }}
111
+ {%- endif -%}
112
+ {{- ": " }}
113
+ {{- render_typescript_type(param_spec, tool.parameters.required or []) }}
114
+ {%- if param_spec.default is defined -%}
115
+ {%- if param_spec.enum %}
116
+ {{- ", // default: " + param_spec.default }}
117
+ {%- elif param_spec.oneOf %}
118
+ {{- "// default: " + param_spec.default }}
119
+ {%- else %}
120
+ {{- ", // default: " + param_spec.default|tojson }}
121
+ {%- endif -%}
122
+ {%- endif -%}
123
+ {%- if not loop.last %}
124
+ {{- ",\n" }}
125
+ {%- else %}
126
+ {{- "\n" }}
127
+ {%- endif -%}
128
+ {%- endfor %}
129
+ {{- "}) => any;" }}
130
+ {%- else -%}
131
+ {{- "() => any;" }}
132
+ {%- endif -%}
133
+ {%- if not loop.last -%}
134
+ {{- "\n" }}
135
+ {%- endif -%}
136
+ {%- endfor %}
137
+ {%- endmacro -%}
138
+
139
+ {{ bos_token }}
140
+
141
+ {%- set system_token = '<|system_start|>' -%}
142
+ {%- set end_system_token = '<|system_end|>' -%}
143
+ {%- set developer_token = '<|developer_start|>' -%}
144
+ {%- set end_developer_token = '<|developer_end|>' -%}
145
+ {%- set user_token = '<|user_start|>' -%}
146
+ {%- set end_user_token = '<|user_end|>' -%}
147
+ {%- set assistant_token = '<|assistant_start|>' -%}
148
+ {%- set end_assistant_token = '<|assistant_end|>' -%}
149
+ {%- set inner_token = '<|inner_prefix|>' -%}
150
+ {%- set outer_token = '<|inner_suffix|>' -%}
151
+ {%- set tool_calls_token = '<|tools_prefix|>' -%}
152
+ {%- set end_tool_calls_token = '<|tools_suffix|>' -%}
153
+ {%- set image_token = '<|image|>' -%}
154
+
155
+ {%- set ns = namespace(in_assistant=false, in_tool=false, in_inner=false, waiting_for_tool_outputs=false, assistant_format=none) -%}
156
+
157
+ {%- if messages and messages[0].role == 'system' -%}
158
+ {%- if "content" in messages[0] -%}
159
+ {%- if messages[0].content is string -%}
160
+ {{ system_token + messages[0].content + end_system_token }}
161
+ {%- elif messages[0].content is mapping and "text" in messages[0].content -%}
162
+ {{ system_token + messages[0].content.text + end_system_token }}
163
+ {%- else -%}
164
+ {{- raise_exception("Invalid system message") -}}
165
+ {%- endif -%}
166
+ {%- else -%}
167
+ {{- raise_exception("Invalid system message") -}}
168
+ {%- endif -%}
169
+ {%- set loop_messages = messages[1:] -%}
170
+ {%- else -%}
171
+ {{ system_token + 'You are Apertus, a helpful assistant created by the SwissAI initiative.\nKnowledge cutoff: 2024-04\nCurrent date: ' + strftime_now('%Y-%m-%d') + end_system_token }}
172
+ {%- set loop_messages = messages -%}
173
+ {%- endif -%}
174
+
175
+ {{ developer_token + 'Deliberation: ' }}
176
+ {%- if enable_thinking is defined and enable_thinking -%}
177
+ {{ 'enabled\n' }}
178
+ {%- else -%}
179
+ {{ 'disabled\n' }}
180
+ {%- endif -%}
181
+ {%- if tools is defined and tools -%}
182
+ {{ 'Tool Capabilities:\n' + render_tools(tools) }}
183
+ {%- else -%}
184
+ {{ 'Tool Capabilities: disabled' }}
185
+ {%- endif -%}
186
+ {{ end_developer_token }}
187
+
188
+ {%- for message in loop_messages -%}
189
+ {%- if message.role == 'user' -%}
190
+ {%- set ns.in_inner = false -%}
191
+ {%- if ns.in_tool -%}
192
+ {{ ']' }}
193
+ {%- set ns.in_tool = false -%}
194
+ {%- endif -%}
195
+ {%- if ns.in_assistant -%}
196
+ {{ end_assistant_token }}
197
+ {%- set ns.in_assistant = false -%}
198
+ {%- endif -%}
199
+ {%- if "content" in message -%}
200
+ {{ user_token }}
201
+ {%- if message.content is string -%}
202
+ {{ message.content }}
203
+ {%- elif message.content is mapping and "parts" in message.content -%}
204
+ {%- set parts = message.content.parts -%}
205
+ {%- for part in parts -%}
206
+ {%- if part.type == "text" -%}
207
+ {{ part.text }}
208
+ {%- elif part.type == "image" -%}
209
+ {{ image_token }}
210
+ {%- else -%}
211
+ {{- raise_exception("Invalid user part: " + part.type) -}}
212
+ {%- endif -%}
213
+ {%- endfor -%}
214
+ {%- else -%}
215
+ {{- raise_exception("Invalid user message: " + message.role) -}}
216
+ {%- endif -%}
217
+ {{ end_user_token }}
218
+ {%- endif -%}
219
+ {%- elif message.role == 'assistant' -%}
220
+ {%- if not ns.in_assistant -%}
221
+ {{ assistant_token }}
222
+ {%- set ns.in_assistant = true -%}
223
+ {%- endif -%}
224
+ {%- if "content" in message -%}
225
+ {%- if message.content is string and (ns.assistant_format is none or ns.assistant_format == "string") -%}
226
+ {%- if ns.in_tool -%}
227
+ {{ ']' }}
228
+ {%- set ns.in_tool = false -%}
229
+ {%- endif -%}
230
+ {%- set ns.assistant_format = "string" -%}
231
+ {{ message.content }}
232
+ {%- elif message.content is mapping and "blocks" in message.content and (ns.assistant_format is none or ns.assistant_format == "mapping") -%}
233
+ {%- set ns.assistant_format = "mapping" -%}
234
+ {%- set blocks = message.content.blocks -%}
235
+ {%- for block in blocks -%}
236
+ {%- if block.type == 'thoughts' -%}
237
+ {%- if ns.in_tool -%}
238
+ {{ ']' }}
239
+ {%- set ns.in_tool = false -%}
240
+ {%- endif -%}
241
+ {%- if not ns.in_inner -%}
242
+ {%- set ns.in_inner = true -%}
243
+ {{ inner_token }}
244
+ {%- endif -%}
245
+ {{ block.text }}
246
+ {%- elif block.type == 'tool_calls' -%}
247
+ {%- if ns.in_tool -%}
248
+ {{ ']' }}
249
+ {%- set ns.in_tool = false -%}
250
+ {%- endif -%}
251
+ {%- if ns.in_inner and not loop.first and block.calls|length == 1 and block.calls[0].name == 'display_answers' -%}
252
+ {%- set ns.in_inner = false -%}
253
+ {{ outer_token }}
254
+ {%- endif -%}
255
+ {{ tool_calls_token + '[' }}
256
+ {%- for tool_call in block.calls -%}
257
+ {{- '{"' + tool_call.name + '": ' + tool_call.arguments + '}' }}
258
+ {%- if not loop.last -%}
259
+ {{- ", " }}
260
+ {%- endif -%}
261
+ {%- endfor -%}
262
+ {{ ']' + end_tool_calls_token }}
263
+ {%- set ns.waiting_for_tool_outputs = true -%}
264
+ {%- elif block.type == 'tool_outputs' -%}
265
+ {%- if ns.in_tool -%}
266
+ {{- raise_exception("Cannot have both tool outputs as separate messages and tool outputs as blocks") -}}
267
+ {%- endif -%}
268
+ {{ '[' }}
269
+ {%- for tool_output in block.outputs -%}
270
+ {{- tool_output.output }}
271
+ {%- if not loop.last -%}
272
+ {{- ", " }}
273
+ {%- endif -%}
274
+ {%- endfor -%}
275
+ {{- ']' }}
276
+ {%- set ns.waiting_for_tool_outputs = false -%}
277
+ {%- elif block.type == 'response' -%}
278
+ {%- if ns.in_tool -%}
279
+ {{ ']' }}
280
+ {%- set ns.in_tool = false -%}
281
+ {%- endif -%}
282
+ {%- if (not loop.first and ns.in_inner) or (ns.in_assistant and ns.in_inner) -%}
283
+ {%- set ns.in_inner = false -%}
284
+ {{ outer_token }}
285
+ {%- endif -%}
286
+ {{ block.text }}
287
+ {%- else -%}
288
+ {{- raise_exception("Invalid assistant block type: " + block.type) -}}
289
+ {%- endif -%}
290
+ {%- endfor -%}
291
+ {%- else -%}
292
+ {{- raise_exception("Invalid assistant content") -}}
293
+ {%- endif -%}
294
+ {%- else -%}
295
+ {{- raise_exception("Invalid assistant message") -}}
296
+ {%- endif -%}
297
+ {%- if "tool_calls" in message and message.tool_calls -%}
298
+ {{ tool_calls_token + '[' }}
299
+ {%- for tool_call in message.tool_calls -%}
300
+ {%- if tool_call.type == 'function' -%}
301
+ {%- set function = tool_call.function -%}
302
+ {{- '{"' + function.name + '": ' + function.arguments + '}' }}
303
+ {%- if not loop.last -%}
304
+ {{- ", " }}
305
+ {%- endif -%}
306
+ {%- else -%}
307
+ {{- raise_exception("Invalid tool call type: " + tool_call.type) -}}
308
+ {%- endif -%}
309
+ {%- endfor -%}
310
+ {{ ']' + end_tool_calls_token }}
311
+ {%- set ns.waiting_for_tool_outputs = true -%}
312
+ {%- endif -%}
313
+ {%- elif message.role == 'tool' -%}
314
+ {%- if not ns.in_assistant -%}
315
+ {{- raise_exception("Tool message outside of assistant") -}}
316
+ {%- endif -%}
317
+ {%- if not ns.in_tool -%}
318
+ {{ '[' }}
319
+ {%- set ns.in_tool = true -%}
320
+ {%- else -%}
321
+ {{ ", "}}
322
+ {%- endif -%}
323
+ {{ message.content }}
324
+ {%- set ns.waiting_for_tool_outputs = false -%}
325
+ {%- else -%}
326
+ {{- raise_exception("Invalid message role") -}}
327
+ {%- endif -%}
328
+ {%- endfor -%}
329
+ {%- if ns.in_tool -%}
330
+ {{ ']' }}
331
+ {%- endif -%}
332
+ {%- if ns.in_assistant and not (continue_assistant_message is defined and continue_assistant_message) and not ns.waiting_for_tool_outputs -%}
333
+ {{ end_assistant_token }}
334
+ {%- endif -%}
335
+ {%- if add_generation_prompt -%}
336
+ {{ assistant_token }}
337
+ {%- endif -%}
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:010095abf1dc6f52d4867584e7b3f0d4eece854593ae310220ec7782dd1b0a66
3
+ size 17078474
tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|assistant_end|>",
7
+ "is_local": false,
8
+ "local_files_only": false,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 1000000000000000019884624838656,
14
+ "pad_token": "<pad>",
15
+ "padding_side": "left",
16
+ "tokenizer_class": "TokenizersBackend",
17
+ "unk_token": "<unk>"
18
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f230a64cbc9ab0f91d8fdca49204b16492c3164617d23a4702ced85012cf8a4
3
+ size 5713