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

Simplify registering "built-in" presets #1818

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

mattdangerw
Copy link
Member

Instead of registering classes with backbone and tokenizer, we just register them with the associated backbone. This will keep the accessors working for models without tokenizer classes. We can build the correct list for any class in the library by checking the associated backbone class.

keras_nlp.models.PaliGemmaTokenizer.presets.keys()
keras_nlp.models.Gpt2Backbone.presets.keys()
keras_nlp.models.TextClassifier.presets.keys()
keras_nlp.layers.AudioConverter.presets.keys()

Instead of registering them with every class a preset should work with,
we just register them with the associated backbone. We can use that
to build `cls.preset` accessors for all library classes. E.g.

```python
keras_nlp.models.PaliGemmaTokenizer.presets
keras_nlp.models.Gpt2Backbone.presets
keras_nlp.models.TextClassifier.presets
```
@github-actions github-actions bot added the Gemma Gemma model specific issues label Sep 10, 2024
@SamanehSaadat
Copy link
Member

Instead of registering classes with backbone and tokenizer, we just register them with the associated backbone.

What was the reason for registering the tokenizer before this change?

@mattdangerw
Copy link
Member Author

What was the reason for registering the tokenizer before this change?

Previously we didn't have the tokenizers associated with a backbone class. But not a particularly good reason, just hadn't thought of this approach?

@mattdangerw mattdangerw merged commit 6d19bb3 into keras-team:master Sep 10, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gemma Gemma model specific issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants