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

Add type hints for several pytorch models (batch-3) #25705

Conversation

nablabits
Copy link
Contributor

What does this PR do?

Addresses some of the models in #16059:

  1. ErnieM
    1. ErnieMForInformationExtraction
    2. ErnieMForMultipleChoice
    3. ErnieMForQuestionAnswering
    4. ErnieMForSequenceClassification
    5. ErnieMForTokenClassification
    6. ErnieMModel
  2. EsmForProteinFolding
  3. GraphormerModel
  4. InstructBlipQFormerModel
  5. LayoutLMForMaskedLM
  6. LukeForEntitySpanClassification

Who can review?

@Rocketknight1, please

Comment on lines +819 to +820
perturb: Optional[torch.FloatTensor] = None,
masked_tokens: None = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For perturb I took what microsoft/graphormer uses.

masked_tokens on the other hand, raises a NotImplemented whenever it has something that is not None

Copy link
Member

Choose a reason for hiding this comment

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

Haa, that's funny. Congrats on our first correct type hint of an explicit None!

input_ids: torch.LongTensor,
attention_mask: Optional[torch.FloatTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
query_embeds: Optional[torch.Tensor] = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was unsure of the dtype (I couldn't find any reference) so I left the generic torch.Tensor

@ArthurZucker
Copy link
Collaborator

cc @Rocketknight1

@nablabits nablabits changed the title Add type hints for several models (batch-3) Add type hints for several pytorch models (batch-3) Aug 25, 2023
Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Looks great to me, thank you!

Comment on lines +819 to +820
perturb: Optional[torch.FloatTensor] = None,
masked_tokens: None = None,
Copy link
Member

Choose a reason for hiding this comment

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

Haa, that's funny. Congrats on our first correct type hint of an explicit None!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@Rocketknight1 Rocketknight1 merged commit 4d9e45f into huggingface:main Aug 25, 2023
3 checks passed
@nablabits nablabits deleted the feature/add-type-hints-for-models-batch-3 branch September 14, 2023 07:06
parambharat pushed a commit to parambharat/transformers that referenced this pull request Sep 26, 2023
* Add missing type hints for ErnieM family

* Add missing type hints for EsmForProteinFolding model

* Add missing type hints for Graphormer model

* Add type hints for InstructBlipQFormer model

* Add missing type hints for LayoutLMForMaskedLM model

* Add missing type hints for LukeForEntitySpanClassification model
blbadger pushed a commit to blbadger/transformers that referenced this pull request Nov 8, 2023
* Add missing type hints for ErnieM family

* Add missing type hints for EsmForProteinFolding model

* Add missing type hints for Graphormer model

* Add type hints for InstructBlipQFormer model

* Add missing type hints for LayoutLMForMaskedLM model

* Add missing type hints for LukeForEntitySpanClassification model
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 18, 2023
* Add missing type hints for ErnieM family

* Add missing type hints for EsmForProteinFolding model

* Add missing type hints for Graphormer model

* Add type hints for InstructBlipQFormer model

* Add missing type hints for LayoutLMForMaskedLM model

* Add missing type hints for LukeForEntitySpanClassification model
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.

4 participants