-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Feature Extractor: Wav2Vec2 & Speech2Text - Allow truncation + padding=longest #13600
Feature Extractor: Wav2Vec2 & Speech2Text - Allow truncation + padding=longest #13600
Conversation
raise ValueError( | ||
"When setting ``truncation=True``, make sure that ``max_length`` is defined and ``padding='max_length'``" | ||
) | ||
raise ValueError("When setting ``truncation=True``, make sure that ``max_length`` is defined.") |
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.
Now we do allow truncation=True + padding="longest"
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.
Thanks for adding this and nice new tests!
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.
LGTM, thanks for catching the bug :)
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
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.
LGTM
…g=longest (huggingface#13600) * correct * add tests * Update src/transformers/feature_extraction_sequence_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
…g=longest (huggingface#13600) * correct * add tests * Update src/transformers/feature_extraction_sequence_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
What does this PR do?
For training is speech it's quite important that we are able to make use of the
padding="longest"
a.k.a dynamic batching in PyTorch on GPU since speech inputs can vary from 2 seconds to up to 30 seconds. We also want to be able to use truncation withpadding="longest"
in such a case. This PR enables using truncation (i.e. cutting sequences to a max length of x seconds) with thepadding="longest"
mode.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.