From 6072f405080d252177d199763376fd5501ee1955 Mon Sep 17 00:00:00 2001 From: manumishra12 Date: Tue, 23 Jun 2026 14:14:30 -0700 Subject: [PATCH] chore: fix spelling typos in comments and docstrings Fix 32 misspellings across comments, docstrings and a couple of doc/prompt strings (found via codespell), e.g. langauge->language, specifiy->specify, aribtrary->arbitrary, intialization->initialization, managment->management, Ouptut->Output. Comment/docstring text only; no code or behaviour change. Intentional French example strings and variable names left unchanged. --- examples/classification.py | 4 ++-- examples/dpo.py | 2 +- gemma/gm/ckpts/_checkpoint.py | 4 ++-- gemma/gm/ckpts/_lora.py | 2 +- gemma/gm/ckpts/_quantization.py | 4 ++-- gemma/gm/data/_functional.py | 2 +- gemma/gm/data/_tasks.py | 2 +- gemma/gm/data/_transforms.py | 2 +- gemma/gm/nn/_transformer.py | 4 ++-- gemma/gm/nn/gemma3n/_transformer.py | 4 ++-- gemma/gm/nn/gemma4/_transformer.py | 4 ++-- gemma/gm/nn/gemma4/audio/_modules.py | 4 ++-- gemma/gm/nn/vision/_vision.py | 6 +++--- gemma/gm/text/_sampler.py | 2 +- gemma/gm/text/_tokenizer.py | 2 +- gemma/gm/text/_tool_sampler.py | 2 +- gemma/peft/_einsum_utils.py | 4 ++-- gemma/peft/_einsum_utils_test.py | 2 +- gemma/peft/_quantization_utils.py | 4 ++-- gemma/research/t5gemma/README.md | 2 +- pyproject.toml | 2 +- 21 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/classification.py b/examples/classification.py index 4ffdbc7a..9f8ef601 100644 --- a/examples/classification.py +++ b/examples/classification.py @@ -96,7 +96,7 @@ def _make_dataset(training: bool) -> kd.data.Pipeline: gm.data.FormatText( key=_INPUT_FIELD, template="""user - Please classify whether the following sentence is grammaticaly correct, please answer only with Yes or No. + Please classify whether the following sentence is grammatically correct, please answer only with Yes or No. Sentence: {text} model""", ), @@ -113,7 +113,7 @@ def _make_dataset(training: bool) -> kd.data.Pipeline: gm.data.MapInts( key=_LABEL_FIELD, # Rather than predicting the token 0 and 1, we are using the - # token 1294 and 3553 which respectivelly correspond to "No" and + # token 1294 and 3553 which respectively correspond to "No" and # "Yes". We do this because those token already contain semantic # information, so even zero-shot prediction without any # finetuning has better than random performances. diff --git a/examples/dpo.py b/examples/dpo.py index 2d2565a9..0753fd55 100644 --- a/examples/dpo.py +++ b/examples/dpo.py @@ -14,7 +14,7 @@ r"""DPO Example. -DPO works by running two answers (one prefered and one rejected) into both +DPO works by running two answers (one preferred and one rejected) into both the reference model and the model to finetune. Then the DPO loss is used to increase the likelihood of generating the preferred answer. diff --git a/gemma/gm/ckpts/_checkpoint.py b/gemma/gm/ckpts/_checkpoint.py index 39138cf8..abb75a60 100644 --- a/gemma/gm/ckpts/_checkpoint.py +++ b/gemma/gm/ckpts/_checkpoint.py @@ -49,7 +49,7 @@ class LoadCheckpoint(kd.ckpts.InitTransform): """Loads weights from a Gemma checkpoint. - Note: The checpoint only contains the Gemma transformer weights, not the + Note: The checkpoint only contains the Gemma transformer weights, not the step, optimizer state,... Use `kd.ckpts.PartialKauldronLoader` to load the state from a Kauldron checkpoint. @@ -292,7 +292,7 @@ def load_params( # TODO(epot): Better API. Currently this do not quantize the weights, but # just refactor the params to the QAT structure. # Eventually quantize the params. Note: It would be better to do this - # while the weights are loaded, so restore do not use unecessary memory. + # while the weights are loaded, so restore do not use unnecessary memory. if quantize: output = _quantization.convert_to_qat_checkpoint(output) diff --git a/gemma/gm/ckpts/_lora.py b/gemma/gm/ckpts/_lora.py index 3ba30983..d2e93acd 100644 --- a/gemma/gm/ckpts/_lora.py +++ b/gemma/gm/ckpts/_lora.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Utils for LoRA checkpoint managment.""" +"""Utils for LoRA checkpoint management.""" from __future__ import annotations diff --git a/gemma/gm/ckpts/_quantization.py b/gemma/gm/ckpts/_quantization.py index f9240da2..cf035e43 100644 --- a/gemma/gm/ckpts/_quantization.py +++ b/gemma/gm/ckpts/_quantization.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Utils for LoRA checkpoint managment.""" +"""Utils for LoRA checkpoint management.""" from __future__ import annotations @@ -53,7 +53,7 @@ def convert_leaf(data: Any) -> Any: data = quantize_leaf(data, checkpoint_kernel_key) # This hack is required because the FeedForward layer call two different # Einsum with using `nn.share_scope`, so the two wrappers need a different - # name. Weights are not stored under any kernel key and are isntead under + # name. Weights are not stored under any kernel key and are instead under # the following names. if 'gating_einsum' in data or 'linear' in data: data = quantize_leaf(data, 'gating_einsum') diff --git a/gemma/gm/data/_functional.py b/gemma/gm/data/_functional.py index fc2609c7..2a3a873f 100644 --- a/gemma/gm/data/_functional.py +++ b/gemma/gm/data/_functional.py @@ -116,7 +116,7 @@ def make_seq2seq_fields( prompt = [10, 11, 12, 13], response = [20, 21, 1], # Here, response ends with EOS token. - # Ouptut: + # Output: out.input = [10, 11, 12, 13, 20, 21], out.target = [11, 12, 13, 20, 21, 1], out.target_mask = [ 0, 0, 0, 1, 1, 1], diff --git a/gemma/gm/data/_tasks.py b/gemma/gm/data/_tasks.py index ba997657..5325195c 100644 --- a/gemma/gm/data/_tasks.py +++ b/gemma/gm/data/_tasks.py @@ -80,7 +80,7 @@ class Seq2SeqTask(grain.MapTransform): 'prompt': 'Hello! I would love to visit France.', 'response': 'Bonjour ! J'adorerais visiter la France.', } - # Ouptut: + # Output: { 'input': i32['max_length'], 'target': i32['max_length 1'], diff --git a/gemma/gm/data/_transforms.py b/gemma/gm/data/_transforms.py index 0641a9db..79398577 100644 --- a/gemma/gm/data/_transforms.py +++ b/gemma/gm/data/_transforms.py @@ -133,7 +133,7 @@ class AddSeq2SeqFields(grain.MapTransform): 'prompt': [10, 11, 12, 13], 'response': [20, 21, 1], # Here, response ends with EOS token. } - # Ouptut: + # Output: { 'input': [10, 11, 12, 13, 20, 21], 'target': [11, 12, 13, 20, 21, 1], diff --git a/gemma/gm/nn/_transformer.py b/gemma/gm/nn/_transformer.py index 2aa19aab..084be33a 100644 --- a/gemma/gm/nn/_transformer.py +++ b/gemma/gm/nn/_transformer.py @@ -107,7 +107,7 @@ class Transformer(nn.Module): attention_mask: kontext.Key | None = None config: _config.TransformerConfig - # Model info to specifiy the tokenizer version and default checkpoint. + # Model info to specify the tokenizer version and default checkpoint. INFO: ClassVar[ModelInfo] = ModelInfo() def __post_init__(self): @@ -178,7 +178,7 @@ def vision_encoder(self) -> gemma_vision.SigLiPFromPatches | None: 'return_hidden_states', ), ) - # The function accepts/returns aribtrary batch shape, but inside the + # The function accepts/returns arbitrary batch shape, but inside the # function, the batch dimension is flattened to a single dimension. @_jax_utils.flatten_unflatten_batch_dim() @typechecked diff --git a/gemma/gm/nn/gemma3n/_transformer.py b/gemma/gm/nn/gemma3n/_transformer.py index 44ddfa59..4092480e 100644 --- a/gemma/gm/nn/gemma3n/_transformer.py +++ b/gemma/gm/nn/gemma3n/_transformer.py @@ -108,7 +108,7 @@ class Gemma3nTransformer(_transformer.Transformer): images: kontext.Key | None = None config: _config.TransformerConfig - # Model info to specifiy the tokenizer version and default checkpoint. + # Model info to specify the tokenizer version and default checkpoint. INFO: ClassVar[ModelInfo] = ModelInfo() def __post_init__(self): @@ -217,7 +217,7 @@ def vision_encoder(self) -> gemma_vision.SigLiPFromPatches | None: 'return_hidden_states', ), ) - # The function accepts/returns aribtrary batch shape, but inside the + # The function accepts/returns arbitrary batch shape, but inside the # function, the batch dimension is flattened to a single dimension. @_jax_utils.flatten_unflatten_batch_dim() @typechecked diff --git a/gemma/gm/nn/gemma4/_transformer.py b/gemma/gm/nn/gemma4/_transformer.py index ad7927f2..11fee5fc 100644 --- a/gemma/gm/nn/gemma4/_transformer.py +++ b/gemma/gm/nn/gemma4/_transformer.py @@ -128,7 +128,7 @@ class Transformer(nn.Module): images: kontext.Key | None = None config: _config.TransformerConfig - # Model info to specifiy the tokenizer version and default checkpoint. + # Model info to specify the tokenizer version and default checkpoint. INFO: ClassVar[ModelInfo] = ModelInfo() def __post_init__(self): @@ -228,7 +228,7 @@ def vision_encoder(self) -> gemma4_vision.VisionEncoder | None: 'audio_soft_token_counts', ), ) - # The function accepts/returns aribtrary batch shape, but inside the + # The function accepts/returns arbitrary batch shape, but inside the # function, the batch dimension is flattened to a single dimension. @_jax_utils.flatten_unflatten_batch_dim() @typechecked diff --git a/gemma/gm/nn/gemma4/audio/_modules.py b/gemma/gm/nn/gemma4/audio/_modules.py index b3fcb78d..1cfb122b 100644 --- a/gemma/gm/nn/gemma4/audio/_modules.py +++ b/gemma/gm/nn/gemma4/audio/_modules.py @@ -403,8 +403,8 @@ class LocalDotProductAttention(nn.Module): the SequenceLayers library. The latter is made for streaming attention and requires a specific kind of tensor manipulation. In order to match exactly output of the internal implementation of the AudioTokenizer, - we perform those manipulation here even though they are not theoritically - necessary. This results in a complexified implementation of a theoritically + we perform those manipulation here even though they are not theoretically + necessary. This results in a complexified implementation of a theoretically simple attention mechanism. """ diff --git a/gemma/gm/nn/vision/_vision.py b/gemma/gm/nn/vision/_vision.py index 9ce3ac25..a84f9b13 100644 --- a/gemma/gm/nn/vision/_vision.py +++ b/gemma/gm/nn/vision/_vision.py @@ -50,7 +50,7 @@ def check_mask(input_data: Float["L"]) -> tuple[Bool["1"], Int["L"]]: Returns: A boolean indicating whether the mask contains the correct number of blocks - and there starting positions (filled with 0 for jit compatiblity). + and there starting positions (filled with 0 for jit compatibility). """ is_mask = input_data == TOKEN_PLACEHOLDER start_idx = ( @@ -124,7 +124,7 @@ def initialize_vision_tokens( ) -> VisionInitEmbeddings: """Initializes vision embeddings. - Vision data intialization wrapper for sampling. + Vision data initialization wrapper for sampling. Example (text only inference): ```python @@ -191,7 +191,7 @@ def initialize_vision_tokens( base_mm_tokens = base_mm_tokens.at[:, -1].set(NEW_LINE_TOKEN) # then we repeat this tensor for each image in the batch mm_tokens = jnp.repeat(base_mm_tokens, patches.shape[1], axis=0) - # insert iamges after the first token, which is BOS as expected in gemma v3 + # insert images after the first token, which is BOS as expected in gemma v3 token_buffer = jnp.concatenate( [token_buffer[:, :1], mm_tokens, token_buffer[:, 1:]], axis=1 ) diff --git a/gemma/gm/text/_sampler.py b/gemma/gm/text/_sampler.py index 5b8ae163..eb464363 100644 --- a/gemma/gm/text/_sampler.py +++ b/gemma/gm/text/_sampler.py @@ -118,7 +118,7 @@ class Sampler: conversation can have (prompts, answers, images for all turns). Setting this to a fixed value avoids re-compilation between turns. max_out_length: Length of the output buffer for a single turn. Static value - used to avoid trigering a jit recompilation. Shouldn't be changed unless + used to avoid triggering a jit recompilation. Shouldn't be changed unless you have a task where the model generates really long outputs. pad_length: If provided, pad the prompt to this length. This ensure the prompt is always the same length, to avoid jit re-compilation. diff --git a/gemma/gm/text/_tokenizer.py b/gemma/gm/text/_tokenizer.py index bf351456..0b9b2b63 100644 --- a/gemma/gm/text/_tokenizer.py +++ b/gemma/gm/text/_tokenizer.py @@ -41,7 +41,7 @@ import plotly.express as px # pylint: disable=g-import-not-at-top # pytype: disable=import-error -_WHITESPACE_CHAR = '▁' # Note this is NOT a undescore (▁ != _) +_WHITESPACE_CHAR = '▁' # Note this is NOT a underscore (▁ != _) class _DisplayEnumType(enum.EnumType): diff --git a/gemma/gm/text/_tool_sampler.py b/gemma/gm/text/_tool_sampler.py index fe4b72d2..5f922bec 100644 --- a/gemma/gm/text/_tool_sampler.py +++ b/gemma/gm/text/_tool_sampler.py @@ -90,7 +90,7 @@ def chat( Overrites the `multi_turn` attribute. is_legacy_tool_answer: When `True`, indicates that the model has emitted `` rather than `<|tool_response>`, thus this needs to be corrected. - (this is an internal variable that should never be explictly set). + (this is an internal variable that should never be explicitly set). sharding: Sharding tree (Gemma 4 only). Returns: diff --git a/gemma/peft/_einsum_utils.py b/gemma/peft/_einsum_utils.py index 847acb9e..0cfed61d 100644 --- a/gemma/peft/_einsum_utils.py +++ b/gemma/peft/_einsum_utils.py @@ -28,7 +28,7 @@ def get_lora_einsum_str_and_shapes( ) -> tuple[str, _Shape, _Shape]: """Extract the LoRA decomposition from the original einsum parameters. - This function reqrites a einsum string `inputs,weights->outputs` into + This function rewrites a einsum string `inputs,weights->outputs` into `inputs,a,b->outputs`. Args: @@ -66,7 +66,7 @@ def get_lora_einsum_str_and_shapes( lora_einsum_str = f'{inputs},{a_str},{b_str}->{outputs}' - # This assume there's no elipsis in the weights. + # This assume there's no ellipsis in the weights. weights_str_to_dim = dict(zip(weights, weights_shape)) weights_str_to_dim[rank_dim] = rank a_shape = tuple(weights_str_to_dim[c] for c in a_str) diff --git a/gemma/peft/_einsum_utils_test.py b/gemma/peft/_einsum_utils_test.py index 997c8e1f..85adc2f3 100644 --- a/gemma/peft/_einsum_utils_test.py +++ b/gemma/peft/_einsum_utils_test.py @@ -40,7 +40,7 @@ def test_einsum(): rank=R, ) == ('bijk,bjkr,rnm->bimn', (B, J, K, R), (R, N, M)) - # When r is already in use in the letters, another letter is choosen + # When r is already in use in the letters, another letter is chosen # (here `D`) assert _einsum_utils.get_lora_einsum_str_and_shapes( einsum_str='...abcABCrR,Rgk->...ABCabcrgk', diff --git a/gemma/peft/_quantization_utils.py b/gemma/peft/_quantization_utils.py index fa0993e2..72887f94 100644 --- a/gemma/peft/_quantization_utils.py +++ b/gemma/peft/_quantization_utils.py @@ -71,7 +71,7 @@ def quantize( ) -> PyTree: """Quantizes the given params. - In ths API, we convert the elements of params in order to actually get + In the API, we convert the elements of params in order to actually get quantized values. It is currently limited to INT$ per-channel weight quantization. @@ -146,7 +146,7 @@ def convert_leaf(data: Any) -> Any: data = quantize_leaf(data, checkpoint_kernel_key) # This hack is required because the FeedForward layer call two different # Einsum with using `nn.share_scope`, so the two wrappers need a different - # name. Weights are not stored under any kernel key and are isntead under + # name. Weights are not stored under any kernel key and are instead under # the following names. if 'gating_einsum' in data or 'linear' in data: data = quantize_leaf(data, 'gating_einsum') diff --git a/gemma/research/t5gemma/README.md b/gemma/research/t5gemma/README.md index 0620cf9a..8ed67342 100644 --- a/gemma/research/t5gemma/README.md +++ b/gemma/research/t5gemma/README.md @@ -2,7 +2,7 @@ T5Gemma (aka encoder-decoder Gemma) was proposed in a [research paper](https://arxiv.org/abs/2504.06225) by Google. It is a family of -encoder-decoder large langauge models, developed by adapting pretrained +encoder-decoder large language models, developed by adapting pretrained decoder-only models into encoder-decoder. T5Gemma includes pretrained and instruction-tuned variants. The architecture is based on transformer encoder-decoder design following T5, with improvements from Gemma 2: GQA, RoPE, diff --git a/pyproject.toml b/pyproject.toml index 79fea791..c74a2842 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ changelog = "https://github.com/google-deepmind/gemma/blob/main/CHANGELOG.md" # documentation = "" [project.optional-dependencies] -# Development deps (unittest, linting, formating,...) +# Development deps (unittest, linting, formatting,...) # Installed through `pip install -e .[dev]` dev = [ "pytest",