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
3 changes: 3 additions & 0 deletions src/transformers/models/gemma3/modeling_gemma3.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,9 @@ class Gemma3ForConditionalGeneration(Gemma3PreTrainedModel, GenerationMixin):
"^language_model.lm_head": "lm_head",
}
_tied_weights_keys = ["lm_head.weight"]
# we are filtering the logits/labels so we shouldn't divide the loss based on num_items_in_batch
# Fix: https://github.com/huggingface/transformers/issues/40564
accepts_loss_kwargs = False

def __init__(self, config: Gemma3Config):
super().__init__(config)
Expand Down
4 changes: 4 additions & 0 deletions src/transformers/models/gemma3/modular_gemma3.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,10 @@ def forward(


class Gemma3ForConditionalGeneration(PaliGemmaForConditionalGeneration):
# we are filtering the logits/labels so we shouldn't divide the loss based on num_items_in_batch
# Fix: https://github.com/huggingface/transformers/issues/40564
accepts_loss_kwargs = False

@auto_docstring
def forward(
self,
Expand Down