U4R
/

Safetensors
chimera
custom_code
Potentialts commited on
Commit
d76ca71
·
1 Parent(s): 5648e83

upload model weights

Browse files
added_tokens.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</box>": 92552,
3
+ "</domain>": 92554,
4
+ "</img>": 92545,
5
+ "</quad>": 92548,
6
+ "</ref>": 92550,
7
+ "<DOMAIN_0_CONTEXT>": 92555,
8
+ "<DOMAIN_1_CONTEXT>": 92556,
9
+ "<DOMAIN_2_CONTEXT>": 92557,
10
+ "<IMG_CONTEXT>": 92546,
11
+ "<box>": 92551,
12
+ "<domain>": 92553,
13
+ "<img>": 92544,
14
+ "<quad>": 92547,
15
+ "<ref>": 92549
16
+ }
config.json ADDED
@@ -0,0 +1,528 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_commit_hash": null,
3
+ "_name_or_path": "/mnt/workspace/Chimera/checkpoints/solva-reasoner-8B",
4
+ "architectures": [
5
+ "ChimeraChatModel"
6
+ ],
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_chimera.ChimeraChatConfig",
9
+ "AutoModel": "modeling_chimera.ChimeraChatModel",
10
+ "AutoModelForCausalLM": "modeling_chimera.ChimeraChatModel"
11
+ },
12
+ "downsample_ratio": 0.5,
13
+ "dynamic_image_size": true,
14
+ "expert_encoder_config": {
15
+ "_attn_implementation_internal": null,
16
+ "_commit_hash": null,
17
+ "_name_or_path": "",
18
+ "add_cross_attention": false,
19
+ "architectures": null,
20
+ "bad_words_ids": null,
21
+ "begin_suppress_tokens": null,
22
+ "bos_token_id": null,
23
+ "chunk_size_feed_forward": 0,
24
+ "config_list": [
25
+ {
26
+ "config": {
27
+ "_name_or_path": "/cpfs01/shared/ADLab/datasets/science_dataset/solva_modules/table_kosmos",
28
+ "add_cross_attention": false,
29
+ "architectures": [
30
+ "Kosmos2_5VisionModel"
31
+ ],
32
+ "attention_dropout": 0.0,
33
+ "bad_words_ids": null,
34
+ "begin_suppress_tokens": null,
35
+ "bos_token_id": null,
36
+ "chunk_size_feed_forward": 0,
37
+ "cross_attention_hidden_size": null,
38
+ "d_ff": 3968,
39
+ "d_kv": 64,
40
+ "decoder_start_token_id": null,
41
+ "dense_act_fn": "gelu_new",
42
+ "diversity_penalty": 0.0,
43
+ "do_sample": false,
44
+ "dropout_rate": 0.0,
45
+ "early_stopping": false,
46
+ "encoder_no_repeat_ngram_size": 0,
47
+ "eos_token_id": null,
48
+ "exponential_decay_length_penalty": null,
49
+ "finetuning_task": null,
50
+ "forced_bos_token_id": null,
51
+ "forced_eos_token_id": null,
52
+ "hidden_size": 1536,
53
+ "id2label": {
54
+ "0": "LABEL_0",
55
+ "1": "LABEL_1"
56
+ },
57
+ "initializer_factor": 1.0,
58
+ "initializer_range": 1e-10,
59
+ "is_decoder": false,
60
+ "is_encoder_decoder": false,
61
+ "label2id": {
62
+ "LABEL_0": 0,
63
+ "LABEL_1": 1
64
+ },
65
+ "layer_norm_eps": 1e-06,
66
+ "length_penalty": 1.0,
67
+ "max_length": 4096,
68
+ "min_length": 0,
69
+ "model_type": "kosmos_2_5_vision_model",
70
+ "no_repeat_ngram_size": 0,
71
+ "num_attention_heads": 24,
72
+ "num_beam_groups": 1,
73
+ "num_beams": 1,
74
+ "num_hidden_layers": 18,
75
+ "num_return_sequences": 1,
76
+ "output_attentions": false,
77
+ "output_hidden_states": false,
78
+ "output_scores": false,
79
+ "pad_token_id": null,
80
+ "patch_embed_hidden_size": 768,
81
+ "prefix": null,
82
+ "problem_type": null,
83
+ "pruned_heads": {},
84
+ "remove_invalid_values": false,
85
+ "repetition_penalty": 1.0,
86
+ "return_dict": true,
87
+ "return_dict_in_generate": false,
88
+ "sep_token_id": null,
89
+ "seq_len": 4096,
90
+ "suppress_tokens": null,
91
+ "task_specific_params": null,
92
+ "temperature": 1.0,
93
+ "tf_legacy_loss": false,
94
+ "tie_encoder_decoder": false,
95
+ "tie_word_embeddings": true,
96
+ "tokenizer_class": null,
97
+ "top_k": 50,
98
+ "top_p": 1.0,
99
+ "torch_dtype": "float32",
100
+ "torchscript": false,
101
+ "transformers_version": "4.44.2",
102
+ "typical_p": 1.0,
103
+ "use_bfloat16": false
104
+ },
105
+ "domain": "table",
106
+ "index": 0,
107
+ "select_layer": -1
108
+ },
109
+ {
110
+ "config": {
111
+ "_name_or_path": "/cpfs01/shared/ADLab/datasets/science_dataset/solva_modules/math_clip",
112
+ "add_cross_attention": false,
113
+ "architectures": null,
114
+ "attention_dropout": 0.0,
115
+ "bad_words_ids": null,
116
+ "begin_suppress_tokens": null,
117
+ "bos_token_id": null,
118
+ "chunk_size_feed_forward": 0,
119
+ "cross_attention_hidden_size": null,
120
+ "decoder_start_token_id": null,
121
+ "diversity_penalty": 0.0,
122
+ "do_sample": false,
123
+ "dropout": 0.0,
124
+ "early_stopping": false,
125
+ "encoder_no_repeat_ngram_size": 0,
126
+ "eos_token_id": null,
127
+ "exponential_decay_length_penalty": null,
128
+ "finetuning_task": null,
129
+ "forced_bos_token_id": null,
130
+ "forced_eos_token_id": null,
131
+ "hidden_act": "quick_gelu",
132
+ "hidden_size": 1024,
133
+ "id2label": {
134
+ "0": "LABEL_0",
135
+ "1": "LABEL_1"
136
+ },
137
+ "image_size": 336,
138
+ "initializer_factor": 1.0,
139
+ "initializer_range": 0.02,
140
+ "intermediate_size": 4096,
141
+ "is_decoder": false,
142
+ "is_encoder_decoder": false,
143
+ "label2id": {
144
+ "LABEL_0": 0,
145
+ "LABEL_1": 1
146
+ },
147
+ "layer_norm_eps": 1e-05,
148
+ "length_penalty": 1.0,
149
+ "max_length": 20,
150
+ "min_length": 0,
151
+ "model_type": "clip_vision_model",
152
+ "no_repeat_ngram_size": 0,
153
+ "num_attention_heads": 16,
154
+ "num_beam_groups": 1,
155
+ "num_beams": 1,
156
+ "num_channels": 3,
157
+ "num_hidden_layers": 24,
158
+ "num_return_sequences": 1,
159
+ "output_attentions": false,
160
+ "output_hidden_states": false,
161
+ "output_scores": false,
162
+ "pad_token_id": null,
163
+ "patch_size": 14,
164
+ "prefix": null,
165
+ "problem_type": null,
166
+ "projection_dim": 768,
167
+ "pruned_heads": {},
168
+ "remove_invalid_values": false,
169
+ "repetition_penalty": 1.0,
170
+ "return_dict": true,
171
+ "return_dict_in_generate": false,
172
+ "sep_token_id": null,
173
+ "suppress_tokens": null,
174
+ "task_specific_params": null,
175
+ "temperature": 1.0,
176
+ "tf_legacy_loss": false,
177
+ "tie_encoder_decoder": false,
178
+ "tie_word_embeddings": true,
179
+ "tokenizer_class": null,
180
+ "top_k": 50,
181
+ "top_p": 1.0,
182
+ "torch_dtype": null,
183
+ "torchscript": false,
184
+ "transformers_version": "4.44.2",
185
+ "typical_p": 1.0,
186
+ "use_bfloat16": false
187
+ },
188
+ "domain": "math",
189
+ "index": 1,
190
+ "select_layer": -2
191
+ },
192
+ {
193
+ "config": {
194
+ "_name_or_path": "/cpfs01/shared/ADLab/datasets/science_dataset/solva_modules/chart_p2s",
195
+ "add_cross_attention": false,
196
+ "architectures": [
197
+ "Pix2StructVisionModel"
198
+ ],
199
+ "attention_dropout": 0.0,
200
+ "bad_words_ids": null,
201
+ "begin_suppress_tokens": null,
202
+ "bos_token_id": null,
203
+ "chunk_size_feed_forward": 0,
204
+ "cross_attention_hidden_size": null,
205
+ "d_ff": 3968,
206
+ "d_kv": 64,
207
+ "decoder_start_token_id": null,
208
+ "dense_act_fn": "gelu_new",
209
+ "diversity_penalty": 0.0,
210
+ "do_sample": false,
211
+ "dropout_rate": 0.0,
212
+ "early_stopping": false,
213
+ "encoder_no_repeat_ngram_size": 0,
214
+ "eos_token_id": null,
215
+ "exponential_decay_length_penalty": null,
216
+ "finetuning_task": null,
217
+ "forced_bos_token_id": null,
218
+ "forced_eos_token_id": null,
219
+ "hidden_size": 1536,
220
+ "id2label": {
221
+ "0": "LABEL_0",
222
+ "1": "LABEL_1"
223
+ },
224
+ "initializer_factor": 1.0,
225
+ "initializer_range": 0.02,
226
+ "is_decoder": false,
227
+ "is_encoder_decoder": false,
228
+ "label2id": {
229
+ "LABEL_0": 0,
230
+ "LABEL_1": 1
231
+ },
232
+ "layer_norm_bias": false,
233
+ "layer_norm_eps": 1e-06,
234
+ "length_penalty": 1.0,
235
+ "max_length": 20,
236
+ "min_length": 0,
237
+ "model_type": "pix2struct_vision_model",
238
+ "no_repeat_ngram_size": 0,
239
+ "num_attention_heads": 24,
240
+ "num_beam_groups": 1,
241
+ "num_beams": 1,
242
+ "num_channels": 3,
243
+ "num_hidden_layers": 18,
244
+ "num_return_sequences": 1,
245
+ "output_attentions": false,
246
+ "output_hidden_states": false,
247
+ "output_scores": false,
248
+ "pad_token_id": null,
249
+ "patch_embed_hidden_size": 768,
250
+ "patch_size": 16,
251
+ "prefix": null,
252
+ "problem_type": null,
253
+ "projection_dim": 768,
254
+ "pruned_heads": {},
255
+ "relative_attention_max_distance": 128,
256
+ "relative_attention_num_buckets": 32,
257
+ "remove_invalid_values": false,
258
+ "repetition_penalty": 1.0,
259
+ "return_dict": true,
260
+ "return_dict_in_generate": false,
261
+ "sep_token_id": null,
262
+ "seq_len": 4096,
263
+ "suppress_tokens": null,
264
+ "task_specific_params": null,
265
+ "temperature": 1.0,
266
+ "tf_legacy_loss": false,
267
+ "tie_encoder_decoder": false,
268
+ "tie_word_embeddings": true,
269
+ "tokenizer_class": null,
270
+ "top_k": 50,
271
+ "top_p": 1.0,
272
+ "torch_dtype": "float32",
273
+ "torchscript": false,
274
+ "transformers_version": "4.44.2",
275
+ "typical_p": 1.0,
276
+ "use_bfloat16": false
277
+ },
278
+ "domain": "chart",
279
+ "index": 2,
280
+ "select_layer": -1
281
+ }
282
+ ],
283
+ "cross_attention_hidden_size": null,
284
+ "decoder_start_token_id": null,
285
+ "diversity_penalty": 0.0,
286
+ "do_sample": false,
287
+ "early_stopping": false,
288
+ "encoder_no_repeat_ngram_size": 0,
289
+ "eos_token_id": null,
290
+ "exponential_decay_length_penalty": null,
291
+ "finetuning_task": null,
292
+ "forced_bos_token_id": null,
293
+ "forced_eos_token_id": null,
294
+ "id2label": {
295
+ "0": "LABEL_0",
296
+ "1": "LABEL_1"
297
+ },
298
+ "is_decoder": false,
299
+ "is_encoder_decoder": false,
300
+ "label2id": {
301
+ "LABEL_0": 0,
302
+ "LABEL_1": 1
303
+ },
304
+ "length_penalty": 1.0,
305
+ "llm_hidden_size": 4096,
306
+ "max_length": 20,
307
+ "min_length": 0,
308
+ "no_repeat_ngram_size": 0,
309
+ "num_beam_groups": 1,
310
+ "num_beams": 1,
311
+ "num_encoder": 3,
312
+ "num_return_sequences": 1,
313
+ "output_attentions": false,
314
+ "output_hidden_states": false,
315
+ "output_scores": false,
316
+ "pad_token_id": null,
317
+ "prefix": null,
318
+ "problem_type": null,
319
+ "pruned_heads": {},
320
+ "remove_invalid_values": false,
321
+ "repetition_penalty": 1.0,
322
+ "return_dict": true,
323
+ "return_dict_in_generate": false,
324
+ "sep_token_id": null,
325
+ "separate_load": false,
326
+ "suppress_tokens": null,
327
+ "task_specific_params": null,
328
+ "temperature": 1.0,
329
+ "tf_legacy_loss": false,
330
+ "tie_encoder_decoder": false,
331
+ "tie_word_embeddings": true,
332
+ "tokenizer_class": null,
333
+ "top_k": 50,
334
+ "top_p": 1.0,
335
+ "torch_dtype": null,
336
+ "torchscript": false,
337
+ "transformers_version": null,
338
+ "typical_p": 1.0,
339
+ "use_bfloat16": false
340
+ },
341
+ "force_image_size": 448,
342
+ "llm_config": {
343
+ "_name_or_path": "internlm/internlm2_5-7b-chat",
344
+ "add_cross_attention": false,
345
+ "architectures": [
346
+ "InternLM2ForCausalLM"
347
+ ],
348
+ "attn_implementation": "flash_attention_2",
349
+ "auto_map": {
350
+ "AutoConfig": "configuration_internlm2.InternLM2Config",
351
+ "AutoModel": "modeling_internlm2.InternLM2ForCausalLM",
352
+ "AutoModelForCausalLM": "modeling_internlm2.InternLM2ForCausalLM"
353
+ },
354
+ "bad_words_ids": null,
355
+ "begin_suppress_tokens": null,
356
+ "bias": false,
357
+ "bos_token_id": 1,
358
+ "chunk_size_feed_forward": 0,
359
+ "cross_attention_hidden_size": null,
360
+ "decoder_start_token_id": null,
361
+ "diversity_penalty": 0.0,
362
+ "do_sample": false,
363
+ "early_stopping": false,
364
+ "encoder_no_repeat_ngram_size": 0,
365
+ "eos_token_id": 2,
366
+ "exponential_decay_length_penalty": null,
367
+ "finetuning_task": null,
368
+ "forced_bos_token_id": null,
369
+ "forced_eos_token_id": null,
370
+ "hidden_act": "silu",
371
+ "hidden_size": 4096,
372
+ "id2label": {
373
+ "0": "LABEL_0",
374
+ "1": "LABEL_1"
375
+ },
376
+ "initializer_range": 0.02,
377
+ "intermediate_size": 14336,
378
+ "is_decoder": false,
379
+ "is_encoder_decoder": false,
380
+ "label2id": {
381
+ "LABEL_0": 0,
382
+ "LABEL_1": 1
383
+ },
384
+ "length_penalty": 1.0,
385
+ "max_length": 20,
386
+ "max_position_embeddings": 32768,
387
+ "min_length": 0,
388
+ "model_type": "internlm2",
389
+ "no_repeat_ngram_size": 0,
390
+ "num_attention_heads": 32,
391
+ "num_beam_groups": 1,
392
+ "num_beams": 1,
393
+ "num_hidden_layers": 32,
394
+ "num_key_value_heads": 8,
395
+ "num_return_sequences": 1,
396
+ "output_attentions": false,
397
+ "output_hidden_states": false,
398
+ "output_scores": false,
399
+ "pad_token_id": 2,
400
+ "prefix": null,
401
+ "pretraining_tp": 1,
402
+ "problem_type": null,
403
+ "pruned_heads": {},
404
+ "remove_invalid_values": false,
405
+ "repetition_penalty": 1.0,
406
+ "return_dict": true,
407
+ "return_dict_in_generate": false,
408
+ "rms_norm_eps": 1e-05,
409
+ "rope_scaling": {
410
+ "factor": 2.0,
411
+ "type": "dynamic"
412
+ },
413
+ "rope_theta": 1000000,
414
+ "sep_token_id": null,
415
+ "suppress_tokens": null,
416
+ "task_specific_params": null,
417
+ "temperature": 1.0,
418
+ "tf_legacy_loss": false,
419
+ "tie_encoder_decoder": false,
420
+ "tie_word_embeddings": false,
421
+ "tokenizer_class": null,
422
+ "top_k": 50,
423
+ "top_p": 1.0,
424
+ "torch_dtype": "bfloat16",
425
+ "torchscript": false,
426
+ "transformers_version": "4.44.2",
427
+ "typical_p": 1.0,
428
+ "use_bfloat16": true,
429
+ "use_cache": false,
430
+ "vocab_size": 92558
431
+ },
432
+ "max_dynamic_patch": 6,
433
+ "min_dynamic_patch": 1,
434
+ "model_type": "chimera",
435
+ "pad2square": false,
436
+ "ps_version": "solva-chat",
437
+ "select_layer": -1,
438
+ "template": "solva-chat",
439
+ "torch_dtype": "bfloat16",
440
+ "transformers_version": null,
441
+ "use_backbone_lora": 0,
442
+ "use_llm_lora": 0,
443
+ "use_thumbnail": true,
444
+ "vision_config": {
445
+ "_name_or_path": "",
446
+ "add_cross_attention": false,
447
+ "architectures": [
448
+ "InternVisionModel"
449
+ ],
450
+ "attention_dropout": 0.0,
451
+ "bad_words_ids": null,
452
+ "begin_suppress_tokens": null,
453
+ "bos_token_id": null,
454
+ "chunk_size_feed_forward": 0,
455
+ "cross_attention_hidden_size": null,
456
+ "decoder_start_token_id": null,
457
+ "diversity_penalty": 0.0,
458
+ "do_sample": false,
459
+ "drop_path_rate": 0.1,
460
+ "dropout": 0.0,
461
+ "early_stopping": false,
462
+ "encoder_no_repeat_ngram_size": 0,
463
+ "eos_token_id": null,
464
+ "exponential_decay_length_penalty": null,
465
+ "finetuning_task": null,
466
+ "forced_bos_token_id": null,
467
+ "forced_eos_token_id": null,
468
+ "hidden_act": "gelu",
469
+ "hidden_size": 1024,
470
+ "id2label": {
471
+ "0": "LABEL_0",
472
+ "1": "LABEL_1"
473
+ },
474
+ "image_size": 448,
475
+ "initializer_factor": 1.0,
476
+ "initializer_range": 0.02,
477
+ "intermediate_size": 4096,
478
+ "is_decoder": false,
479
+ "is_encoder_decoder": false,
480
+ "label2id": {
481
+ "LABEL_0": 0,
482
+ "LABEL_1": 1
483
+ },
484
+ "layer_norm_eps": 1e-06,
485
+ "length_penalty": 1.0,
486
+ "max_length": 20,
487
+ "min_length": 0,
488
+ "model_type": "intern_vit_6b",
489
+ "no_repeat_ngram_size": 0,
490
+ "norm_type": "layer_norm",
491
+ "num_attention_heads": 16,
492
+ "num_beam_groups": 1,
493
+ "num_beams": 1,
494
+ "num_channels": 3,
495
+ "num_hidden_layers": 24,
496
+ "num_return_sequences": 1,
497
+ "output_attentions": false,
498
+ "output_hidden_states": false,
499
+ "output_scores": false,
500
+ "pad_token_id": null,
501
+ "patch_size": 14,
502
+ "prefix": null,
503
+ "problem_type": null,
504
+ "pruned_heads": {},
505
+ "qk_normalization": false,
506
+ "qkv_bias": true,
507
+ "remove_invalid_values": false,
508
+ "repetition_penalty": 1.0,
509
+ "return_dict": true,
510
+ "return_dict_in_generate": false,
511
+ "sep_token_id": null,
512
+ "suppress_tokens": null,
513
+ "task_specific_params": null,
514
+ "temperature": 1.0,
515
+ "tf_legacy_loss": false,
516
+ "tie_encoder_decoder": false,
517
+ "tie_word_embeddings": true,
518
+ "tokenizer_class": null,
519
+ "top_k": 50,
520
+ "top_p": 1.0,
521
+ "torch_dtype": "bfloat16",
522
+ "torchscript": false,
523
+ "transformers_version": "4.44.2",
524
+ "typical_p": 1.0,
525
+ "use_bfloat16": true,
526
+ "use_flash_attn": true
527
+ }
528
+ }
generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.44.2"
4
+ }
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81a61b774c85fa7d3baf14693dced3cde9d44bcf05ab922b5b744cd9b6e2c528
3
+ size 4913953760
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6779cdf9bde3376c5fddde884747d9e60f649b2873490578d4c12a3e9f8726e6
3
+ size 4999817504
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:584ec431f6c38435c1769a65e6b5683b5d61f3fdc4689e0090b07421a2d2737f
3
+ size 4915914592
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30b66adc1c373690414ba94aec2c32c4537f840e54183b7720e623cf99f989a7
3
+ size 4113857944
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,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|action_start|>",
6
+ "<|action_end|>",
7
+ "<|interpreter|>",
8
+ "<|plugin|>",
9
+ "<img>",
10
+ "</img>",
11
+ "<IMG_CONTEXT>",
12
+ "<quad>",
13
+ "</quad>",
14
+ "<ref>",
15
+ "</ref>",
16
+ "<box>",
17
+ "</box>",
18
+ "<domain>",
19
+ "</domain>",
20
+ "<DOMAIN_0_CONTEXT>",
21
+ "<DOMAIN_1_CONTEXT>",
22
+ "<DOMAIN_2_CONTEXT>"
23
+ ],
24
+ "bos_token": {
25
+ "content": "<s>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "eos_token": {
32
+ "content": "</s>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ },
38
+ "pad_token": {
39
+ "content": "</s>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false
44
+ },
45
+ "unk_token": {
46
+ "content": "<unk>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false
51
+ }
52
+ }
tokenization_internlm2.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) The InternLM team and The HuggingFace Inc. team. All rights reserved.
2
+ #
3
+ # This code is based on transformers/src/transformers/models/llama/tokenization_llama.py
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ """Tokenization classes for InternLM."""
18
+ import os
19
+ from shutil import copyfile
20
+ from typing import Any, Dict, List, Optional, Tuple
21
+
22
+ import sentencepiece as spm
23
+ from transformers.tokenization_utils import PreTrainedTokenizer
24
+ from transformers.utils import logging
25
+
26
+ logger = logging.get_logger(__name__)
27
+
28
+ VOCAB_FILES_NAMES = {'vocab_file': './tokenizer.model'}
29
+
30
+ PRETRAINED_VOCAB_FILES_MAP = {}
31
+
32
+
33
+ # Modified from transformers.model.llama.tokenization_llama.LlamaTokenizer
34
+ class InternLM2Tokenizer(PreTrainedTokenizer):
35
+ """
36
+ Construct a InternLM2 tokenizer. Based on byte-level Byte-Pair-Encoding.
37
+
38
+ Args:
39
+ vocab_file (`str`):
40
+ Path to the vocabulary file.
41
+ """
42
+
43
+ vocab_files_names = VOCAB_FILES_NAMES
44
+ pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
45
+ model_input_names = ['input_ids', 'attention_mask']
46
+ _auto_class = 'AutoTokenizer'
47
+
48
+ def __init__(
49
+ self,
50
+ vocab_file,
51
+ unk_token='<unk>',
52
+ bos_token='<s>',
53
+ eos_token='</s>',
54
+ pad_token='</s>',
55
+ sp_model_kwargs: Optional[Dict[str, Any]] = None,
56
+ add_bos_token=True,
57
+ add_eos_token=False,
58
+ decode_with_prefix_space=False,
59
+ clean_up_tokenization_spaces=False,
60
+ **kwargs,
61
+ ):
62
+ self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
63
+ self.vocab_file = vocab_file
64
+ self.add_bos_token = add_bos_token
65
+ self.add_eos_token = add_eos_token
66
+ self.decode_with_prefix_space = decode_with_prefix_space
67
+ self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
68
+ self.sp_model.Load(vocab_file)
69
+ self._no_prefix_space_tokens = None
70
+ super().__init__(
71
+ bos_token=bos_token,
72
+ eos_token=eos_token,
73
+ unk_token=unk_token,
74
+ pad_token=pad_token,
75
+ clean_up_tokenization_spaces=clean_up_tokenization_spaces,
76
+ **kwargs,
77
+ )
78
+
79
+ @property
80
+ def no_prefix_space_tokens(self):
81
+ if self._no_prefix_space_tokens is None:
82
+ vocab = self.convert_ids_to_tokens(list(range(self.vocab_size)))
83
+ self._no_prefix_space_tokens = {i for i, tok in enumerate(vocab) if not tok.startswith('▁')}
84
+ return self._no_prefix_space_tokens
85
+
86
+ @property
87
+ def vocab_size(self):
88
+ """Returns vocab size"""
89
+ return self.sp_model.get_piece_size()
90
+
91
+ @property
92
+ def bos_token_id(self) -> Optional[int]:
93
+ return self.sp_model.bos_id()
94
+
95
+ @property
96
+ def eos_token_id(self) -> Optional[int]:
97
+ return self.sp_model.eos_id()
98
+
99
+ def get_vocab(self):
100
+ """Returns vocab as a dict"""
101
+ vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
102
+ vocab.update(self.added_tokens_encoder)
103
+ return vocab
104
+
105
+ def _tokenize(self, text):
106
+ """Returns a tokenized string."""
107
+ return self.sp_model.encode(text, out_type=str)
108
+
109
+ def _convert_token_to_id(self, token):
110
+ """Converts a token (str) in an id using the vocab."""
111
+ return self.sp_model.piece_to_id(token)
112
+
113
+ def _convert_id_to_token(self, index):
114
+ """Converts an index (integer) in a token (str) using the vocab."""
115
+ token = self.sp_model.IdToPiece(index)
116
+ return token
117
+
118
+ def _maybe_add_prefix_space(self, tokens, decoded):
119
+ if tokens and tokens[0] not in self.no_prefix_space_tokens:
120
+ return ' ' + decoded
121
+ else:
122
+ return decoded
123
+
124
+ def convert_tokens_to_string(self, tokens):
125
+ """Converts a sequence of tokens (string) in a single string."""
126
+ current_sub_tokens = []
127
+ out_string = ''
128
+ prev_is_special = False
129
+ for token in tokens:
130
+ # make sure that special tokens are not decoded using sentencepiece model
131
+ if token in self.all_special_tokens:
132
+ if not prev_is_special:
133
+ out_string += ' '
134
+ out_string += self.sp_model.decode(current_sub_tokens) + token
135
+ prev_is_special = True
136
+ current_sub_tokens = []
137
+ else:
138
+ current_sub_tokens.append(token)
139
+ prev_is_special = False
140
+ out_string += self.sp_model.decode(current_sub_tokens)
141
+ out_string = self.clean_up_tokenization(out_string)
142
+ out_string = self._maybe_add_prefix_space(tokens=tokens, decoded=out_string)
143
+ return out_string[1:]
144
+
145
+ def save_vocabulary(self, save_directory, filename_prefix: Optional[str] = None) -> Tuple[str]:
146
+ """
147
+ Save the vocabulary and special tokens file to a directory.
148
+
149
+ Args:
150
+ save_directory (`str`):
151
+ The directory in which to save the vocabulary.
152
+
153
+ Returns:
154
+ `Tuple(str)`: Paths to the files saved.
155
+ """
156
+ if not os.path.isdir(save_directory):
157
+ logger.error(f'Vocabulary path ({save_directory}) should be a directory')
158
+ return
159
+ out_vocab_file = os.path.join(
160
+ save_directory, (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']
161
+ )
162
+
163
+ if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file):
164
+ copyfile(self.vocab_file, out_vocab_file)
165
+ elif not os.path.isfile(self.vocab_file):
166
+ with open(out_vocab_file, 'wb') as fi:
167
+ content_spiece_model = self.sp_model.serialized_model_proto()
168
+ fi.write(content_spiece_model)
169
+
170
+ return (out_vocab_file,)
171
+
172
+ def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
173
+ if self.add_bos_token:
174
+ bos_token_ids = [self.bos_token_id]
175
+ else:
176
+ bos_token_ids = []
177
+
178
+ output = bos_token_ids + token_ids_0
179
+
180
+ if token_ids_1 is not None:
181
+ output = output + token_ids_1
182
+
183
+ if self.add_eos_token:
184
+ output = output + [self.eos_token_id]
185
+
186
+ return output
187
+
188
+ def get_special_tokens_mask(
189
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
190
+ ) -> List[int]:
191
+ """
192
+ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
193
+ special tokens using the tokenizer `prepare_for_model` method.
194
+
195
+ Args:
196
+ token_ids_0 (`List[int]`):
197
+ List of IDs.
198
+ token_ids_1 (`List[int]`, *optional*):
199
+ Optional second list of IDs for sequence pairs.
200
+ already_has_special_tokens (`bool`, *optional*, defaults to `False`):
201
+ Whether or not the token list is already formatted with special tokens for the model.
202
+
203
+ Returns:
204
+ `List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
205
+ """
206
+ if already_has_special_tokens:
207
+ return super().get_special_tokens_mask(
208
+ token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
209
+ )
210
+
211
+ if token_ids_1 is None:
212
+ return [1] + ([0] * len(token_ids_0)) + [1]
213
+ return [1] + ([0] * len(token_ids_0)) + [1, 1] + ([0] * len(token_ids_1)) + [1]
214
+
215
+ def create_token_type_ids_from_sequences(
216
+ self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
217
+ ) -> List[int]:
218
+ """
219
+ Create a mask from the two sequences passed to be used in a sequence-pair classification task. T5 does not make
220
+ use of token type ids, therefore a list of zeros is returned.
221
+
222
+ Args:
223
+ token_ids_0 (`List[int]`):
224
+ List of IDs.
225
+ token_ids_1 (`List[int]`, *optional*):
226
+ Optional second list of IDs for sequence pairs.
227
+
228
+ Returns:
229
+ `List[int]`: List of zeros.
230
+ """
231
+ eos = [self.eos_token_id]
232
+
233
+ if token_ids_1 is None:
234
+ return len(token_ids_0 + eos) * [0]
235
+ return len(token_ids_0 + eos + token_ids_1 + eos) * [0]
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f868398fc4e05ee1e8aeba95ddf18ddcc45b8bce55d5093bead5bbf80429b48b
3
+ size 1477754
tokenizer_config.json ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<unk>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<s>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "92538": {
28
+ "content": "<|plugin|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "92539": {
36
+ "content": "<|interpreter|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "92540": {
44
+ "content": "<|action_end|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "92541": {
52
+ "content": "<|action_start|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "92542": {
60
+ "content": "<|im_end|>",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "92543": {
68
+ "content": "<|im_start|>",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "92544": {
76
+ "content": "<img>",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "92545": {
84
+ "content": "</img>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "92546": {
92
+ "content": "<IMG_CONTEXT>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "92547": {
100
+ "content": "<quad>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "92548": {
108
+ "content": "</quad>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ },
115
+ "92549": {
116
+ "content": "<ref>",
117
+ "lstrip": false,
118
+ "normalized": false,
119
+ "rstrip": false,
120
+ "single_word": false,
121
+ "special": true
122
+ },
123
+ "92550": {
124
+ "content": "</ref>",
125
+ "lstrip": false,
126
+ "normalized": false,
127
+ "rstrip": false,
128
+ "single_word": false,
129
+ "special": true
130
+ },
131
+ "92551": {
132
+ "content": "<box>",
133
+ "lstrip": false,
134
+ "normalized": false,
135
+ "rstrip": false,
136
+ "single_word": false,
137
+ "special": true
138
+ },
139
+ "92552": {
140
+ "content": "</box>",
141
+ "lstrip": false,
142
+ "normalized": false,
143
+ "rstrip": false,
144
+ "single_word": false,
145
+ "special": true
146
+ },
147
+ "92553": {
148
+ "content": "<domain>",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false,
153
+ "special": true
154
+ },
155
+ "92554": {
156
+ "content": "</domain>",
157
+ "lstrip": false,
158
+ "normalized": false,
159
+ "rstrip": false,
160
+ "single_word": false,
161
+ "special": true
162
+ },
163
+ "92555": {
164
+ "content": "<DOMAIN_0_CONTEXT>",
165
+ "lstrip": false,
166
+ "normalized": false,
167
+ "rstrip": false,
168
+ "single_word": false,
169
+ "special": true
170
+ },
171
+ "92556": {
172
+ "content": "<DOMAIN_1_CONTEXT>",
173
+ "lstrip": false,
174
+ "normalized": false,
175
+ "rstrip": false,
176
+ "single_word": false,
177
+ "special": true
178
+ },
179
+ "92557": {
180
+ "content": "<DOMAIN_2_CONTEXT>",
181
+ "lstrip": false,
182
+ "normalized": false,
183
+ "rstrip": false,
184
+ "single_word": false,
185
+ "special": true
186
+ }
187
+ },
188
+ "additional_special_tokens": [
189
+ "<|im_start|>",
190
+ "<|im_end|>",
191
+ "<|action_start|>",
192
+ "<|action_end|>",
193
+ "<|interpreter|>",
194
+ "<|plugin|>",
195
+ "<img>",
196
+ "</img>",
197
+ "<IMG_CONTEXT>",
198
+ "<quad>",
199
+ "</quad>",
200
+ "<ref>",
201
+ "</ref>",
202
+ "<box>",
203
+ "</box>",
204
+ "<domain>",
205
+ "</domain>",
206
+ "<DOMAIN_0_CONTEXT>",
207
+ "<DOMAIN_1_CONTEXT>",
208
+ "<DOMAIN_2_CONTEXT>"
209
+ ],
210
+ "auto_map": {
211
+ "AutoTokenizer": [
212
+ "tokenization_internlm2.InternLM2Tokenizer",
213
+ null
214
+ ]
215
+ },
216
+ "bos_token": "<s>",
217
+ "chat_template": "{{ bos_token }}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
218
+ "clean_up_tokenization_spaces": false,
219
+ "eos_token": "</s>",
220
+ "model_max_length": 8192,
221
+ "pad_token": "</s>",
222
+ "tokenizer_class": "InternLM2Tokenizer",
223
+ "unk_token": "<unk>"
224
+ }