Skip to content

Fix generate() to accept additional generation parameters - #9

Merged
mrinalchaturvedi27 merged 2 commits into
mainfrom
copilot/fix-training-error
Feb 5, 2026
Merged

Fix generate() to accept additional generation parameters#9
mrinalchaturvedi27 merged 2 commits into
mainfrom
copilot/fix-training-error

Conversation

Copilot AI commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Trainer.evaluate() passes length_penalty, no_repeat_ngram_size, and early_stopping to generate(), but SignLanguageTranslationModel.generate() didn't accept these parameters, causing a TypeError during training.

Changes

  • Added **kwargs to SignLanguageTranslationModel.generate() signature
  • Forward kwargs to underlying HuggingFace model for both encoder-decoder and causal LM paths
def generate(
    self,
    input_ids: torch.Tensor,
    attention_mask: torch.Tensor,
    max_length: int = 128,
    num_beams: int = 5,
    **kwargs,  # Now accepts length_penalty, early_stopping, etc.
):

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: `/usr/bin/python python -c
      from transformers import AutoModelForSeq2SeqLM, AutoConfig, AutoTokenizer
      import inspect

Check generate method signature

model = AutoModelForSeq2SeqLM.from_pretrained('t5-small')
print('Generate parameters:')
sig = inspect.signature(model.generate)
fo` (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ional parameters

Co-authored-by: mrinalchaturvedi27 <203689324+mrinalchaturvedi27@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in multi-GPU training script Fix generate() to accept additional generation parameters Feb 5, 2026
@mrinalchaturvedi27
mrinalchaturvedi27 marked this pull request as ready for review February 5, 2026 18:24
Copilot AI review requested due to automatic review settings February 5, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a TypeError that occurred when Trainer.evaluate() called SignLanguageTranslationModel.generate() with additional generation parameters (length_penalty, no_repeat_ngram_size, and early_stopping) that the method didn't accept.

Changes:

  • Added **kwargs parameter to the generate() method signature to accept additional generation parameters
  • Forwarded kwargs to the underlying HuggingFace model's generate method for both encoder-decoder and causal LM code paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrinalchaturvedi27
mrinalchaturvedi27 merged commit dac3279 into main Feb 5, 2026
10 checks passed
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.

3 participants