]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
gguf(python): Fix special vocab handling when id < 0 (#2984)
authorKerfuffle <redacted>
Sun, 3 Sep 2023 10:38:43 +0000 (04:38 -0600)
committerGitHub <redacted>
Sun, 3 Sep 2023 10:38:43 +0000 (04:38 -0600)
gguf-py/gguf/gguf.py
gguf-py/pyproject.toml

index b1bc4205bb8b0dfaea1aeb52669a04c4d32312f0..d377cd56d88e792ddc61a7b5ded1e1c14af065cc 100644 (file)
@@ -801,7 +801,7 @@ class SpecialVocab:
             else:
                 continue
             for maybe_token_id in (atok.get('id') for atok in added_tokens if atok.get('content') == tc_content):
-                if isinstance(maybe_token_id, int):
+                if isinstance(maybe_token_id, int) and maybe_token_id >= 0:
                     self.special_token_ids[typ] = maybe_token_id
                 break
         return True
@@ -814,7 +814,7 @@ class SpecialVocab:
             config = json.load(f)
         for typ in self.special_token_types:
             maybe_token_id = config.get(f'{typ}_token_id')
-            if isinstance(maybe_token_id, int):
+            if isinstance(maybe_token_id, int) and maybe_token_id >= 0:
                 self.special_token_ids[typ] = maybe_token_id
         return True
 
index 26f792b14c46a2981fe4fb84134f449d8255a0ea..8da60de1b3f3f806fcc65e3cfaf00313abc837e8 100644 (file)
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "gguf"
-version = "0.3.1"
+version = "0.3.2"
 description = "Write ML models in GGUF for GGML"
 authors = ["GGML <ggml@ggml.ai>"]
 packages = [