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

Preserve features in iterable dataset.filter #7209

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

alex-hh
Copy link
Contributor

@alex-hh alex-hh commented Oct 9, 2024

Fixes example in #7208 - I'm not sure what other checks I should do? @lhoestq

I also haven't thought hard about the concatenate / interleaving example iterables but think this might work assuming that features are either all identical or None?

@lhoestq
Copy link
Member

lhoestq commented Oct 9, 2024

Yes your assumption on concatenate/interleave is ok imo.

It seems the TypedExamplesIterable can slow down things, it should take formatting into account to not convert numpy arrays to python lists

right now it's slow (unrelatedly to your PR):

>>> ds = Dataset.from_dict({"a": np.zeros((1000, 32, 32))}).to_iterable_dataset().with_format("np")
>>> filtered_ds = ds.filter(lambda x: True)
>>> %time sum(1 for _ in ds)
CPU times: user 175 ms, sys: 8.1 ms, total: 183 ms
Wall time: 184 ms
1000
>>> %time sum(1 for _ in filtered_ds)
CPU times: user 4.1 s, sys: 8.41 ms, total: 4.1 s
Wall time: 4.12 s
1000

Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@alex-hh
Copy link
Contributor Author

alex-hh commented Oct 9, 2024

It seems the TypedExamplesIterable can slow down things, it should take formatting into account to not convert numpy arrays to python lists

Should be fixed by updated #7207 I hope!

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.

in any case, LGTM now :)

@lhoestq lhoestq merged commit 16a121d into huggingface:main Oct 9, 2024
14 checks passed
@alex-hh alex-hh deleted the filter-preserve-features branch October 16, 2024 11:27
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.

3 participants