]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Use `tokenizer.vocab_size()` instead of hardcoding 32000 in convert-pth-to-ggml.py...
authorRonsor <redacted>
Wed, 15 Mar 2023 19:37:50 +0000 (12:37 -0700)
committerGitHub <redacted>
Wed, 15 Mar 2023 19:37:50 +0000 (21:37 +0200)
There are ways that special tokens or other new tokens could be added to the tokenizer; therefore it's probably best not to assume the vocabulary is only 32000 tokens.

convert-pth-to-ggml.py

index d2557500af0948a3f2d3a6f3cfd9dad13082cab0..5c36e9c09dc0d5c039aa08a9133b129f7f1e1eb4 100644 (file)
@@ -99,7 +99,7 @@ for p in range(n_parts):
     fout.write(struct.pack("i", ftype))
 
     # Is this correct??
-    for i in range(32000):
+    for i in range(tokenizer.vocab_size()):
         if tokenizer.is_unknown(i):
             # "<unk>" token (translated as ??)
             text = " \u2047 ".encode("utf-8")