-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix UnboundLocalError if preprocessing returns an empty list #6346
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For causal language modeling, if you're using the preprocessing as described in this HF YouTube video: https://youtu.be/ma1TrR7gE7I?si=T1PdOEvcQwDJuGtt&t=117 Throws the following error if no sample is longer than the context length: UnboundLocalError: local variable 'batch_idx' referenced before assignment
cwallenwein
changed the title
Fix UnboundLocalError if preprocessing doesn't return a batch
Fix UnboundLocalError if preprocessing doesn't returns an empty list
Oct 24, 2023
mariosasko
reviewed
Oct 24, 2023
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!
The batched
.filter
also has this issue, so feel free to fix it too as part of this PR.
The documentation is not available anymore as the PR was closed or merged. |
Co-authored-by: Mario Šaško <mariosasko777@gmail.com>
mariosasko
approved these changes
Oct 25, 2023
Show benchmarksPyArrow==8.0.0 Show updated benchmarks!Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json
Show updated benchmarks!Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json
|
cwallenwein
changed the title
Fix UnboundLocalError if preprocessing doesn't returns an empty list
Fix UnboundLocalError if preprocessing returns an empty list
Oct 25, 2023
albertvillanova
pushed a commit
that referenced
this pull request
Nov 15, 2023
…6346) * Fix For causal language modeling, if you're using the preprocessing as described in this HF YouTube video: https://youtu.be/ma1TrR7gE7I?si=T1PdOEvcQwDJuGtt&t=117 Throws the following error if no sample is longer than the context length: UnboundLocalError: local variable 'batch_idx' referenced before assignment * Apply suggestions from code review Co-authored-by: Mario Šaško <mariosasko777@gmail.com> * Fix indent + improve readability * Fixes * Style * Style again --------- Co-authored-by: Mario Šaško <mariosasko777@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If this tokenization function is used with IterableDatasets and no sample is as big as the context length,
input_batch
will be an empty list.This will throw the following error: UnboundLocalError: local variable 'batch_idx' referenced before assignment, because the for loop was not executed a single time
Some of the possible solutions
or