Conversation
When we added `padding='longest'` to the tokenization, it caused empty
strings to be padded to the same length as the longest sample. That
meant that `numel()` was never going to be 0.
This commit moves the empty string check to the part of the code that
loads the dataset into memory.
Because of the way we're sampling indices in `sample_batch`...:
```
sampled_indices = torch.randperm(len(dataset_split))[:batch_size]
samples = dataset_split.select(sampled_indices)
tokenized_outputs = self.text_tokenizer(samples['text'], truncation=True, padding="longest", max_length=self.context_length, return_tensors='pt')
```
... we were ending up with batches of varying sizes, depending on how
many empty text strings we sampled. We always sample 64 indices, for
example, but sometimes we might get 20 of them that are empty strings.
Other times we might get 10 of them that are empty strings. Therefore
our batch size would vary on each sample. By filtering when we load the
dataset into memeory, we guarantee every batch size to be the same.
This file contains hidden or 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
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.
This PR fixes the perplexity bug that has been haunting NEKO for months! :)