Yuan-lab commited on
Commit
46a2a2d
·
verified ·
1 Parent(s): 2e05013

Upload 8 files

Browse files
added_tokens.json ADDED
@@ -0,0 +1,1049 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</3dbox>": 134971,
3
+ "</IMAGE>": 134962,
4
+ "</box>": 134967,
5
+ "</code_query>": 135987,
6
+ "</code_result>": 135989,
7
+ "</depth>": 134973,
8
+ "</final_answer>": 135999,
9
+ "</infer>": 135991,
10
+ "</inferresult>": 135993,
11
+ "</obj>": 134965,
12
+ "</point>": 134969,
13
+ "</search_query>": 135985,
14
+ "</search_result>": 135983,
15
+ "</think>": 135981,
16
+ "</tool_calls>": 135995,
17
+ "</tool_response>": 135997,
18
+ "<3dbox>": 134970,
19
+ "<BOS>": 134960,
20
+ "<FIM_MIDDLE>": 134957,
21
+ "<FIM_PREFIX>": 134956,
22
+ "<FIM_SUFFIX>": 134955,
23
+ "<IMAGE>": 134961,
24
+ "<box>": 134966,
25
+ "<code_query>": 135986,
26
+ "<code_result>": 135988,
27
+ "<depth>": 134972,
28
+ "<eog>": 135975,
29
+ "<eop>": 135974,
30
+ "<file_sep>": 134959,
31
+ "<final_answer>": 135998,
32
+ "<grounding>": 134963,
33
+ "<infer>": 135990,
34
+ "<inferresult>": 135992,
35
+ "<mask>": 134953,
36
+ "<obj>": 134964,
37
+ "<point>": 134968,
38
+ "<predict>": 134954,
39
+ "<repo_name>": 134958,
40
+ "<search_query>": 135984,
41
+ "<search_result>": 135982,
42
+ "<think>": 135980,
43
+ "<tool_calls>": 135994,
44
+ "<tool_response>": 135996,
45
+ "<|Assistant|>": 135979,
46
+ "<|User|>": 135978,
47
+ "<|begin_of_sentence|>": 135976,
48
+ "<|end_of_sentence|>": 135977,
49
+ "s000": 134974,
50
+ "s001": 134975,
51
+ "s002": 134976,
52
+ "s003": 134977,
53
+ "s004": 134978,
54
+ "s005": 134979,
55
+ "s006": 134980,
56
+ "s007": 134981,
57
+ "s008": 134982,
58
+ "s009": 134983,
59
+ "s010": 134984,
60
+ "s011": 134985,
61
+ "s012": 134986,
62
+ "s013": 134987,
63
+ "s014": 134988,
64
+ "s015": 134989,
65
+ "s016": 134990,
66
+ "s017": 134991,
67
+ "s018": 134992,
68
+ "s019": 134993,
69
+ "s020": 134994,
70
+ "s021": 134995,
71
+ "s022": 134996,
72
+ "s023": 134997,
73
+ "s024": 134998,
74
+ "s025": 134999,
75
+ "s026": 135000,
76
+ "s027": 135001,
77
+ "s028": 135002,
78
+ "s029": 135003,
79
+ "s030": 135004,
80
+ "s031": 135005,
81
+ "s032": 135006,
82
+ "s033": 135007,
83
+ "s034": 135008,
84
+ "s035": 135009,
85
+ "s036": 135010,
86
+ "s037": 135011,
87
+ "s038": 135012,
88
+ "s039": 135013,
89
+ "s040": 135014,
90
+ "s041": 135015,
91
+ "s042": 135016,
92
+ "s043": 135017,
93
+ "s044": 135018,
94
+ "s045": 135019,
95
+ "s046": 135020,
96
+ "s047": 135021,
97
+ "s048": 135022,
98
+ "s049": 135023,
99
+ "s050": 135024,
100
+ "s051": 135025,
101
+ "s052": 135026,
102
+ "s053": 135027,
103
+ "s054": 135028,
104
+ "s055": 135029,
105
+ "s056": 135030,
106
+ "s057": 135031,
107
+ "s058": 135032,
108
+ "s059": 135033,
109
+ "s060": 135034,
110
+ "s061": 135035,
111
+ "s062": 135036,
112
+ "s063": 135037,
113
+ "s064": 135038,
114
+ "s065": 135039,
115
+ "s066": 135040,
116
+ "s067": 135041,
117
+ "s068": 135042,
118
+ "s069": 135043,
119
+ "s070": 135044,
120
+ "s071": 135045,
121
+ "s072": 135046,
122
+ "s073": 135047,
123
+ "s074": 135048,
124
+ "s075": 135049,
125
+ "s076": 135050,
126
+ "s077": 135051,
127
+ "s078": 135052,
128
+ "s079": 135053,
129
+ "s080": 135054,
130
+ "s081": 135055,
131
+ "s082": 135056,
132
+ "s083": 135057,
133
+ "s084": 135058,
134
+ "s085": 135059,
135
+ "s086": 135060,
136
+ "s087": 135061,
137
+ "s088": 135062,
138
+ "s089": 135063,
139
+ "s090": 135064,
140
+ "s091": 135065,
141
+ "s092": 135066,
142
+ "s093": 135067,
143
+ "s094": 135068,
144
+ "s095": 135069,
145
+ "s096": 135070,
146
+ "s097": 135071,
147
+ "s098": 135072,
148
+ "s099": 135073,
149
+ "s100": 135074,
150
+ "s101": 135075,
151
+ "s102": 135076,
152
+ "s103": 135077,
153
+ "s104": 135078,
154
+ "s105": 135079,
155
+ "s106": 135080,
156
+ "s107": 135081,
157
+ "s108": 135082,
158
+ "s109": 135083,
159
+ "s110": 135084,
160
+ "s111": 135085,
161
+ "s112": 135086,
162
+ "s113": 135087,
163
+ "s114": 135088,
164
+ "s115": 135089,
165
+ "s116": 135090,
166
+ "s117": 135091,
167
+ "s118": 135092,
168
+ "s119": 135093,
169
+ "s120": 135094,
170
+ "s121": 135095,
171
+ "s122": 135096,
172
+ "s123": 135097,
173
+ "s124": 135098,
174
+ "s125": 135099,
175
+ "s126": 135100,
176
+ "s127": 135101,
177
+ "s128": 135102,
178
+ "s129": 135103,
179
+ "s130": 135104,
180
+ "s131": 135105,
181
+ "s132": 135106,
182
+ "s133": 135107,
183
+ "s134": 135108,
184
+ "s135": 135109,
185
+ "s136": 135110,
186
+ "s137": 135111,
187
+ "s138": 135112,
188
+ "s139": 135113,
189
+ "s140": 135114,
190
+ "s141": 135115,
191
+ "s142": 135116,
192
+ "s143": 135117,
193
+ "s144": 135118,
194
+ "s145": 135119,
195
+ "s146": 135120,
196
+ "s147": 135121,
197
+ "s148": 135122,
198
+ "s149": 135123,
199
+ "s150": 135124,
200
+ "s151": 135125,
201
+ "s152": 135126,
202
+ "s153": 135127,
203
+ "s154": 135128,
204
+ "s155": 135129,
205
+ "s156": 135130,
206
+ "s157": 135131,
207
+ "s158": 135132,
208
+ "s159": 135133,
209
+ "s160": 135134,
210
+ "s161": 135135,
211
+ "s162": 135136,
212
+ "s163": 135137,
213
+ "s164": 135138,
214
+ "s165": 135139,
215
+ "s166": 135140,
216
+ "s167": 135141,
217
+ "s168": 135142,
218
+ "s169": 135143,
219
+ "s170": 135144,
220
+ "s171": 135145,
221
+ "s172": 135146,
222
+ "s173": 135147,
223
+ "s174": 135148,
224
+ "s175": 135149,
225
+ "s176": 135150,
226
+ "s177": 135151,
227
+ "s178": 135152,
228
+ "s179": 135153,
229
+ "s180": 135154,
230
+ "s181": 135155,
231
+ "s182": 135156,
232
+ "s183": 135157,
233
+ "s184": 135158,
234
+ "s185": 135159,
235
+ "s186": 135160,
236
+ "s187": 135161,
237
+ "s188": 135162,
238
+ "s189": 135163,
239
+ "s190": 135164,
240
+ "s191": 135165,
241
+ "s192": 135166,
242
+ "s193": 135167,
243
+ "s194": 135168,
244
+ "s195": 135169,
245
+ "s196": 135170,
246
+ "s197": 135171,
247
+ "s198": 135172,
248
+ "s199": 135173,
249
+ "s200": 135174,
250
+ "s201": 135175,
251
+ "s202": 135176,
252
+ "s203": 135177,
253
+ "s204": 135178,
254
+ "s205": 135179,
255
+ "s206": 135180,
256
+ "s207": 135181,
257
+ "s208": 135182,
258
+ "s209": 135183,
259
+ "s210": 135184,
260
+ "s211": 135185,
261
+ "s212": 135186,
262
+ "s213": 135187,
263
+ "s214": 135188,
264
+ "s215": 135189,
265
+ "s216": 135190,
266
+ "s217": 135191,
267
+ "s218": 135192,
268
+ "s219": 135193,
269
+ "s220": 135194,
270
+ "s221": 135195,
271
+ "s222": 135196,
272
+ "s223": 135197,
273
+ "s224": 135198,
274
+ "s225": 135199,
275
+ "s226": 135200,
276
+ "s227": 135201,
277
+ "s228": 135202,
278
+ "s229": 135203,
279
+ "s230": 135204,
280
+ "s231": 135205,
281
+ "s232": 135206,
282
+ "s233": 135207,
283
+ "s234": 135208,
284
+ "s235": 135209,
285
+ "s236": 135210,
286
+ "s237": 135211,
287
+ "s238": 135212,
288
+ "s239": 135213,
289
+ "s240": 135214,
290
+ "s241": 135215,
291
+ "s242": 135216,
292
+ "s243": 135217,
293
+ "s244": 135218,
294
+ "s245": 135219,
295
+ "s246": 135220,
296
+ "s247": 135221,
297
+ "s248": 135222,
298
+ "s249": 135223,
299
+ "s250": 135224,
300
+ "s251": 135225,
301
+ "s252": 135226,
302
+ "s253": 135227,
303
+ "s254": 135228,
304
+ "s255": 135229,
305
+ "s256": 135230,
306
+ "s257": 135231,
307
+ "s258": 135232,
308
+ "s259": 135233,
309
+ "s260": 135234,
310
+ "s261": 135235,
311
+ "s262": 135236,
312
+ "s263": 135237,
313
+ "s264": 135238,
314
+ "s265": 135239,
315
+ "s266": 135240,
316
+ "s267": 135241,
317
+ "s268": 135242,
318
+ "s269": 135243,
319
+ "s270": 135244,
320
+ "s271": 135245,
321
+ "s272": 135246,
322
+ "s273": 135247,
323
+ "s274": 135248,
324
+ "s275": 135249,
325
+ "s276": 135250,
326
+ "s277": 135251,
327
+ "s278": 135252,
328
+ "s279": 135253,
329
+ "s280": 135254,
330
+ "s281": 135255,
331
+ "s282": 135256,
332
+ "s283": 135257,
333
+ "s284": 135258,
334
+ "s285": 135259,
335
+ "s286": 135260,
336
+ "s287": 135261,
337
+ "s288": 135262,
338
+ "s289": 135263,
339
+ "s290": 135264,
340
+ "s291": 135265,
341
+ "s292": 135266,
342
+ "s293": 135267,
343
+ "s294": 135268,
344
+ "s295": 135269,
345
+ "s296": 135270,
346
+ "s297": 135271,
347
+ "s298": 135272,
348
+ "s299": 135273,
349
+ "s300": 135274,
350
+ "s301": 135275,
351
+ "s302": 135276,
352
+ "s303": 135277,
353
+ "s304": 135278,
354
+ "s305": 135279,
355
+ "s306": 135280,
356
+ "s307": 135281,
357
+ "s308": 135282,
358
+ "s309": 135283,
359
+ "s310": 135284,
360
+ "s311": 135285,
361
+ "s312": 135286,
362
+ "s313": 135287,
363
+ "s314": 135288,
364
+ "s315": 135289,
365
+ "s316": 135290,
366
+ "s317": 135291,
367
+ "s318": 135292,
368
+ "s319": 135293,
369
+ "s320": 135294,
370
+ "s321": 135295,
371
+ "s322": 135296,
372
+ "s323": 135297,
373
+ "s324": 135298,
374
+ "s325": 135299,
375
+ "s326": 135300,
376
+ "s327": 135301,
377
+ "s328": 135302,
378
+ "s329": 135303,
379
+ "s330": 135304,
380
+ "s331": 135305,
381
+ "s332": 135306,
382
+ "s333": 135307,
383
+ "s334": 135308,
384
+ "s335": 135309,
385
+ "s336": 135310,
386
+ "s337": 135311,
387
+ "s338": 135312,
388
+ "s339": 135313,
389
+ "s340": 135314,
390
+ "s341": 135315,
391
+ "s342": 135316,
392
+ "s343": 135317,
393
+ "s344": 135318,
394
+ "s345": 135319,
395
+ "s346": 135320,
396
+ "s347": 135321,
397
+ "s348": 135322,
398
+ "s349": 135323,
399
+ "s350": 135324,
400
+ "s351": 135325,
401
+ "s352": 135326,
402
+ "s353": 135327,
403
+ "s354": 135328,
404
+ "s355": 135329,
405
+ "s356": 135330,
406
+ "s357": 135331,
407
+ "s358": 135332,
408
+ "s359": 135333,
409
+ "s360": 135334,
410
+ "s361": 135335,
411
+ "s362": 135336,
412
+ "s363": 135337,
413
+ "s364": 135338,
414
+ "s365": 135339,
415
+ "s366": 135340,
416
+ "s367": 135341,
417
+ "s368": 135342,
418
+ "s369": 135343,
419
+ "s370": 135344,
420
+ "s371": 135345,
421
+ "s372": 135346,
422
+ "s373": 135347,
423
+ "s374": 135348,
424
+ "s375": 135349,
425
+ "s376": 135350,
426
+ "s377": 135351,
427
+ "s378": 135352,
428
+ "s379": 135353,
429
+ "s380": 135354,
430
+ "s381": 135355,
431
+ "s382": 135356,
432
+ "s383": 135357,
433
+ "s384": 135358,
434
+ "s385": 135359,
435
+ "s386": 135360,
436
+ "s387": 135361,
437
+ "s388": 135362,
438
+ "s389": 135363,
439
+ "s390": 135364,
440
+ "s391": 135365,
441
+ "s392": 135366,
442
+ "s393": 135367,
443
+ "s394": 135368,
444
+ "s395": 135369,
445
+ "s396": 135370,
446
+ "s397": 135371,
447
+ "s398": 135372,
448
+ "s399": 135373,
449
+ "s400": 135374,
450
+ "s401": 135375,
451
+ "s402": 135376,
452
+ "s403": 135377,
453
+ "s404": 135378,
454
+ "s405": 135379,
455
+ "s406": 135380,
456
+ "s407": 135381,
457
+ "s408": 135382,
458
+ "s409": 135383,
459
+ "s410": 135384,
460
+ "s411": 135385,
461
+ "s412": 135386,
462
+ "s413": 135387,
463
+ "s414": 135388,
464
+ "s415": 135389,
465
+ "s416": 135390,
466
+ "s417": 135391,
467
+ "s418": 135392,
468
+ "s419": 135393,
469
+ "s420": 135394,
470
+ "s421": 135395,
471
+ "s422": 135396,
472
+ "s423": 135397,
473
+ "s424": 135398,
474
+ "s425": 135399,
475
+ "s426": 135400,
476
+ "s427": 135401,
477
+ "s428": 135402,
478
+ "s429": 135403,
479
+ "s430": 135404,
480
+ "s431": 135405,
481
+ "s432": 135406,
482
+ "s433": 135407,
483
+ "s434": 135408,
484
+ "s435": 135409,
485
+ "s436": 135410,
486
+ "s437": 135411,
487
+ "s438": 135412,
488
+ "s439": 135413,
489
+ "s440": 135414,
490
+ "s441": 135415,
491
+ "s442": 135416,
492
+ "s443": 135417,
493
+ "s444": 135418,
494
+ "s445": 135419,
495
+ "s446": 135420,
496
+ "s447": 135421,
497
+ "s448": 135422,
498
+ "s449": 135423,
499
+ "s450": 135424,
500
+ "s451": 135425,
501
+ "s452": 135426,
502
+ "s453": 135427,
503
+ "s454": 135428,
504
+ "s455": 135429,
505
+ "s456": 135430,
506
+ "s457": 135431,
507
+ "s458": 135432,
508
+ "s459": 135433,
509
+ "s460": 135434,
510
+ "s461": 135435,
511
+ "s462": 135436,
512
+ "s463": 135437,
513
+ "s464": 135438,
514
+ "s465": 135439,
515
+ "s466": 135440,
516
+ "s467": 135441,
517
+ "s468": 135442,
518
+ "s469": 135443,
519
+ "s470": 135444,
520
+ "s471": 135445,
521
+ "s472": 135446,
522
+ "s473": 135447,
523
+ "s474": 135448,
524
+ "s475": 135449,
525
+ "s476": 135450,
526
+ "s477": 135451,
527
+ "s478": 135452,
528
+ "s479": 135453,
529
+ "s480": 135454,
530
+ "s481": 135455,
531
+ "s482": 135456,
532
+ "s483": 135457,
533
+ "s484": 135458,
534
+ "s485": 135459,
535
+ "s486": 135460,
536
+ "s487": 135461,
537
+ "s488": 135462,
538
+ "s489": 135463,
539
+ "s490": 135464,
540
+ "s491": 135465,
541
+ "s492": 135466,
542
+ "s493": 135467,
543
+ "s494": 135468,
544
+ "s495": 135469,
545
+ "s496": 135470,
546
+ "s497": 135471,
547
+ "s498": 135472,
548
+ "s499": 135473,
549
+ "s500": 135474,
550
+ "s501": 135475,
551
+ "s502": 135476,
552
+ "s503": 135477,
553
+ "s504": 135478,
554
+ "s505": 135479,
555
+ "s506": 135480,
556
+ "s507": 135481,
557
+ "s508": 135482,
558
+ "s509": 135483,
559
+ "s510": 135484,
560
+ "s511": 135485,
561
+ "s512": 135486,
562
+ "s513": 135487,
563
+ "s514": 135488,
564
+ "s515": 135489,
565
+ "s516": 135490,
566
+ "s517": 135491,
567
+ "s518": 135492,
568
+ "s519": 135493,
569
+ "s520": 135494,
570
+ "s521": 135495,
571
+ "s522": 135496,
572
+ "s523": 135497,
573
+ "s524": 135498,
574
+ "s525": 135499,
575
+ "s526": 135500,
576
+ "s527": 135501,
577
+ "s528": 135502,
578
+ "s529": 135503,
579
+ "s530": 135504,
580
+ "s531": 135505,
581
+ "s532": 135506,
582
+ "s533": 135507,
583
+ "s534": 135508,
584
+ "s535": 135509,
585
+ "s536": 135510,
586
+ "s537": 135511,
587
+ "s538": 135512,
588
+ "s539": 135513,
589
+ "s540": 135514,
590
+ "s541": 135515,
591
+ "s542": 135516,
592
+ "s543": 135517,
593
+ "s544": 135518,
594
+ "s545": 135519,
595
+ "s546": 135520,
596
+ "s547": 135521,
597
+ "s548": 135522,
598
+ "s549": 135523,
599
+ "s550": 135524,
600
+ "s551": 135525,
601
+ "s552": 135526,
602
+ "s553": 135527,
603
+ "s554": 135528,
604
+ "s555": 135529,
605
+ "s556": 135530,
606
+ "s557": 135531,
607
+ "s558": 135532,
608
+ "s559": 135533,
609
+ "s560": 135534,
610
+ "s561": 135535,
611
+ "s562": 135536,
612
+ "s563": 135537,
613
+ "s564": 135538,
614
+ "s565": 135539,
615
+ "s566": 135540,
616
+ "s567": 135541,
617
+ "s568": 135542,
618
+ "s569": 135543,
619
+ "s570": 135544,
620
+ "s571": 135545,
621
+ "s572": 135546,
622
+ "s573": 135547,
623
+ "s574": 135548,
624
+ "s575": 135549,
625
+ "s576": 135550,
626
+ "s577": 135551,
627
+ "s578": 135552,
628
+ "s579": 135553,
629
+ "s580": 135554,
630
+ "s581": 135555,
631
+ "s582": 135556,
632
+ "s583": 135557,
633
+ "s584": 135558,
634
+ "s585": 135559,
635
+ "s586": 135560,
636
+ "s587": 135561,
637
+ "s588": 135562,
638
+ "s589": 135563,
639
+ "s590": 135564,
640
+ "s591": 135565,
641
+ "s592": 135566,
642
+ "s593": 135567,
643
+ "s594": 135568,
644
+ "s595": 135569,
645
+ "s596": 135570,
646
+ "s597": 135571,
647
+ "s598": 135572,
648
+ "s599": 135573,
649
+ "s600": 135574,
650
+ "s601": 135575,
651
+ "s602": 135576,
652
+ "s603": 135577,
653
+ "s604": 135578,
654
+ "s605": 135579,
655
+ "s606": 135580,
656
+ "s607": 135581,
657
+ "s608": 135582,
658
+ "s609": 135583,
659
+ "s610": 135584,
660
+ "s611": 135585,
661
+ "s612": 135586,
662
+ "s613": 135587,
663
+ "s614": 135588,
664
+ "s615": 135589,
665
+ "s616": 135590,
666
+ "s617": 135591,
667
+ "s618": 135592,
668
+ "s619": 135593,
669
+ "s620": 135594,
670
+ "s621": 135595,
671
+ "s622": 135596,
672
+ "s623": 135597,
673
+ "s624": 135598,
674
+ "s625": 135599,
675
+ "s626": 135600,
676
+ "s627": 135601,
677
+ "s628": 135602,
678
+ "s629": 135603,
679
+ "s630": 135604,
680
+ "s631": 135605,
681
+ "s632": 135606,
682
+ "s633": 135607,
683
+ "s634": 135608,
684
+ "s635": 135609,
685
+ "s636": 135610,
686
+ "s637": 135611,
687
+ "s638": 135612,
688
+ "s639": 135613,
689
+ "s640": 135614,
690
+ "s641": 135615,
691
+ "s642": 135616,
692
+ "s643": 135617,
693
+ "s644": 135618,
694
+ "s645": 135619,
695
+ "s646": 135620,
696
+ "s647": 135621,
697
+ "s648": 135622,
698
+ "s649": 135623,
699
+ "s650": 135624,
700
+ "s651": 135625,
701
+ "s652": 135626,
702
+ "s653": 135627,
703
+ "s654": 135628,
704
+ "s655": 135629,
705
+ "s656": 135630,
706
+ "s657": 135631,
707
+ "s658": 135632,
708
+ "s659": 135633,
709
+ "s660": 135634,
710
+ "s661": 135635,
711
+ "s662": 135636,
712
+ "s663": 135637,
713
+ "s664": 135638,
714
+ "s665": 135639,
715
+ "s666": 135640,
716
+ "s667": 135641,
717
+ "s668": 135642,
718
+ "s669": 135643,
719
+ "s670": 135644,
720
+ "s671": 135645,
721
+ "s672": 135646,
722
+ "s673": 135647,
723
+ "s674": 135648,
724
+ "s675": 135649,
725
+ "s676": 135650,
726
+ "s677": 135651,
727
+ "s678": 135652,
728
+ "s679": 135653,
729
+ "s680": 135654,
730
+ "s681": 135655,
731
+ "s682": 135656,
732
+ "s683": 135657,
733
+ "s684": 135658,
734
+ "s685": 135659,
735
+ "s686": 135660,
736
+ "s687": 135661,
737
+ "s688": 135662,
738
+ "s689": 135663,
739
+ "s690": 135664,
740
+ "s691": 135665,
741
+ "s692": 135666,
742
+ "s693": 135667,
743
+ "s694": 135668,
744
+ "s695": 135669,
745
+ "s696": 135670,
746
+ "s697": 135671,
747
+ "s698": 135672,
748
+ "s699": 135673,
749
+ "s700": 135674,
750
+ "s701": 135675,
751
+ "s702": 135676,
752
+ "s703": 135677,
753
+ "s704": 135678,
754
+ "s705": 135679,
755
+ "s706": 135680,
756
+ "s707": 135681,
757
+ "s708": 135682,
758
+ "s709": 135683,
759
+ "s710": 135684,
760
+ "s711": 135685,
761
+ "s712": 135686,
762
+ "s713": 135687,
763
+ "s714": 135688,
764
+ "s715": 135689,
765
+ "s716": 135690,
766
+ "s717": 135691,
767
+ "s718": 135692,
768
+ "s719": 135693,
769
+ "s720": 135694,
770
+ "s721": 135695,
771
+ "s722": 135696,
772
+ "s723": 135697,
773
+ "s724": 135698,
774
+ "s725": 135699,
775
+ "s726": 135700,
776
+ "s727": 135701,
777
+ "s728": 135702,
778
+ "s729": 135703,
779
+ "s730": 135704,
780
+ "s731": 135705,
781
+ "s732": 135706,
782
+ "s733": 135707,
783
+ "s734": 135708,
784
+ "s735": 135709,
785
+ "s736": 135710,
786
+ "s737": 135711,
787
+ "s738": 135712,
788
+ "s739": 135713,
789
+ "s740": 135714,
790
+ "s741": 135715,
791
+ "s742": 135716,
792
+ "s743": 135717,
793
+ "s744": 135718,
794
+ "s745": 135719,
795
+ "s746": 135720,
796
+ "s747": 135721,
797
+ "s748": 135722,
798
+ "s749": 135723,
799
+ "s750": 135724,
800
+ "s751": 135725,
801
+ "s752": 135726,
802
+ "s753": 135727,
803
+ "s754": 135728,
804
+ "s755": 135729,
805
+ "s756": 135730,
806
+ "s757": 135731,
807
+ "s758": 135732,
808
+ "s759": 135733,
809
+ "s760": 135734,
810
+ "s761": 135735,
811
+ "s762": 135736,
812
+ "s763": 135737,
813
+ "s764": 135738,
814
+ "s765": 135739,
815
+ "s766": 135740,
816
+ "s767": 135741,
817
+ "s768": 135742,
818
+ "s769": 135743,
819
+ "s770": 135744,
820
+ "s771": 135745,
821
+ "s772": 135746,
822
+ "s773": 135747,
823
+ "s774": 135748,
824
+ "s775": 135749,
825
+ "s776": 135750,
826
+ "s777": 135751,
827
+ "s778": 135752,
828
+ "s779": 135753,
829
+ "s780": 135754,
830
+ "s781": 135755,
831
+ "s782": 135756,
832
+ "s783": 135757,
833
+ "s784": 135758,
834
+ "s785": 135759,
835
+ "s786": 135760,
836
+ "s787": 135761,
837
+ "s788": 135762,
838
+ "s789": 135763,
839
+ "s790": 135764,
840
+ "s791": 135765,
841
+ "s792": 135766,
842
+ "s793": 135767,
843
+ "s794": 135768,
844
+ "s795": 135769,
845
+ "s796": 135770,
846
+ "s797": 135771,
847
+ "s798": 135772,
848
+ "s799": 135773,
849
+ "s800": 135774,
850
+ "s801": 135775,
851
+ "s802": 135776,
852
+ "s803": 135777,
853
+ "s804": 135778,
854
+ "s805": 135779,
855
+ "s806": 135780,
856
+ "s807": 135781,
857
+ "s808": 135782,
858
+ "s809": 135783,
859
+ "s810": 135784,
860
+ "s811": 135785,
861
+ "s812": 135786,
862
+ "s813": 135787,
863
+ "s814": 135788,
864
+ "s815": 135789,
865
+ "s816": 135790,
866
+ "s817": 135791,
867
+ "s818": 135792,
868
+ "s819": 135793,
869
+ "s820": 135794,
870
+ "s821": 135795,
871
+ "s822": 135796,
872
+ "s823": 135797,
873
+ "s824": 135798,
874
+ "s825": 135799,
875
+ "s826": 135800,
876
+ "s827": 135801,
877
+ "s828": 135802,
878
+ "s829": 135803,
879
+ "s830": 135804,
880
+ "s831": 135805,
881
+ "s832": 135806,
882
+ "s833": 135807,
883
+ "s834": 135808,
884
+ "s835": 135809,
885
+ "s836": 135810,
886
+ "s837": 135811,
887
+ "s838": 135812,
888
+ "s839": 135813,
889
+ "s840": 135814,
890
+ "s841": 135815,
891
+ "s842": 135816,
892
+ "s843": 135817,
893
+ "s844": 135818,
894
+ "s845": 135819,
895
+ "s846": 135820,
896
+ "s847": 135821,
897
+ "s848": 135822,
898
+ "s849": 135823,
899
+ "s850": 135824,
900
+ "s851": 135825,
901
+ "s852": 135826,
902
+ "s853": 135827,
903
+ "s854": 135828,
904
+ "s855": 135829,
905
+ "s856": 135830,
906
+ "s857": 135831,
907
+ "s858": 135832,
908
+ "s859": 135833,
909
+ "s860": 135834,
910
+ "s861": 135835,
911
+ "s862": 135836,
912
+ "s863": 135837,
913
+ "s864": 135838,
914
+ "s865": 135839,
915
+ "s866": 135840,
916
+ "s867": 135841,
917
+ "s868": 135842,
918
+ "s869": 135843,
919
+ "s870": 135844,
920
+ "s871": 135845,
921
+ "s872": 135846,
922
+ "s873": 135847,
923
+ "s874": 135848,
924
+ "s875": 135849,
925
+ "s876": 135850,
926
+ "s877": 135851,
927
+ "s878": 135852,
928
+ "s879": 135853,
929
+ "s880": 135854,
930
+ "s881": 135855,
931
+ "s882": 135856,
932
+ "s883": 135857,
933
+ "s884": 135858,
934
+ "s885": 135859,
935
+ "s886": 135860,
936
+ "s887": 135861,
937
+ "s888": 135862,
938
+ "s889": 135863,
939
+ "s890": 135864,
940
+ "s891": 135865,
941
+ "s892": 135866,
942
+ "s893": 135867,
943
+ "s894": 135868,
944
+ "s895": 135869,
945
+ "s896": 135870,
946
+ "s897": 135871,
947
+ "s898": 135872,
948
+ "s899": 135873,
949
+ "s900": 135874,
950
+ "s901": 135875,
951
+ "s902": 135876,
952
+ "s903": 135877,
953
+ "s904": 135878,
954
+ "s905": 135879,
955
+ "s906": 135880,
956
+ "s907": 135881,
957
+ "s908": 135882,
958
+ "s909": 135883,
959
+ "s910": 135884,
960
+ "s911": 135885,
961
+ "s912": 135886,
962
+ "s913": 135887,
963
+ "s914": 135888,
964
+ "s915": 135889,
965
+ "s916": 135890,
966
+ "s917": 135891,
967
+ "s918": 135892,
968
+ "s919": 135893,
969
+ "s920": 135894,
970
+ "s921": 135895,
971
+ "s922": 135896,
972
+ "s923": 135897,
973
+ "s924": 135898,
974
+ "s925": 135899,
975
+ "s926": 135900,
976
+ "s927": 135901,
977
+ "s928": 135902,
978
+ "s929": 135903,
979
+ "s930": 135904,
980
+ "s931": 135905,
981
+ "s932": 135906,
982
+ "s933": 135907,
983
+ "s934": 135908,
984
+ "s935": 135909,
985
+ "s936": 135910,
986
+ "s937": 135911,
987
+ "s938": 135912,
988
+ "s939": 135913,
989
+ "s940": 135914,
990
+ "s941": 135915,
991
+ "s942": 135916,
992
+ "s943": 135917,
993
+ "s944": 135918,
994
+ "s945": 135919,
995
+ "s946": 135920,
996
+ "s947": 135921,
997
+ "s948": 135922,
998
+ "s949": 135923,
999
+ "s950": 135924,
1000
+ "s951": 135925,
1001
+ "s952": 135926,
1002
+ "s953": 135927,
1003
+ "s954": 135928,
1004
+ "s955": 135929,
1005
+ "s956": 135930,
1006
+ "s957": 135931,
1007
+ "s958": 135932,
1008
+ "s959": 135933,
1009
+ "s960": 135934,
1010
+ "s961": 135935,
1011
+ "s962": 135936,
1012
+ "s963": 135937,
1013
+ "s964": 135938,
1014
+ "s965": 135939,
1015
+ "s966": 135940,
1016
+ "s967": 135941,
1017
+ "s968": 135942,
1018
+ "s969": 135943,
1019
+ "s970": 135944,
1020
+ "s971": 135945,
1021
+ "s972": 135946,
1022
+ "s973": 135947,
1023
+ "s974": 135948,
1024
+ "s975": 135949,
1025
+ "s976": 135950,
1026
+ "s977": 135951,
1027
+ "s978": 135952,
1028
+ "s979": 135953,
1029
+ "s980": 135954,
1030
+ "s981": 135955,
1031
+ "s982": 135956,
1032
+ "s983": 135957,
1033
+ "s984": 135958,
1034
+ "s985": 135959,
1035
+ "s986": 135960,
1036
+ "s987": 135961,
1037
+ "s988": 135962,
1038
+ "s989": 135963,
1039
+ "s990": 135964,
1040
+ "s991": 135965,
1041
+ "s992": 135966,
1042
+ "s993": 135967,
1043
+ "s994": 135968,
1044
+ "s995": 135969,
1045
+ "s996": 135970,
1046
+ "s997": 135971,
1047
+ "s998": 135972,
1048
+ "s999": 135973
1049
+ }
chat_template.jinja ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% for message in messages if message.role == 'user' and message.content is iterable and message.content is not string %}
2
+ {% for item in message.content if item.type == 'image' %}
3
+ {{- '<image>' -}}
4
+ {% endfor %}
5
+ {% endfor %}
6
+
7
+ {{- '<|begin_of_sentence|>' -}}
8
+
9
+ {%- set system_message = namespace(value=none) -%}
10
+ {%- for message in messages if message.role == 'system' -%}
11
+ {%- set system_message.value = message.content -%}
12
+ {%- endfor -%}
13
+ {%- if system_message.value -%}
14
+ {{- system_message.value -}}
15
+ {%- endif -%}
16
+
17
+ {%- for message in messages -%}
18
+ {%- if message.role == "user" -%}
19
+ {{- '<|User|>' -}}
20
+ {%- if message.content is string -%}
21
+ {{- message.content -}}
22
+ {%- elif message.content is iterable and message.content is not string -%}
23
+ {%- for item in message.content if item.type == "text" -%}
24
+ {{- item.text -}}
25
+ {%- endfor -%}
26
+ {%- endif -%}
27
+
28
+ {%- elif message.role == "assistant" -%}
29
+ {%- set thinking_tag = "" -%}
30
+ {%- if enable_thinking is defined -%}
31
+ {%- set thinking_tag = "</think>" if not enable_thinking else "<think>" -%}
32
+ {%- endif -%}
33
+ {{- '<|Assistant|>' + thinking_tag -}}
34
+
35
+ {%- if message.content is string -%}
36
+ {{- message.content -}}
37
+ {%- elif message.content is iterable and message.content is not string -%}
38
+ {%- for item in message.content if item.type == "text" -%}
39
+ {{- item.text -}}
40
+ {%- endfor -%}
41
+ {%- endif -%}
42
+
43
+ {{- '<|end_of_sentence|>' -}}
44
+ {%- endif -%}
45
+ {%- endfor -%}
46
+
47
+ {%- if add_generation_prompt -%}
48
+ {{- '<|Assistant|>' -}}
49
+ {%- if enable_thinking is defined -%}
50
+ {{- "</think>" if not enable_thinking else "<think>" -}}
51
+ {%- endif -%}
52
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "YuanVLChatModel"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_yuanvl.YuanVLChatConfig",
7
+ "AutoModel": "modeling_yuanvl_chat.YuanVLChatModel",
8
+ "AutoModelForCausalLM": "modeling_yuanvl_chat.YuanVLChatModel"
9
+ },
10
+ "bos_token_id": 134960,
11
+ "clip_download_path": "internvit2.5-300M",
12
+ "clip_model_name": "InternViT-448",
13
+ "downsample_ratio": 0.5,
14
+ "dynamic_image_size": true,
15
+ "eos_token_id": 77185,
16
+ "force_image_size": 448,
17
+ "imagemlp_recompute": true,
18
+ "img_context_token_id": 77188,
19
+ "llm_config": {
20
+ "_from_model_config": true,
21
+ "architectures": [
22
+ "YuanForCausalLM"
23
+ ],
24
+ "attention_dropout": 0.0,
25
+ "attention_projection_size": 9216,
26
+ "attn_dropout": 0.0,
27
+ "attn_mask_type": "causal",
28
+ "auto_map": {
29
+ "AutoConfig": "configuration_yuanvl.YuanConfig",
30
+ "AutoModelForCausalLM": "yuanvl.YuanForCausalLM"
31
+ },
32
+ "bos_token": "<BOS>",
33
+ "bos_token_id": 134960,
34
+ "causal_mask": true,
35
+ "dropout": 0,
36
+ "eod_token": "<eod>",
37
+ "eod_token_id": 77185,
38
+ "ffn_hidden_size": 16384,
39
+ "head_dim": 256,
40
+ "hidden_act": "silu",
41
+ "hidden_size": 4608,
42
+ "initializer_range": 0.02,
43
+ "intermediate_size": 16384,
44
+ "lf_conv2d_add_bias": false,
45
+ "lf_conv2d_group": 1,
46
+ "lf_conv2d_num_pad": 0,
47
+ "mask_token_id": 77185,
48
+ "max_position_embeddings": 32768,
49
+ "model_max_length": 32768,
50
+ "model_type": "yuan",
51
+ "moe_config": {
52
+ "ffn_hidden_size": 16384,
53
+ "gated_linear_unit": true,
54
+ "moe_num_experts": 64,
55
+ "moe_top_k": 2,
56
+ "norm_topk_prob": true,
57
+ "per_layer_experts_blocks": [
58
+ 40,
59
+ 48,
60
+ 24,
61
+ 16,
62
+ 24,
63
+ 16,
64
+ 16,
65
+ 24,
66
+ 32,
67
+ 32,
68
+ 24,
69
+ 24,
70
+ 24,
71
+ 40,
72
+ 40,
73
+ 40,
74
+ 48,
75
+ 48,
76
+ 48,
77
+ 48,
78
+ 48,
79
+ 48,
80
+ 48,
81
+ 48,
82
+ 48,
83
+ 48,
84
+ 48,
85
+ 48,
86
+ 48,
87
+ 48,
88
+ 48,
89
+ 48,
90
+ 48,
91
+ 48,
92
+ 48,
93
+ 48,
94
+ 48,
95
+ 48,
96
+ 48,
97
+ 48,
98
+ 48,
99
+ 48,
100
+ 48,
101
+ 48,
102
+ 48,
103
+ 48,
104
+ 48,
105
+ 48,
106
+ 48,
107
+ 48,
108
+ 48,
109
+ 48,
110
+ 48,
111
+ 48,
112
+ 48,
113
+ 48,
114
+ 48,
115
+ 48,
116
+ 48,
117
+ 48,
118
+ 48,
119
+ 48,
120
+ 48,
121
+ 48,
122
+ 48,
123
+ 48,
124
+ 48,
125
+ 48,
126
+ 48,
127
+ 48,
128
+ 48,
129
+ 48,
130
+ 48,
131
+ 48,
132
+ 48,
133
+ 48,
134
+ 48,
135
+ 48,
136
+ 48,
137
+ 48,
138
+ 48,
139
+ 48,
140
+ 48,
141
+ 48,
142
+ 48,
143
+ 40,
144
+ 40,
145
+ 40,
146
+ 40,
147
+ 40,
148
+ 40,
149
+ 40,
150
+ 40,
151
+ 32,
152
+ 32,
153
+ 32,
154
+ 32,
155
+ 32,
156
+ 32,
157
+ 24,
158
+ 24,
159
+ 16,
160
+ 8
161
+ ],
162
+ "router_type": "linear"
163
+ },
164
+ "num_attention_heads": 36,
165
+ "num_hidden_layers": 103,
166
+ "num_key_value_heads": 36,
167
+ "num_query_groups": 36,
168
+ "output_router_logits": false,
169
+ "pad_token_id": 77188,
170
+ "perform_initialization": false,
171
+ "reset_attention_mask": false,
172
+ "reset_position_ids": false,
173
+ "rms_norm_eps": 1e-06,
174
+ "rope_theta": 1000000.0,
175
+ "rotary_base": 1000000,
176
+ "rotary_percent": 1.0,
177
+ "sep_token": "<sep>",
178
+ "sep_token_id": 77187,
179
+ "tie_word_embeddings": false,
180
+ "tokenizer_class": "YuanVLTokenizer",
181
+ "torch_dtype": "bfloat16",
182
+ "use_bias": false,
183
+ "use_cache": true,
184
+ "use_flash_attention": true,
185
+ "use_lf_gate": true,
186
+ "use_lfa_bias": false,
187
+ "use_loss_mask": false,
188
+ "use_moe": true,
189
+ "use_rope_scaling": false,
190
+ "vocab_size": 136064
191
+ },
192
+ "max_dynamic_patch": 9,
193
+ "max_position_embeddings": 32768,
194
+ "min_dynamic_patch": 1,
195
+ "model_max_length": 32768,
196
+ "model_type": "yuanvl",
197
+ "output_attentions": false,
198
+ "pad_token_id": 77185,
199
+ "ps_version": "v2",
200
+ "select_layer": -1,
201
+ "template": "yuan-chat",
202
+ "torch_dtype": "bfloat16",
203
+ "transformers_version": null,
204
+ "use_backbone_lora": 0,
205
+ "use_llm_lora": 0,
206
+ "use_thumbnail": true,
207
+ "vision_config": {
208
+ "architectures": [
209
+ "InternVisionModel"
210
+ ],
211
+ "attention_dropout": 0.0,
212
+ "drop_path_rate": 0.0,
213
+ "dropout": 0.0,
214
+ "hidden_act": "gelu",
215
+ "hidden_size": 1024,
216
+ "image_size": 448,
217
+ "initializer_factor": 1.0,
218
+ "initializer_range": 0.02,
219
+ "intermediate_size": 4096,
220
+ "layer_norm_eps": 1e-06,
221
+ "model_type": "intern_vit_6b",
222
+ "norm_type": "layer_norm",
223
+ "num_attention_heads": 16,
224
+ "num_channels": 3,
225
+ "num_hidden_layers": 24,
226
+ "patch_size": 14,
227
+ "qk_normalization": false,
228
+ "qkv_bias": true,
229
+ "torch_dtype": "bfloat16",
230
+ "use_bfloat16": true,
231
+ "use_flash_attn": true
232
+ }
233
+ }
configuration_intern_vit.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # --------------------------------------------------------
2
+ # InternVL
3
+ # Copyright (c) 2024 OpenGVLab
4
+ # Licensed under The MIT License [see LICENSE for details]
5
+ # --------------------------------------------------------
6
+
7
+ import os
8
+ from typing import Union
9
+
10
+ from transformers.configuration_utils import PretrainedConfig
11
+ from transformers.utils import logging
12
+
13
+ logger = logging.get_logger(__name__)
14
+
15
+
16
+ class InternVisionConfig(PretrainedConfig):
17
+ r"""
18
+ This is the configuration class to store the configuration of a [`InternVisionModel`]. It is used to
19
+ instantiate a vision encoder according to the specified arguments, defining the model architecture.
20
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
21
+ documentation from [`PretrainedConfig`] for more information.
22
+ Args:
23
+ num_channels (`int`, *optional*, defaults to 3):
24
+ Number of color channels in the input images (e.g., 3 for RGB).
25
+ patch_size (`int`, *optional*, defaults to 14):
26
+ The size (resolution) of each patch.
27
+ image_size (`int`, *optional*, defaults to 224):
28
+ The size (resolution) of each image.
29
+ qkv_bias (`bool`, *optional*, defaults to `False`):
30
+ Whether to add a bias to the queries and values in the self-attention layers.
31
+ hidden_size (`int`, *optional*, defaults to 3200):
32
+ Dimensionality of the encoder layers and the pooler layer.
33
+ num_attention_heads (`int`, *optional*, defaults to 25):
34
+ Number of attention heads for each attention layer in the Transformer encoder.
35
+ intermediate_size (`int`, *optional*, defaults to 12800):
36
+ Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
37
+ qk_normalization (`bool`, *optional*, defaults to `True`):
38
+ Whether to normalize the queries and keys in the self-attention layers.
39
+ num_hidden_layers (`int`, *optional*, defaults to 48):
40
+ Number of hidden layers in the Transformer encoder.
41
+ use_flash_attn (`bool`, *optional*, defaults to `True`):
42
+ Whether to use flash attention mechanism.
43
+ hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
44
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
45
+ `"relu"`, `"selu"` and `"gelu_new"` ``"gelu"` are supported.
46
+ layer_norm_eps (`float`, *optional*, defaults to 1e-6):
47
+ The epsilon used by the layer normalization layers.
48
+ dropout (`float`, *optional*, defaults to 0.0):
49
+ The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
50
+ drop_path_rate (`float`, *optional*, defaults to 0.0):
51
+ Dropout rate for stochastic depth.
52
+ attention_dropout (`float`, *optional*, defaults to 0.0):
53
+ The dropout ratio for the attention probabilities.
54
+ initializer_range (`float`, *optional*, defaults to 0.02):
55
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
56
+ initializer_factor (`float`, *optional*, defaults to 0.1):
57
+ A factor for layer scale.
58
+ """
59
+
60
+ model_type = 'intern_vit_6b'
61
+
62
+ def __init__(
63
+ self,
64
+ num_channels=3,
65
+ patch_size=14,
66
+ image_size=224,
67
+ qkv_bias=False,
68
+ hidden_size=3200,
69
+ num_attention_heads=25,
70
+ intermediate_size=12800,
71
+ qk_normalization=True,
72
+ num_hidden_layers=48,
73
+ use_flash_attn=True,
74
+ hidden_act='gelu',
75
+ norm_type='rms_norm',
76
+ layer_norm_eps=1e-6,
77
+ dropout=0.0,
78
+ drop_path_rate=0.0,
79
+ attention_dropout=0.0,
80
+ initializer_range=0.02,
81
+ initializer_factor=0.1,
82
+ **kwargs,
83
+ ):
84
+ super().__init__(**kwargs)
85
+
86
+ self.hidden_size = hidden_size
87
+ self.intermediate_size = intermediate_size
88
+ self.dropout = dropout
89
+ self.drop_path_rate = drop_path_rate
90
+ self.num_hidden_layers = num_hidden_layers
91
+ self.num_attention_heads = num_attention_heads
92
+ self.num_channels = num_channels
93
+ self.patch_size = patch_size
94
+ self.image_size = image_size
95
+ self.initializer_range = initializer_range
96
+ self.initializer_factor = initializer_factor
97
+ self.attention_dropout = attention_dropout
98
+ self.layer_norm_eps = layer_norm_eps
99
+ self.hidden_act = hidden_act
100
+ self.norm_type = norm_type
101
+ self.qkv_bias = qkv_bias
102
+ self.qk_normalization = qk_normalization
103
+ self.use_flash_attn = use_flash_attn
104
+
105
+ @classmethod
106
+ def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> 'PretrainedConfig':
107
+ config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
108
+
109
+ if 'vision_config' in config_dict:
110
+ config_dict = config_dict['vision_config']
111
+
112
+ if 'model_type' in config_dict and hasattr(cls, 'model_type') and config_dict['model_type'] != cls.model_type:
113
+ logger.warning(
114
+ f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
115
+ f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'
116
+ )
117
+
118
+ return cls.from_dict(config_dict, **kwargs)
configuration_yuan.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright YuanLabAi and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Yuan model configuration"""
16
+
17
+ from transformers.configuration_utils import PretrainedConfig
18
+ from transformers.utils import logging
19
+
20
+
21
+ logger = logging.get_logger(__name__)
22
+
23
+
24
+ class YuanConfig(PretrainedConfig):
25
+ r"""
26
+ This is the configuration class to store the configuration of a [`YuanModel`]. It is used to instantiate an
27
+ Yuan model according to the specified arguments, defining the model architecture. Instantiating a configuration
28
+ with the defaults will yield a similar configuration to that of the Yuan--v0.1 or Yuan.
29
+
30
+
31
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
32
+ documentation from [`PretrainedConfig`] for more information.
33
+
34
+
35
+ Args:
36
+ vocab_size (`int`, *optional*, defaults to 32000):
37
+ Vocabulary size of the Yuan model. Defines the number of different tokens that can be represented by the
38
+ `inputs_ids` passed when calling [`YuanModel`]
39
+ hidden_size (`int`, *optional*, defaults to 4096):
40
+ Dimension of the hidden representations.
41
+ intermediate_size (`int`, *optional*, defaults to 14336):
42
+ Dimension of the MLP representations.
43
+ num_hidden_layers (`int`, *optional*, defaults to 32):
44
+ Number of hidden layers in the Transformer encoder.
45
+ num_attention_heads (`int`, *optional*, defaults to 32):
46
+ Number of attention heads for each attention layer in the Transformer encoder.
47
+ num_key_value_heads (`int`, *optional*, defaults to 8):
48
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
49
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
50
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
51
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
52
+ by meanpooling all the original heads within that group. For more details checkout [this
53
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `8`.
54
+ head_dim (`int`, *optional*, defaults to `hidden_size // num_attention_heads`):
55
+ The attention head dimension.
56
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
57
+ The non-linear activation function (function or string) in the decoder.
58
+ max_position_embeddings (`int`, *optional*, defaults to `4096*32`):
59
+ The maximum sequence length that this model might ever be used with. Yuan's sliding window attention
60
+ allows sequence of up to 4096*32 tokens.
61
+ initializer_range (`float`, *optional*, defaults to 0.02):
62
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
63
+ rms_norm_eps (`float`, *optional*, defaults to 1e-05):
64
+ The epsilon used by the rms normalization layers.
65
+ use_cache (`bool`, *optional*, defaults to `True`):
66
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
67
+ relevant if `config.is_decoder=True`.
68
+ pad_token_id (`int`, *optional*):
69
+ The id of the padding token.
70
+ bos_token_id (`int`, *optional*, defaults to 1):
71
+ The id of the "beginning-of-sequence" token.
72
+ eos_token_id (`int`, *optional*, defaults to 2):
73
+ The id of the "end-of-sequence" token.
74
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
75
+ Whether the model's input and output word embeddings should be tied.
76
+ rope_theta (`float`, *optional*, defaults to 1000000.0):
77
+ The base period of the RoPE embeddings.
78
+ attention_dropout (`float`, *optional*, defaults to 0.0):
79
+ The dropout ratio for the attention probabilities.
80
+ """
81
+ model_type = "yuan"
82
+ keys_to_ignore_at_inference = ["past_key_values"]
83
+ base_model_tp_plan = {
84
+ "layers.*.self_attn.q_proj": "colwise",
85
+ "layers.*.self_attn.k_proj": "colwise",
86
+ "layers.*.self_attn.v_proj": "colwise",
87
+ "layers.*.self_attn.o_proj": "rowwise",
88
+ "layers.*.block_sparse_moe.gate": "colwise_rep", # we need to replicate here to correctly route experts
89
+ "layers.*.block_sparse_moe.experts.*.w1": "colwise",
90
+ "layers.*.block_sparse_moe.experts.*.w2": "rowwise",
91
+ "layers.*.block_sparse_moe.experts.*.w3": "colwise",
92
+ }
93
+ base_model_pp_plan = {
94
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
95
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
96
+ "norm": (["hidden_states"], ["hidden_states"]),
97
+ }
98
+
99
+ def __init__(
100
+ self,
101
+ vocab_size=135040,
102
+ hidden_size=2048,
103
+ intermediate_size=8192,
104
+ num_hidden_layers=24,
105
+ num_attention_heads=32,
106
+ num_key_value_heads=16,
107
+ head_dim=None,
108
+ hidden_act="silu",
109
+ max_position_embeddings=4096 * 32,
110
+ model_max_length=8192,
111
+ initializer_range=0.02,
112
+ rms_norm_eps=1e-5,
113
+ use_cache=True,
114
+ pad_token_id=None,
115
+ bos_token_id=1,
116
+ eos_token_id=2,
117
+ tie_word_embeddings=False,
118
+ rope_theta=1e6,
119
+ attention_dropout=0.0,
120
+ attention_projection_size=None,
121
+ perform_initialization=False,
122
+ **kwargs,
123
+ ):
124
+ self.vocab_size = vocab_size
125
+ self.max_position_embeddings = max_position_embeddings
126
+ self.model_max_length = model_max_length
127
+ self.hidden_size = hidden_size
128
+ self.intermediate_size = intermediate_size
129
+ self.num_hidden_layers = num_hidden_layers
130
+ self.num_attention_heads = num_attention_heads
131
+ if num_key_value_heads is None:
132
+ num_key_value_heads = num_attention_heads
133
+
134
+ self.num_key_value_heads = num_key_value_heads
135
+ self.hidden_act = hidden_act
136
+ self.initializer_range = initializer_range
137
+ self.rms_norm_eps = rms_norm_eps
138
+ self.use_cache = use_cache
139
+ self.rope_theta = rope_theta
140
+ self.attention_dropout = attention_dropout
141
+ self.attention_projection_size = attention_projection_size if attention_projection_size is not None else self.hidden_size
142
+ self.head_dim = head_dim if head_dim is not None else self.attention_projection_size // self.num_attention_heads
143
+ self.perform_initialization=perform_initialization
144
+ self.tie_word_embeddings = tie_word_embeddings
145
+ super().__init__(
146
+ pad_token_id=pad_token_id,
147
+ bos_token_id=bos_token_id,
148
+ eos_token_id=eos_token_id,
149
+ #tie_word_embeddings=tie_word_embeddings,
150
+ **kwargs,
151
+ )
152
+
153
+
configuration_yuanvl.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # --------------------------------------------------------
2
+ # InternVL
3
+ # Copyright (c) 2024 OpenGVLab
4
+ # Licensed under The MIT License [see LICENSE for details]
5
+ # --------------------------------------------------------
6
+
7
+ import copy
8
+
9
+ from transformers import AutoConfig, LlamaConfig
10
+ from transformers.configuration_utils import PretrainedConfig
11
+ from transformers.utils import logging
12
+ from transformers.models.auto import CONFIG_MAPPING
13
+
14
+ from .configuration_intern_vit import InternVisionConfig
15
+ from .configuration_yuan import YuanConfig
16
+
17
+ logger = logging.get_logger(__name__)
18
+
19
+
20
+ class YuanVLChatConfig(PretrainedConfig):
21
+ model_type = 'yuanvl'
22
+ is_composition = True
23
+ sub_configs = {"llm_config": YuanConfig, "vision_config": InternVisionConfig} # 声明子配置类型
24
+
25
+ def __init__(
26
+ self,
27
+ vision_config=None,
28
+ llm_config=None,
29
+ use_backbone_lora=0,
30
+ use_llm_lora=0,
31
+ select_layer=-1,
32
+ force_image_size=None,
33
+ downsample_ratio=0.5,
34
+ template=None,
35
+ dynamic_image_size=False,
36
+ use_thumbnail=False,
37
+ tie_word_embeddings=False,
38
+ ps_version='v1',
39
+ min_dynamic_patch=1,
40
+ max_dynamic_patch=6,
41
+ img_context_token_id=77188,** kwargs):
42
+
43
+ # 初始化视觉子配置(确保为InternVisionConfig实例)
44
+ if vision_config is None:
45
+ # 输入为None时,直接实例化InternVisionConfig(而非字典)
46
+ self.vision_config = InternVisionConfig(architectures=['InternVisionModel'])
47
+ logger.info('vision_config is None. Initializing InternVisionConfig with default values.')
48
+ elif isinstance(vision_config, dict):
49
+ # 输入为字典时,用from_dict实例化
50
+ self.vision_config = InternVisionConfig.from_dict(vision_config)
51
+ else:
52
+ # 输入已为实例时直接使用
53
+ self.vision_config = vision_config
54
+
55
+ # 初始化LLM子配置(确保为YuanConfig实例)
56
+ if llm_config is None:
57
+ # 输入为None时,直接实例化YuanConfig(而非字典)
58
+ self.llm_config = YuanConfig(architectures=['YuanForCausalLM'])
59
+ self.llm_config.tie_word_embeddings = tie_word_embeddings # 显式设置属性
60
+ logger.info('llm_config is None. Initializing YuanConfig with default values.')
61
+ elif isinstance(llm_config, dict):
62
+ # 输入为字典时,用from_dict实例化
63
+ self.llm_config = YuanConfig.from_dict(llm_config)
64
+ self.llm_config.tie_word_embeddings = tie_word_embeddings
65
+ else:
66
+ # 输入已为实例时直接使用,并同步tie_word_embeddings
67
+ self.llm_config = llm_config
68
+ self.llm_config.tie_word_embeddings = tie_word_embeddings
69
+
70
+ # 其他属性初始化
71
+ self.use_backbone_lora = use_backbone_lora
72
+ self.use_llm_lora = use_llm_lora
73
+ self.select_layer = select_layer
74
+ self.force_image_size = force_image_size
75
+ self.downsample_ratio = downsample_ratio
76
+ self.template = template
77
+ self.dynamic_image_size = dynamic_image_size
78
+ self.use_thumbnail = use_thumbnail
79
+ self.ps_version = ps_version
80
+ self.min_dynamic_patch = min_dynamic_patch
81
+ self.max_dynamic_patch = max_dynamic_patch
82
+ self.img_context_token_id = img_context_token_id
83
+ self.tie_word_embeddings = self.llm_config.tie_word_embeddings # 同步LLM的配置
84
+
85
+ # 日志输出
86
+ logger.info(f'vision_select_layer: {self.select_layer}')
87
+ logger.info(f'ps_version: {self.ps_version}')
88
+ logger.info(f'min_dynamic_patch: {self.min_dynamic_patch}')
89
+ logger.info(f'max_dynamic_patch: {self.max_dynamic_patch}')
90
+
91
+ super().__init__(**kwargs)
92
+
93
+ @classmethod
94
+ def from_sub_model_configs(
95
+ cls,
96
+ vision_config: InternVisionConfig,
97
+ llm_config: YuanConfig,
98
+ **kwargs,
99
+ ):
100
+ r"""
101
+ Instantiate a [`YuanVLChatConfig`] (or a derived class) from bark sub-models configuration.
102
+
103
+ Returns:
104
+ [``YuanVLChatConfig``]: An instance of a configuration object
105
+ """
106
+ return cls(
107
+ vision_config=vision_config.to_dict(),
108
+ llm_config=llm_config.to_dict(),
109
+ **kwargs,
110
+ )
111
+
112
+ def to_dict(self):
113
+ """
114
+ Serializes this instance to a Python dictionary. Override the default [`~PretrainedConfig.to_dict`].
115
+ Returns:
116
+ `Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
117
+ """
118
+ output = copy.deepcopy(self.__dict__)
119
+ output['vision_config'] = self.vision_config.to_dict()
120
+ output['llm_config'] = self.llm_config.to_dict()
121
+ output['model_type'] = self.__class__.model_type
122
+ output['use_backbone_lora'] = self.use_backbone_lora
123
+ output['use_llm_lora'] = self.use_llm_lora
124
+ output['select_layer'] = self.select_layer
125
+ output['force_image_size'] = self.force_image_size
126
+ output['downsample_ratio'] = self.downsample_ratio
127
+ output['template'] = self.template
128
+ output['dynamic_image_size'] = self.dynamic_image_size
129
+ output['use_thumbnail'] = self.use_thumbnail
130
+ output['ps_version'] = self.ps_version
131
+ output['min_dynamic_patch'] = self.min_dynamic_patch
132
+ output['max_dynamic_patch'] = self.max_dynamic_patch
133
+
134
+ return output
conversation.py ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Conversation prompt templates.
3
+ We kindly request that you import fastchat instead of copying this file if you wish to use it.
4
+ If you have changes in mind, please contribute back so the community can benefit collectively and continue to maintain these valuable templates.
5
+ Modified from https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py
6
+ """
7
+
8
+ import dataclasses
9
+ from enum import IntEnum, auto
10
+ from typing import Dict, List, Tuple, Union
11
+
12
+
13
+ class SeparatorStyle(IntEnum):
14
+ """Separator styles."""
15
+
16
+ ADD_COLON_SINGLE = auto()
17
+ ADD_COLON_TWO = auto()
18
+ ADD_COLON_SPACE_SINGLE = auto()
19
+ NO_COLON_SINGLE = auto()
20
+ NO_COLON_TWO = auto()
21
+ ADD_NEW_LINE_SINGLE = auto()
22
+ LLAMA2 = auto()
23
+ CHATGLM = auto()
24
+ CHATML = auto()
25
+ CHATINTERN = auto()
26
+ DOLLY = auto()
27
+ RWKV = auto()
28
+ PHOENIX = auto()
29
+ ROBIN = auto()
30
+ FALCON_CHAT = auto()
31
+ CHATGLM3 = auto()
32
+ INTERNVL_ZH = auto()
33
+ MPT = auto()
34
+
35
+
36
+ @dataclasses.dataclass
37
+ class Conversation:
38
+ """A class that manages prompt templates and keeps all conversation history."""
39
+
40
+ # The name of this template
41
+ name: str
42
+ # The template of the system prompt
43
+ system_template: str = '{system_message}'
44
+ # The system message
45
+ system_message: str = ''
46
+ # The names of two roles
47
+ roles: Tuple[str] = ('USER', 'ASSISTANT')
48
+ # All messages. Each item is (role, message).
49
+ messages: List[List[str]] = ()
50
+ # The number of few shot examples
51
+ offset: int = 0
52
+ # The separator style and configurations
53
+ sep_style: SeparatorStyle = SeparatorStyle.ADD_COLON_SINGLE
54
+ sep: str = '\n'
55
+ sep2: str = None
56
+ # Stop criteria (the default one is EOS token)
57
+ stop_str: Union[str, List[str]] = None
58
+ # Stops generation if meeting any token in this list
59
+ stop_token_ids: List[int] = None
60
+
61
+ def get_prompt(self) -> str:
62
+ """Get the prompt for generation."""
63
+ system_prompt = self.system_template.format(system_message=self.system_message)
64
+ if self.sep_style == SeparatorStyle.ADD_COLON_SINGLE:
65
+ ret = system_prompt + self.sep
66
+ for role, message in self.messages:
67
+ if message:
68
+ ret += role + ': ' + message + self.sep
69
+ else:
70
+ ret += role + ':'
71
+ return ret
72
+ elif self.sep_style == SeparatorStyle.ADD_COLON_TWO:
73
+ seps = [self.sep, self.sep2]
74
+ ret = system_prompt + seps[0]
75
+ for i, (role, message) in enumerate(self.messages):
76
+ if message:
77
+ ret += role + ': ' + message + seps[i % 2]
78
+ else:
79
+ ret += role + ':'
80
+ return ret
81
+ elif self.sep_style == SeparatorStyle.ADD_COLON_SPACE_SINGLE:
82
+ ret = system_prompt + self.sep
83
+ for role, message in self.messages:
84
+ if message:
85
+ ret += role + ': ' + message + self.sep
86
+ else:
87
+ ret += role + ': ' # must be end with a space
88
+ return ret
89
+ elif self.sep_style == SeparatorStyle.ADD_NEW_LINE_SINGLE:
90
+ ret = '' if system_prompt == '' else system_prompt + self.sep
91
+ for role, message in self.messages:
92
+ if message:
93
+ ret += role + '\n' + message + self.sep
94
+ else:
95
+ ret += role + '\n'
96
+ return ret
97
+ elif self.sep_style == SeparatorStyle.NO_COLON_SINGLE:
98
+ ret = system_prompt
99
+ for role, message in self.messages:
100
+ if message:
101
+ ret += role + message + self.sep
102
+ else:
103
+ ret += role
104
+ return ret
105
+ elif self.sep_style == SeparatorStyle.NO_COLON_TWO:
106
+ seps = [self.sep, self.sep2]
107
+ ret = system_prompt
108
+ for i, (role, message) in enumerate(self.messages):
109
+ if message:
110
+ ret += role + message + seps[i % 2]
111
+ else:
112
+ ret += role
113
+ return ret
114
+ elif self.sep_style == SeparatorStyle.RWKV:
115
+ ret = system_prompt
116
+ for i, (role, message) in enumerate(self.messages):
117
+ if message:
118
+ ret += (
119
+ role
120
+ + ': '
121
+ + message.replace('\r\n', '\n').replace('\n\n', '\n')
122
+ )
123
+ ret += '\n\n'
124
+ else:
125
+ ret += role + ':'
126
+ return ret
127
+ elif self.sep_style == SeparatorStyle.LLAMA2:
128
+ seps = [self.sep, self.sep2]
129
+ if self.system_message:
130
+ ret = system_prompt
131
+ else:
132
+ ret = '[INST] '
133
+ for i, (role, message) in enumerate(self.messages):
134
+ tag = self.roles[i % 2]
135
+ if message:
136
+ if i == 0:
137
+ ret += message + ' '
138
+ else:
139
+ ret += tag + ' ' + message + seps[i % 2]
140
+ else:
141
+ ret += tag
142
+ return ret
143
+ elif self.sep_style == SeparatorStyle.CHATGLM:
144
+ # source: https://huggingface.co/THUDM/chatglm-6b/blob/1d240ba371910e9282298d4592532d7f0f3e9f3e/modeling_chatglm.py#L1302-L1308
145
+ # source2: https://huggingface.co/THUDM/chatglm2-6b/blob/e186c891cf64310ac66ef10a87e6635fa6c2a579/modeling_chatglm.py#L926
146
+ round_add_n = 1 if self.name == 'chatglm2' else 0
147
+ if system_prompt:
148
+ ret = system_prompt + self.sep
149
+ else:
150
+ ret = ''
151
+
152
+ for i, (role, message) in enumerate(self.messages):
153
+ if i % 2 == 0:
154
+ ret += f'[Round {i//2 + round_add_n}]{self.sep}'
155
+
156
+ if message:
157
+ ret += f'{role}:{message}{self.sep}'
158
+ else:
159
+ ret += f'{role}:'
160
+ return ret
161
+ elif self.sep_style == SeparatorStyle.CHATML:
162
+ ret = '' if system_prompt == '' else system_prompt + self.sep + '\n'
163
+ for role, message in self.messages:
164
+ if message:
165
+ ret += role + '\n' + message + self.sep + '\n'
166
+ else:
167
+ ret += role + '\n'
168
+ return ret
169
+ elif self.sep_style == SeparatorStyle.CHATGLM3:
170
+ ret = ''
171
+ if self.system_message:
172
+ ret += system_prompt
173
+ for role, message in self.messages:
174
+ if message:
175
+ ret += role + '\n' + ' ' + message
176
+ else:
177
+ ret += role
178
+ return ret
179
+ elif self.sep_style == SeparatorStyle.CHATINTERN:
180
+ # source: https://huggingface.co/internlm/internlm-chat-7b-8k/blob/bd546fa984b4b0b86958f56bf37f94aa75ab8831/modeling_internlm.py#L771
181
+ seps = [self.sep, self.sep2]
182
+ ret = system_prompt
183
+ for i, (role, message) in enumerate(self.messages):
184
+ # if i % 2 == 0:
185
+ # ret += "<s>"
186
+ if message:
187
+ ret += role + ':' + message + seps[i % 2] + '\n'
188
+ else:
189
+ ret += role + ':'
190
+ return ret
191
+ elif self.sep_style == SeparatorStyle.DOLLY:
192
+ seps = [self.sep, self.sep2]
193
+ ret = system_prompt
194
+ for i, (role, message) in enumerate(self.messages):
195
+ if message:
196
+ ret += role + ':\n' + message + seps[i % 2]
197
+ if i % 2 == 1:
198
+ ret += '\n\n'
199
+ else:
200
+ ret += role + ':\n'
201
+ return ret
202
+ elif self.sep_style == SeparatorStyle.PHOENIX:
203
+ ret = system_prompt
204
+ for role, message in self.messages:
205
+ if message:
206
+ ret += role + ': ' + '<s>' + message + '</s>'
207
+ else:
208
+ ret += role + ': ' + '<s>'
209
+ return ret
210
+ elif self.sep_style == SeparatorStyle.ROBIN:
211
+ ret = system_prompt + self.sep
212
+ for role, message in self.messages:
213
+ if message:
214
+ ret += role + ':\n' + message + self.sep
215
+ else:
216
+ ret += role + ':\n'
217
+ return ret
218
+ elif self.sep_style == SeparatorStyle.FALCON_CHAT:
219
+ ret = ''
220
+ if self.system_message:
221
+ ret += system_prompt + self.sep
222
+ for role, message in self.messages:
223
+ if message:
224
+ ret += role + ': ' + message + self.sep
225
+ else:
226
+ ret += role + ':'
227
+
228
+ return ret
229
+ elif self.sep_style == SeparatorStyle.INTERNVL_ZH:
230
+ seps = [self.sep, self.sep2]
231
+ ret = self.system_message + seps[0]
232
+ for i, (role, message) in enumerate(self.messages):
233
+ if message:
234
+ ret += role + ': ' + message + seps[i % 2]
235
+ else:
236
+ ret += role + ':'
237
+ return ret
238
+ elif self.sep_style == SeparatorStyle.MPT:
239
+ ret = system_prompt + self.sep
240
+ for role, message in self.messages:
241
+ if message:
242
+ if type(message) is tuple:
243
+ message, _, _ = message
244
+ ret += role + message + self.sep
245
+ else:
246
+ ret += role
247
+ return ret
248
+ else:
249
+ raise ValueError(f'Invalid style: {self.sep_style}')
250
+
251
+ def set_system_message(self, system_message: str):
252
+ """Set the system message."""
253
+ self.system_message = system_message
254
+
255
+ def append_message(self, role: str, message: str):
256
+ """Append a new message."""
257
+ self.messages.append([role, message])
258
+
259
+ def update_last_message(self, message: str):
260
+ """Update the last output.
261
+ The last message is typically set to be None when constructing the prompt,
262
+ so we need to update it in-place after getting the response from a model.
263
+ """
264
+ self.messages[-1][1] = message
265
+
266
+ def to_gradio_chatbot(self):
267
+ """Convert the conversation to gradio chatbot format."""
268
+ ret = []
269
+ for i, (role, msg) in enumerate(self.messages[self.offset :]):
270
+ if i % 2 == 0:
271
+ ret.append([msg, None])
272
+ else:
273
+ ret[-1][-1] = msg
274
+ return ret
275
+
276
+ def to_openai_api_messages(self):
277
+ """Convert the conversation to OpenAI chat completion format."""
278
+ ret = [{'role': 'system', 'content': self.system_message}]
279
+
280
+ for i, (_, msg) in enumerate(self.messages[self.offset :]):
281
+ if i % 2 == 0:
282
+ ret.append({'role': 'user', 'content': msg})
283
+ else:
284
+ if msg is not None:
285
+ ret.append({'role': 'assistant', 'content': msg})
286
+ return ret
287
+
288
+ def copy(self):
289
+ return Conversation(
290
+ name=self.name,
291
+ system_template=self.system_template,
292
+ system_message=self.system_message,
293
+ roles=self.roles,
294
+ messages=[[x, y] for x, y in self.messages],
295
+ offset=self.offset,
296
+ sep_style=self.sep_style,
297
+ sep=self.sep,
298
+ sep2=self.sep2,
299
+ stop_str=self.stop_str,
300
+ stop_token_ids=self.stop_token_ids,
301
+ )
302
+
303
+ def dict(self):
304
+ return {
305
+ 'template_name': self.name,
306
+ 'system_message': self.system_message,
307
+ 'roles': self.roles,
308
+ 'messages': self.messages,
309
+ 'offset': self.offset,
310
+ }
311
+
312
+
313
+ # A global registry for all conversation templates
314
+ conv_templates: Dict[str, Conversation] = {}
315
+
316
+
317
+ def register_conv_template(template: Conversation, override: bool = False):
318
+ """Register a new conversation template."""
319
+ if not override:
320
+ assert (
321
+ template.name not in conv_templates
322
+ ), f'{template.name} has been registered.'
323
+
324
+ conv_templates[template.name] = template
325
+
326
+
327
+ def get_conv_template(name: str) -> Conversation:
328
+ """Get a conversation template."""
329
+ return conv_templates[name].copy()
330
+
331
+
332
+ # Both Hermes-2 and internlm2-chat are chatml-format conversation templates. The difference
333
+ # is that during training, the preprocessing function for the Hermes-2 template doesn't add
334
+ # <s> at the beginning of the tokenized sequence, while the internlm2-chat template does.
335
+ # Therefore, they are completely equivalent during inference.
336
+ register_conv_template(
337
+ Conversation(
338
+ name='Hermes-2',
339
+ system_template='<|im_start|>system\n{system_message}',
340
+ # note: The new system prompt was not used here to avoid changes in benchmark performance.
341
+ # system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。',
342
+ system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
343
+ roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
344
+ sep_style=SeparatorStyle.MPT,
345
+ sep='<|im_end|>',
346
+ stop_str='<|endoftext|>',
347
+ )
348
+ )
349
+
350
+
351
+ register_conv_template(
352
+ Conversation(
353
+ name='internlm2-chat',
354
+ system_template='<|im_start|>system\n{system_message}',
355
+ # note: The new system prompt was not used here to avoid changes in benchmark performance.
356
+ # system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。',
357
+ system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
358
+ roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
359
+ sep_style=SeparatorStyle.MPT,
360
+ sep='<|im_end|>',
361
+ )
362
+ )
363
+
364
+
365
+ register_conv_template(
366
+ Conversation(
367
+ name='phi3-chat',
368
+ system_template='<|system|>\n{system_message}',
369
+ # note: The new system prompt was not used here to avoid changes in benchmark performance.
370
+ # system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。',
371
+ system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
372
+ roles=('<|user|>\n', '<|assistant|>\n'),
373
+ sep_style=SeparatorStyle.MPT,
374
+ sep='<|end|>',
375
+ )
376
+ )
377
+
378
+
379
+ register_conv_template(
380
+ Conversation(
381
+ name='internvl2_5',
382
+ system_template='<|im_start|>system\n{system_message}',
383
+ system_message='你是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。',
384
+ roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
385
+ sep_style=SeparatorStyle.MPT,
386
+ sep='<|im_end|>\n',
387
+ )
388
+ )
389
+
390
+ register_conv_template(
391
+ Conversation(
392
+ name='yuan-chat',
393
+ system_template='<|im_start|>system\n{system_message}',
394
+ system_message='你是YuanLabAi-多模态模型,英文名是YuanVL,是由YuanLabAi开发的多模态大语言模型。',
395
+ roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
396
+ sep_style=SeparatorStyle.MPT,
397
+ sep='<|im_end|>\n',
398
+ )
399
+ )
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff