Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions tinybpe/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,11 @@ def _load_registry() -> tuple[dict[str, ModelInfo], dict[str, str | None]]:
# decoding would be ambiguous — the C tokenizer cannot tell
# whether that ID means a vocab token or a special token.
max_vocab_id = entry["vocab_size"] - 1
conflicting = [
(tok, tid) for tok, tid in raw_special.items() if tid <= max_vocab_id
]
conflicting = [(tok, tid) for tok, tid in raw_special.items() if tid <= max_vocab_id]
if conflicting:
import warnings

conflicting_repr = ", ".join(
f"{tok!r}→{tid}" for tok, tid in conflicting
)
conflicting_repr = ", ".join(f"{tok!r}→{tid}" for tok, tid in conflicting)
warnings.warn(
f"Model {entry['name']!r}: special tokens overlap with byte or "
f"merge IDs ({conflicting_repr}). "
Expand Down
3 changes: 2 additions & 1 deletion tinybpe/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def __init__(
self._vocab_cache: dict[int, bytes] | None = None
if bytes_maps is not None:
self._vocab_cache = {
k: self._inv_map(v) for k, v in self._enc.vocab.items() # type: ignore[union-attr]
k: self._inv_map(v)
for k, v in self._enc.vocab.items() # type: ignore[union-attr]
}

# ------------------------------------------------------------------
Expand Down
Loading