Skip to content

Handle tokenizer configs without tokenizer_class#2278

Open
CodingFeng101 wants to merge 1 commit into
Lightning-AI:mainfrom
CodingFeng101:codex/fix-tokenizer-dir-check
Open

Handle tokenizer configs without tokenizer_class#2278
CodingFeng101 wants to merge 1 commit into
Lightning-AI:mainfrom
CodingFeng101:codex/fix-tokenizer-dir-check

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

This updates Tokenizer to treat tokenizer_class in tokenizer_config.json as optional when deciding whether to apply the single-token LLaMA decoding workaround.

Why

A tokenizer directory can include a valid tokenizer.json and a minimal tokenizer_config.json that does not define tokenizer_class. In that case, initialization currently raises a KeyError even though the tokenizer can otherwise be loaded.

Validation

  • python -m pytest tests/test_tokenizer.py::test_tokenizer_config_without_tokenizer_class tests/test_tokenizer.py::test_tokenizer_bos_eos tests/test_tokenizer.py::test_tokenizer_input_validation -q
  • python -m ruff check litgpt\tokenizer.py tests\test_tokenizer.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant