Skip to content

Commit

Permalink
gguf-py : fail fast on nonsensical special token IDs (ggerganov#4489)
Browse files Browse the repository at this point in the history
  • Loading branch information
cebtenzzre authored Dec 17, 2023
1 parent 919c406 commit f7f468a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gguf-py/gguf/vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ def _try_load_merges_txt(self, path: Path) -> bool:
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
Expand Down

0 comments on commit f7f468a

Please sign in to comment.