CISCai commited on
Commit
6ca68af
·
verified ·
1 Parent(s): 0a3d8c5

Ensure token names are listed for _token_id even when tokens metadata comes afterwards

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -37,7 +37,7 @@ def human_readable_metadata(
37
  key: str,
38
  typ: int,
39
  val: Any,
40
- ) -> tuple[str, Any]:
41
  typ = GGUFValueType(typ).name
42
 
43
  if typ == 'ARRAY':
@@ -358,8 +358,14 @@ with gr.Blocks(
358
  meta.var['repo_file'] = repo_file
359
  meta.var['branch'] = branch
360
 
 
361
  for k, v in progress.tqdm(metadata, desc = 'Reading metadata...', total = num_metadata, unit = f' of {num_metadata} metadata keys...'):
362
- m.append([*human_readable_metadata(meta, k, v.type, v.value)])
 
 
 
 
 
363
  meta.key[k] = (v.type, v.value)
364
 
365
  # FIXME
@@ -368,6 +374,9 @@ with gr.Blocks(
368
  # m,
369
  # ),
370
  # }
 
 
 
371
  except Exception as e:
372
  raise gr.Error(e)
373
 
 
37
  key: str,
38
  typ: int,
39
  val: Any,
40
+ ) -> tuple[str, int | str, Any]:
41
  typ = GGUFValueType(typ).name
42
 
43
  if typ == 'ARRAY':
 
358
  meta.var['repo_file'] = repo_file
359
  meta.var['branch'] = branch
360
 
361
+ deferred_updates = []
362
  for k, v in progress.tqdm(metadata, desc = 'Reading metadata...', total = num_metadata, unit = f' of {num_metadata} metadata keys...'):
363
+ human = [*human_readable_metadata(meta, k, v.type, v.value)]
364
+
365
+ if k.endswith('_token_id') and 'tokenizer.ggml.tokens' not in meta.key:
366
+ deferred_updates.append(((k, v.type, v.value), human))
367
+
368
+ m.append(human)
369
  meta.key[k] = (v.type, v.value)
370
 
371
  # FIXME
 
374
  # m,
375
  # ),
376
  # }
377
+
378
+ for data, human in deferred_updates:
379
+ human[:] = human_readable_metadata(meta, *data)
380
  except Exception as e:
381
  raise gr.Error(e)
382