DOC: Clarify attention_mask usage in BertModel forward method#38877
DOC: Clarify attention_mask usage in BertModel forward method#38877dhyeyinf wants to merge 3 commits into
Conversation
|
Hi! This is my first contribution to Hugging Face. I see that one CircleCI check failed ( |
stevhliu
left a comment
There was a problem hiding this comment.
Thanks!
I think you should edit the line in the file below because it is a common argument and let @auto_docstring update it for all the other models that use it. cc @yonigozlan, is this the correct way?
| Mask used to avoid performing attention on padding tokens. | ||
| Positions with a value of 1 indicate tokens that should be attended to, | ||
| while 0 indicates padding tokens which are ignored by the model. | ||
| Typically used to differentiate between actual tokens and padding in batched sequences. |
There was a problem hiding this comment.
| Mask used to avoid performing attention on padding tokens. | |
| Positions with a value of 1 indicate tokens that should be attended to, | |
| while 0 indicates padding tokens which are ignored by the model. | |
| Typically used to differentiate between actual tokens and padding in batched sequences. | |
| Mask used to avoid performing attention on padding tokens indices. | |
| Positions with a value of 1 indicates a token should be attended to | |
| and 0 means it should be ignored. |
There was a problem hiding this comment.
This seems very similar to what we have already in args_doc, minus the link to the glossary, so not sure we should override the doc for bert here, and even less override the one in args_doc
| Example: | ||
| >>> attention_mask = torch.tensor([[1, 1, 1, 0, 0]]) | ||
| >>> # 1s represent actual tokens, 0s are padding. |
There was a problem hiding this comment.
I don't think its necessary to include an example here since there's already a link to a more detailed description of it
| Example: | |
| >>> attention_mask = torch.tensor([[1, 1, 1, 0, 0]]) | |
| >>> # 1s represent actual tokens, 0s are padding. |
…e model files via make fix-copies
|
Thanks for the review! |
|
Hi! I've applied make fix-copies and also ran make fix-all to ensure consistency across all models. If anything else is required from my side to pass the remaining checks, happy to assist. Thanks for reviewing! |
|
Thanks for your PR, but since your changes aren't all that different from what we currently have, I don't think we need to update this particular arg. Happy to review other areas where you think it can be improved though! 🙂 |
This PR improves the documentation of the
attention_maskparameter in theforward()method of theBertModelclass.Changes made:
attention_maskcontrol attention behaviorThe goal is to make the docstring more understandable and helpful for beginners exploring the source code.
Please let me know if you'd like any phrasing or formatting adjusted — happy to revise!