From 8e78ca34a2a5c7788dc7346d0b3b1b79aff06f99 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 29 Nov 2025 01:23:34 +0000 Subject: [PATCH 1/2] Fix typos in config.py - Fix typo in docstring: 'diresired' -> 'desired' - Fix double comma in error message: '"4b",,' -> '"4b",' --- gemma/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gemma/config.py b/gemma/config.py index 710f6d1..40378e0 100644 --- a/gemma/config.py +++ b/gemma/config.py @@ -310,7 +310,7 @@ def get_config_for_27b_v3(dtype: str) -> GemmaConfig: def get_model_config(variant: str, dtype: str = 'bfloat16') -> GemmaConfig: - """Gets the GemmaConfig for the diresired variant and dtype.""" + """Gets the GemmaConfig for the desired variant and dtype.""" # Gemma1 variants if variant == '7b': return get_config_for_7b(dtype) @@ -336,5 +336,5 @@ def get_model_config(variant: str, dtype: str = 'bfloat16') -> GemmaConfig: else: raise ValueError( f'Invalid variant {variant}. Supported variants are "1b", "2b", ' - '"2b-v2", "4b",, "7b", "9b" "12b", "27b", and "27b_v3".' + '"2b-v2", "4b", "7b", "9b", "12b", "27b", and "27b_v3".' ) From 114456456f019be790b759eb6a8ed28729aca7f7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 29 Nov 2025 01:32:35 +0000 Subject: [PATCH 2/2] Fix multiple bugs and inconsistencies - Fix typo in siglip_vision/config.py: 'andPaliGemma' -> 'and PaliGemma' - Fix incomplete model variant list in scripts/run.py (add 4b, 12b, 27b_v3) - Fix None handling bug in tokenizer.py with better error message --- gemma/siglip_vision/config.py | 2 +- gemma/tokenizer.py | 6 ++++-- scripts/run.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gemma/siglip_vision/config.py b/gemma/siglip_vision/config.py index 66a2835..61a6738 100644 --- a/gemma/siglip_vision/config.py +++ b/gemma/siglip_vision/config.py @@ -21,7 +21,7 @@ # https://developers.googleblog.com/en/gemma-explained-paligemma-architecture/ @dataclasses.dataclass class SiglipVisionModelConfig: - """Returns the model config for the vision model of Gemma 3 andPaliGemma.""" + """Returns the model config for the vision model of Gemma 3 and PaliGemma.""" # The number of transformer encoder blocks in the siglip encoder model. num_hidden_layers: int = 27 # The dimension of the embedding. diff --git a/gemma/tokenizer.py b/gemma/tokenizer.py index 400760e..341c8a4 100644 --- a/gemma/tokenizer.py +++ b/gemma/tokenizer.py @@ -16,8 +16,10 @@ import sentencepiece -def _assert_file_exists(model_path: str): - assert os.path.isfile(model_path), model_path +def _assert_file_exists(model_path: Optional[str]): + if model_path is None: + raise ValueError("model_path cannot be None") + assert os.path.isfile(model_path), f"Model file not found: {model_path}" _BEGIN_IMAGE_TOKEN = 255999 _END_IMAGE_TOKEN = 256000 diff --git a/scripts/run.py b/scripts/run.py index e1f93e5..6c66595 100644 --- a/scripts/run.py +++ b/scripts/run.py @@ -35,7 +35,7 @@ flags.DEFINE_string('prompt', 'What are large language models?', 'Input prompt for the model.') # Define valid text only model variants -_VALID_MODEL_VARIANTS = ['2b', '2b-v2', '7b', '9b', '27b', '1b'] +_VALID_MODEL_VARIANTS = ['1b', '2b', '2b-v2', '4b', '7b', '9b', '12b', '27b', '27b_v3'] # Define valid devices _VALID_DEVICES = ['cpu', 'cuda']