File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1111from pathlib import Path
1212from typing import TYPE_CHECKING , Any
1313import itertools
14- import gguf
1514import numpy as np
1615import torch
1716from sentencepiece import SentencePieceProcessor # type: ignore[import]
1817
18+ if 'NO_LOCAL_GGUF' not in os .environ :
19+ sys .path .insert (1 , str (Path (__file__ ).parent / 'gguf-py' / 'gguf' ))
20+ import gguf
21+
1922
2023if TYPE_CHECKING :
2124 from typing import TypeAlias
@@ -174,8 +177,11 @@ def parse_args() -> argparse.Namespace:
174177print ("gguf: get sentencepiece tokenizer vocab, scores and token types" )
175178
176179tokenizer = SentencePieceProcessor (str (tokenizer_model_file ))
180+ vocab_size = hparams .get ('vocab_size' )
181+ if vocab_size is None :
182+ vocab_size = tokenizer .vocab_size ()
177183
178- for i in range (tokenizer . vocab_size () ):
184+ for i in range (vocab_size ):
179185 text : bytes
180186 score : float
181187
You can’t perform that action at this time.
0 commit comments