-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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 tf models batch 1 #25853
Add type hints for tf models batch 1 #25853
Conversation
is_decoder=False, | ||
training=None, | ||
): | ||
input_ids: TFModelInputType | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen a nice mix of this TFModelInputType
and tf.Tensor | None
in a few models, so whenever I had to fill input_ids
I defaulted to the former as the instructions of the issue say. If this is not the case, is there a way to tell apart when each one should be used?
decoder_attention_mask=None, | ||
head_mask=None, | ||
decoder_head_mask=None, | ||
encoder_outputs: Optional[Union[Tuple, TFLEDEncoderBaseModelOutput]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've replaced this to the |
format for consistency. There are other places where there's a mix of approaches that I didn't fix as all the type hints were present. Let me know if you want me to give them some consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the | format is preferred! The main reason is that it looks nicer in the automatically generated documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, great, I've then added a commit to make them consistent within the method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Good catches with the copy-pasted docstrings from torch as well. Is this ready to merge, or do you want to add anything else?
@@ -1571,7 +1571,7 @@ class TFLEDSeq2SeqLMOutput(ModelOutput): | |||
- 0 for tokens that are **masked**. | |||
|
|||
[What are attention masks?](../glossary#attention-mask) | |||
decoder_input_ids (`tf.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*): | |||
decoder_input_ids (`tf.Tensor` of shape `(batch_size, target_sequence_length)`, *optional*): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
decoder_attention_mask=None, | ||
head_mask=None, | ||
decoder_head_mask=None, | ||
encoder_outputs: Optional[Union[Tuple, TFLEDEncoderBaseModelOutput]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the | format is preferred! The main reason is that it looks nicer in the automatically generated documentation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
Now with the consistency tweaks I'm happy for you to merge, thanks 🤗 |
* Add type hints to `TFBlipTextModel` * Add missing type hints to DPR family models * Add type hints to `TFLEDModel` * Add type hints to `TFLxmertForPreTraining` * Add missing type hints to `TFMarianMTModel` and `TFMarianModel` * Add missing type hints to `TFRagModel` & `TFRagTokenForGeneration` * Make type hints annotations consistent
* Add type hints to `TFBlipTextModel` * Add missing type hints to DPR family models * Add type hints to `TFLEDModel` * Add type hints to `TFLxmertForPreTraining` * Add missing type hints to `TFMarianMTModel` and `TFMarianModel` * Add missing type hints to `TFRagModel` & `TFRagTokenForGeneration` * Make type hints annotations consistent
* Add type hints to `TFBlipTextModel` * Add missing type hints to DPR family models * Add type hints to `TFLEDModel` * Add type hints to `TFLxmertForPreTraining` * Add missing type hints to `TFMarianMTModel` and `TFMarianModel` * Add missing type hints to `TFRagModel` & `TFRagTokenForGeneration` * Make type hints annotations consistent
What does this PR do?
Addresses some of the type hints for tf models in #16059:
TFBlipTextModel
DPRModel
family:TFDPRContextEncoder
TFDPRQuestionEncoder
TFDPRReader
LED
familyTFLEDForConditionalGeneration
TFLEDModel
TFLxmertForPreTraining
Marian
familyTFMarianMTModel
TFMarianModel
Rag
familyTFRagModel
TFRagTokenForGeneration
Who can review?
@Rocketknight1 please