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

Update modular_modernbert.py to support input_embeddings #35422

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

KoichiYasuoka
Copy link
Contributor

@KoichiYasuoka KoichiYasuoka commented Dec 26, 2024

What does this PR do?

Fixes #35344

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@KoichiYasuoka KoichiYasuoka changed the title Update modular_modernbert.py Update modular_modernbert.py to support input_embeddings Dec 28, 2024
@tomaarsen tomaarsen self-requested a review December 28, 2024 12:18
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@tomaarsen tomaarsen left a comment

Choose a reason for hiding this comment

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

I believe the norm is that only the base model, i.e. ModernBertModel here, has get_input_embeddings and set_input_embeddings. See for example modeling_bert.py and modeling_roberta.py.

Beyond that, the ModernBertForSequenceClassification class doesn't have an attribute called embeddings.

However, the Python 3.9 patch is very good, and I'll be making a separate PR for it.

@tomaarsen
Copy link
Member

I opened #35458 with @KoichiYasuoka as co-author to implement the Python 3.9 support from this PR.
Unless we'd like to break the norm and add get_input_embeddings to the other model classes, we can probably leave this PR be, and only merge #35458.

  • Tom Aarsen

@KoichiYasuoka
Copy link
Contributor Author

Thank you @tomaarsen for separating issues. Well... I added get_input_embeddings in #29878 to handle input_embeds for "single character which was tokenized into multiple tokens". So I really need input_embeds for ModernBERT but this time I'm planing to emulate with set_input_embeddings to [UNUSED] token.

@tomaarsen
Copy link
Member

Oh I see, I didn't realise there were non-base model classes that use get_input_embeddings. That changes things!

@KoichiYasuoka
Copy link
Contributor Author

Thank you @tomaarsen and here I link to Ek and Bernardy (2020).

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