Skip to content

Conversation

@mariosasko
Copy link
Collaborator

@mariosasko mariosasko commented Sep 27, 2022

Use pa.Table.to_reader to make iteration over examples/batches faster in Dataset.{__iter__, map}

TODO:

  • benchmarking (the only benchmark for now - iterating over (single) examples of bookcorpus (75 mil examples) in Colab is approx. 2.3x faster)
  • check if iterating over bigger chunks + slicing to fetch individual examples in _iter yields better performance

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 27, 2022

The documentation is not available anymore as the PR was closed or merged.

@mariosasko
Copy link
Collaborator Author

I ran some benchmarks (focused on the data fetching part of __iter__) and it seems like the combination table.to_reader(batch_size) + RecordBatch.slice performs the best (script with the results). I think we can choose (implicit) batch_size=10 in the final implementation to avoid having problems with fetching large examples.

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

Nice thank you ! The benchmarks are super helpful as well, I think you can link to them in comments in the code

@mariosasko mariosasko merged commit 1ea4d09 into main Sep 29, 2022
@mariosasko mariosasko deleted the iter-with-reader branch September 29, 2022 15:48
@lhoestq lhoestq mentioned this pull request Oct 14, 2022
2 tasks
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.

4 participants