# Loading a fraction of data

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%3E%5C
**Category:** 🤗Datasets\
**Created:** [May 10, 2023, 8:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373 "2023-05-10T08:28:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eli4s](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/eli4s/32/56317_2.png) [@eli4s](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Feli4s)%5C
**Post date:** [May 10, 2023, 8:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F1 "2023-05-10T08:28:32Z")

</div>

Hi,  
Is it possible to load a certain percent of any given dataset with the function load\_dataset?

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [May 11, 2023, 12:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F2 "2023-05-11T12:35:04Z")

</div>

Hi ! You can load a subset from a dataset this way:

```python
subset = load_dataset(..., split="train[:30%]")

```

Note that it still downloads and prepares the full dataset - but only the requested subset is returned.

---

<div class="post-metadata">

**Author:** ![eli4s](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/eli4s/32/56317_2.png) [@eli4s](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Feli4s)%5C
**Post date:** [May 11, 2023, 1:10pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F3 "2023-05-11T13:10:30Z")

</div>

Hi,  
Thanks a lot for your answer !  
Unfortunately, it does not solve my issue, I need a solution for only downloading a fraction of data (some datasets are huge, but I still might need a small fraction of it without downloading the whole dataset)

Will Hugging Face consider this issue?  
Thanks again 🙏

---

<div class="post-metadata">

**Author:** ![stevhliu](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/stevhliu/32/18373_2.png) [@stevhliu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fstevhliu)%5C
**Post date:** [May 11, 2023, 4:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F4 "2023-05-11T16:02:14Z")

</div>

Hi, if dataset size is an issue you can consider [streaming](https://huggingface.co/docs/datasets/stream) the dataset instead. This way you don’t have to download it, but you can still use it.

---

<div class="post-metadata">

**Author:** ![eli4s](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/eli4s/32/56317_2.png) [@eli4s](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Feli4s)%5C
**Post date:** [May 12, 2023, 11:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F5 "2023-05-12T11:15:27Z")

</div>

Awesome, I hadn’t noticed this feature.  
Although streaming the dataset sounds awesome, sometimes you just want to have your dataset locally. For this reason, I am just asking the following questions :

- Am I able to load a small fraction of this dataset in streaming? for instance, running this command

```auto
dataset = load_dataset('oscar-corpus/OSCAR-2201', 'en', split='train[:1%]', streaming=True)

```

with the `[:1%]` in the train split and the streaming option `True`? (PS : I tried it with no success…)

- If so, am I able to then download this fraction of data locally?

- If not, can this issue be considered by Hugging Face?

Even though I believe that the streaming of datasets is a great tool, I just ask these questions for more specifications.  
Thank you all 🙏

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [May 12, 2023, 1:24pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-a-fraction-of-data%2F39373%2F6 "2023-05-12T13:24:33Z")

</div>

Loading a percentage in streaming mode is not implemented yet, because for some datasets we don’t know how many samples there are (e.g. for CSV files you need to download the full file to count the rows).

This can be supported for datasets with metadata about their length, or for supported formats like Parquet where the number of rows is available.
