Skip to content

Commit f7f468a

Browse files
authored
gguf-py : fail fast on nonsensical special token IDs (#4489)
1 parent 919c406 commit f7f468a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gguf-py/gguf/vocab.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ def _try_load_merges_txt(self, path: Path) -> bool:
109109
return True
110110

111111
def _set_special_token(self, typ: str, tid: Any) -> None:
112-
if not isinstance(tid, int) or tid < 0:
112+
if not isinstance(tid, int):
113113
return
114+
if tid < 0:
115+
raise ValueError(f'invalid value for special token type {typ}: {tid}')
114116
if self.n_vocab is None or tid < self.n_vocab:
115117
if typ in self.special_token_ids:
116118
return

0 commit comments

Comments
 (0)