]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
gguf-py : fail fast on nonsensical special token IDs (#4489)
authorJared Van Bortel <redacted>
Sun, 17 Dec 2023 15:45:46 +0000 (10:45 -0500)
committerGitHub <redacted>
Sun, 17 Dec 2023 15:45:46 +0000 (10:45 -0500)
gguf-py/gguf/vocab.py

index de3e5edb557d7b483ccb76da975a2c71e30700b9..76924d8f29f5e220cebcb6caaf862f35227188ae 100644 (file)
@@ -109,8 +109,10 @@ class SpecialVocab:
         return True
 
     def _set_special_token(self, typ: str, tid: Any) -> None:
-        if not isinstance(tid, int) or tid < 0:
+        if not isinstance(tid, int):
             return
+        if tid < 0:
+            raise ValueError(f'invalid value for special token type {typ}: {tid}')
         if self.n_vocab is None or tid < self.n_vocab:
             if typ in self.special_token_ids:
                 return