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 missing type hints for all flavors of RoBERTa PyTorch models. #16086

Merged
merged 2 commits into from Mar 11, 2022

Conversation

chainyo
Copy link
Contributor

@chainyo chainyo commented Mar 11, 2022

What does this PR do?

I added type hints for all RoBERTa PyTorch classes as described in #16059 .
As I commented on the linked issue, CamemBERT inherits from RoBERTa, so it should be also good for PyTorch version of CamemBERT models.

@Rocketknight1

I was not sure about encoder_hidden_states and encoder_attention_mask which have torch.FloatTensor as type in the docstring, but I don't know if it needs to be specified or torch.Tensor is enough. Tell me if I need to change that.

EDIT: Oh it seems that I have put some torch.LongTensor like inputs_ids as torch.Tensor.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 11, 2022

The documentation is not available anymore as the PR was closed or merged.

@Rocketknight1
Copy link
Member

@chainyo it's totally okay to just use torch.Tensor, specifying torch.FloatTensor or torch.LongTensor is a bonus but not at all necessary!

Also, this PR looks great, but note that the methods can return a tuple if return_dict is False, so the real return type is usually Union[Tuple, OutputClass] and not just OutputClass!

@chainyo
Copy link
Contributor Author

chainyo commented Mar 11, 2022

@chainyo it's totally okay to just use torch.Tensor, specifying torch.FloatTensor or torch.LongTensor is a bonus but not at all necessary!

Also, this PR looks great, but note that the methods can return a tuple if return_dict is False, so the real return type is usually Union[Tuple, OutputClass] and not just OutputClass!

Fine, I will change that.

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, thank you!

@Rocketknight1 Rocketknight1 merged commit eaed689 into huggingface:master Mar 11, 2022
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.

None yet

3 participants