Skip to content

Validate tokenizer compatibility in Gemma4Sampler - #787

Open
sylvesterkaczmarek wants to merge 2 commits into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/gemma4-sampler-tokenizer-validation
Open

Validate tokenizer compatibility in Gemma4Sampler#787
sylvesterkaczmarek wants to merge 2 commits into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/gemma4-sampler-tokenizer-validation

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Gemma4Sampler accepted an explicitly supplied tokenizer without checking that its VERSION matched model.INFO.tokenizer_version. This differs from Sampler and can allow incompatible token IDs and special tokens into sampling.

This adds the same compatibility validation already used by Sampler and a regression test that verifies a Gemma 4 model rejects a version-3 tokenizer.

Testing

  • Added gemma/gm/text/_gemma4_sampler_test.py::test_rejects_incompatible_tokenizer

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