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

Fix perplexity and bring text modality to SOTA possible #90

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

bhavul
Copy link
Contributor

@bhavul bhavul commented May 26, 2024

This PR fixes the perplexity bug that has been haunting NEKO for months! :)

@bhavul bhavul requested a review from eihli May 26, 2024 17:23
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.
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.

2 participants