Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix task pre-processor in tasks #1373

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

sampathweb
Copy link
Collaborator

@sampathweb sampathweb commented Dec 19, 2023

When a user passes preprocessor to a from_preset constructor via kwargs, it fails with "got multiple values for keyword argument 'preprocessor'". This is because from_preset adds preprocessor parameter regardless of whether has also provided it. With this fix, we only add the preprocessor when the user has not provided the input.

Also, adds a validation to verify that user doesn't provide a backbone to the from_preset method since that's obtained from the preset directly.

# Repro steps
preprocessor = keras_nlp.models.DistilBertPreprocessor.from_preset(
    "distil_bert_base_en_uncased",
    sequence_length=SEQ_LENGTH,
)

# Pretrained classifier -  Errors out with duplicate `preprocessor` arg
classifier = keras_nlp.models.DistilBertClassifier.from_preset(
    "distil_bert_base_en_uncased",
    num_classes=2,
    activation=None,
    preprocessor=preprocessor,
)

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

Thank you! Couple comments.

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Collaborator

@nkovela1 nkovela1 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the fix Ramesh!

@sampathweb sampathweb merged commit 7f5236e into keras-team:kaggle Dec 20, 2023
6 checks passed
@sampathweb sampathweb deleted the fix-task-preprocessor branch December 20, 2023 03:29
mattdangerw pushed a commit that referenced this pull request Jan 4, 2024
* Allow custom preprocessor

* Allow custom preprocessor

* Fix preprocessor validation in tasks
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