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

Fixes #17128 . #17356

Merged
merged 1 commit into from
Jun 10, 2022
Merged

Fixes #17128 . #17356

merged 1 commit into from
Jun 10, 2022

Conversation

mygithubid1
Copy link
Contributor

@mygithubid1 mygithubid1 commented May 19, 2022

What does this PR do?

Finalize changes as per this PR.
Sorry. I messed up changes during merge and hence this new PR.

Fixes #17128

Before submitting

  • [N/A] 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? Here's the link
  • [N/A] Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests? I didn't write a custom test. Ran the following commands run to ensure local tests pass
  1. RUN_PIPELINE_TESTS=yes python -m unittest discover -s tests/pipelines -p "test_pipelines_question_answering.py" -t . -v -f
  2. python -m unittest discover -s . -p "test_tokenization_wav2vec2.py" -t . -v -f

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.

@LysandreJik
@Narsil

VisibleDeprecationWarning is addressed by specifying dtype=object when creating numpy array.
Update code based on review feedback.
Undo whitespace changes to tokenization_utils_base.py.
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 19, 2022

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

@mygithubid1 mygithubid1 marked this pull request as ready for review May 19, 2022 20:09
Copy link
Contributor

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

LGTM pinging @LysandreJik !

@@ -344,7 +339,7 @@ def preprocess(self, example, padding="do_not_pad", doc_stride=None, max_questio
for i, feature in enumerate(features):
fw_args = {}
others = {}
model_input_names = self.tokenizer.model_input_names + ["p_mask"]
model_input_names = self.tokenizer.model_input_names + ["p_mask", "token_type_ids"]
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, but if the tokenizer already has token_type_ids in model_input_names (for example BERT), then token_type_ids will be here twice. Why is this line necessary compared to before?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are two ways to pass arguments to the _forward function, and the autobatcher will act differently if it's a Tensor or a list. (lists are unbatched, just lists of lists) while tensors get batched (with padded value and direction).

The problem occurs here becaus token_type_ids are used in the postprocessing (like p_mask) so they need to be correctly passed as tensors. So the hint self.tokenizer.model_input_names is not enough and this line ensures that the postprocessing will see a tensor aligned with the others.

If token_type_idsis listed twice, then maybe we can just (lmodel_input_names = set(model_input_names) ? (Actually the fw_args and others are already dictionnary so I think there's only 1 level of duplication.

Copy link
Member

Choose a reason for hiding this comment

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

Yes that's one solution! Anyway it's a nitpick given that it won't change much. We're using this list to check if the name of a variable is in it, so if it's in it twice, it'll result in the same!

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi both. I got notification that this issue has been marked as stale. If there's anything to do be done, please let me know. If you both require more time to reach a conclusion, that's fine by me.
Thanks,

Copy link
Contributor

Choose a reason for hiding this comment

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

@LysandreJik are you ok with merging this ?

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

LGTM!

@LysandreJik LysandreJik merged commit 35b1603 into huggingface:main Jun 10, 2022
@LysandreJik
Copy link
Member

Thank you for your contribution, @mygithubid1!

@mygithubid1 mygithubid1 deleted the issue-17128 branch June 10, 2022 16:12
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
VisibleDeprecationWarning is addressed by specifying dtype=object when creating numpy array.
Update code based on review feedback.
Undo whitespace changes to tokenization_utils_base.py.

Co-authored-by: I like data <[email protected]>
amyeroberts pushed a commit to amyeroberts/transformers that referenced this pull request Jun 16, 2022
VisibleDeprecationWarning is addressed by specifying dtype=object when creating numpy array.
Update code based on review feedback.
Undo whitespace changes to tokenization_utils_base.py.

Co-authored-by: I like data <[email protected]>
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.

fixing VisibleDeprecationWarning
5 participants