File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type {
5
5
BaseGGUFMetadata ,
6
6
BloomMetadata ,
7
7
FalconMetadata ,
8
+ GemmaMetadata ,
8
9
GGUFMetadata ,
9
10
GPT2Metadata ,
10
11
GPTJMetadata ,
@@ -16,6 +17,7 @@ import type {
16
17
import {
17
18
bloomMetadataSchema ,
18
19
falconMetadataSchema ,
20
+ gemmaMetadataSchema ,
19
21
gPT2MetadataSchema ,
20
22
gPTJMetadataSchema ,
21
23
gPTNeoXMetadataSchema ,
@@ -263,6 +265,7 @@ const isValidArchitecture = (
263
265
'gpt2' ,
264
266
'bloom' ,
265
267
'falcon' ,
268
+ 'gemma' ,
266
269
'rwkv' ,
267
270
] . includes ( architecture )
268
271
}
@@ -317,6 +320,11 @@ const validateMetadata = (
317
320
if ( res . success === false ) return { error : res . error }
318
321
return { metadata : res . data }
319
322
}
323
+ case 'gemma' : {
324
+ const res = gemmaMetadataSchema . safeParse ( metadata )
325
+ if ( res . success === false ) return { error : res . error }
326
+ return { metadata : res . data }
327
+ }
320
328
case 'rwkv' : {
321
329
const res = rWKVMetadataSchema . safeParse ( metadata )
322
330
if ( res . success === false ) return { error : res . error }
@@ -604,6 +612,12 @@ export const isFalconMetadata = (
604
612
return metadata . general . architecture === 'falcon'
605
613
}
606
614
615
+ export const isGemmaMetadata = (
616
+ metadata : GGUFMetadata ,
617
+ ) : metadata is GemmaMetadata => {
618
+ return metadata . general . architecture === 'gemma'
619
+ }
620
+
607
621
export const isRWKVMetadata = (
608
622
metadata : GGUFMetadata ,
609
623
) : metadata is RWKVMetadata => {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export type ArchitectureType =
10
10
| 'gpt2'
11
11
| 'bloom'
12
12
| 'falcon'
13
+ | 'gemma'
13
14
| 'rwkv'
14
15
15
16
export type BaseGGUFMetadata = {
@@ -369,6 +370,37 @@ export type RWKVMetadata = {
369
370
}
370
371
}
371
372
373
+ export type GemmaMetadata = {
374
+ gemma : {
375
+ attention : {
376
+ /** Also known as n_head. Number of attention heads. */
377
+ head_count : number
378
+ /** The number of heads per group used in Grouped-Query-Attention. If not
379
+ * present or if present and equal to [llm].attention.head_count, the model
380
+ * does not use GQA. */
381
+ head_count_kv ?: number
382
+ /** Layer RMS normalization epsilon. */
383
+ layer_norm_rms_epsilon : number
384
+ }
385
+ block_count : number
386
+ /** Length of the context used during training or fine-tuning. RWKV is able
387
+ * to handle larger context than this limit, but the output quality
388
+ * may suffer. */
389
+ context_length : number
390
+ /** Also known as n_embd. Embedding layer size. */
391
+ embedding_length : number
392
+ /** Also known as n_ff. The length of the feedforward layer. */
393
+ feed_forward_length : number
394
+ }
395
+ general : BaseGGUFMetadata & {
396
+ /**
397
+ * describes what architecture this model implements. All lowercase ASCII,
398
+ * with only [a-z0-9]+ characters allowed.
399
+ **/
400
+ architecture : 'gemma'
401
+ }
402
+ }
403
+
372
404
export type WhisperMetadata = {
373
405
general : BaseGGUFMetadata & {
374
406
/**
@@ -416,5 +448,6 @@ export type GGUFMetadata =
416
448
| GPT2Metadata
417
449
| BloomMetadata
418
450
| FalconMetadata
451
+ | GemmaMetadata
419
452
| RWKVMetadata
420
453
| WhisperMetadata
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export const architectureTypeSchema = z.union([
9
9
z . literal ( 'gpt2' ) ,
10
10
z . literal ( 'bloom' ) ,
11
11
z . literal ( 'falcon' ) ,
12
+ z . literal ( 'gemma' ) ,
12
13
z . literal ( 'rwkv' ) ,
13
14
] )
14
15
@@ -218,6 +219,25 @@ export const rWKVMetadataSchema = z.object({
218
219
} ) ,
219
220
} )
220
221
222
+ export const gemmaMetadataSchema = z . object ( {
223
+ gemma : z . object ( {
224
+ attention : z . object ( {
225
+ head_count : z . number ( ) ,
226
+ head_count_kv : z . number ( ) . optional ( ) ,
227
+ layer_norm_rms_epsilon : z . number ( ) ,
228
+ } ) ,
229
+ block_count : z . number ( ) ,
230
+ context_length : z . number ( ) ,
231
+ embedding_length : z . number ( ) ,
232
+ feed_forward_length : z . number ( ) ,
233
+ } ) ,
234
+ general : baseGGUFMetadataSchema . and (
235
+ z . object ( {
236
+ architecture : z . literal ( 'gemma' ) ,
237
+ } ) ,
238
+ ) ,
239
+ } )
240
+
221
241
export const whisperMetadataSchema = z . object ( {
222
242
general : baseGGUFMetadataSchema . and (
223
243
z . object ( {
@@ -253,6 +273,7 @@ export const gGUFMetadataSchema = z.union([
253
273
gPT2MetadataSchema ,
254
274
bloomMetadataSchema ,
255
275
falconMetadataSchema ,
276
+ gemmaMetadataSchema ,
256
277
rWKVMetadataSchema ,
257
278
whisperMetadataSchema ,
258
279
] )
You can’t perform that action at this time.
0 commit comments