summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Van Bortel <jared@nomic.ai>2023-12-17 10:45:46 -0500
committerGitHub <noreply@github.com>2023-12-17 10:45:46 -0500
commitf7f468a97dceec2f8fe8b1ed7a2091083446ebc7 (patch)
tree8b2ba17a8946234e5f7add67aecb5ad21d657006
parent919c40660fd27157b391b5832d2a577d5afef4cb (diff)
gguf-py : fail fast on nonsensical special token IDs (#4489)
-rw-r--r--gguf-py/gguf/vocab.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/gguf-py/gguf/vocab.py b/gguf-py/gguf/vocab.py
index de3e5edb..76924d8f 100644
--- a/gguf-py/gguf/vocab.py
+++ b/gguf-py/gguf/vocab.py
@@ -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