Skip to content

Commit

Permalink
gguf(python): Fix special vocab handling when id < 0 (ggerganov#2984)
Browse files Browse the repository at this point in the history
  • Loading branch information
KerfuffleV2 authored Sep 3, 2023
1 parent b7f2aa9 commit 6519e9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gguf-py/gguf/gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def try_load_from_tokenizer_json(self, path: Path) -> bool:
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
Expand All @@ -814,7 +814,7 @@ def try_load_from_config_json(self, path: Path) -> bool:
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

Expand Down
2 changes: 1 addition & 1 deletion gguf-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
packages = [
Expand Down

0 comments on commit 6519e9c

Please sign in to comment.