Skip to content

Fix 'standardize_data_formats' when using iterable datasets #126

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcandrelarochelle
Copy link
Contributor

Adds support to Iterable datasets for the 'standardize_data_formats'

num_proc is not supported by IterableDataset and cannot be accessed via index

PS: Sorry had to recreated my fork, did a mistake on my side

@danielhanchen
Copy link
Contributor

Much apologies on the delay @marcandrelarochelle ! Thanks for the PR!

Copy link
Contributor

@danielhanchen danielhanchen left a comment

Choose a reason for hiding this comment

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

@Erland366 Could you take a final review and confirm if iterable datasets work fine? Appreciate it

@@ -405,10 +405,10 @@ def standardize_data_formats(
if "conversations" not in column_names:
return dataset

convos = dataset[:10]["conversations"]
examples = itertools.islice(dataset, 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this specifically for iterable datasets? Ie itertools.islice works for iterable datasets whilst dataset[:10] does not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, you can't use an index or in this case [:10] on iterators

for convo in convos:
for message in convo:
for example in examples:
for message in example["conversations"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

The main reason why I did "conversations" outside is to make it somewhat faster, but I guess since its 10 examples, no big deal

return dataset.map(
_standardize_dataset,
batched = True,
batch_size = dataset._ex_iterable.batch_size,
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting on ._ex_iterable - I actually am not super interested with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I did this is to pass the batch_size, if you are using a iterable dataset, you might have a resource restrained system and by default it would use a batch size of 1000, but this way it will keep the same batch size it had before the _standardize_datasetformatting.

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