# How do i load part of the data set

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049%3E%5C
**Category:** Beginners\
**Created:** [April 30, 2025, 6:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049 "2025-04-30T18:34:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sKlklkjjkj](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@sKlklkjjkj](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FsKlklkjjkj)%5C
**Post date:** [April 30, 2025, 6:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049%2F1 "2025-04-30T18:34:29Z")

</div>

I have big dataset [un\_pc](https://huggingface.co/datasets/Helsinki-NLP/un_pc)

I want to load part like 200 k rows for start how do i do this

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 30, 2025, 9:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049%2F2 "2025-04-30T21:07:24Z")

</div>

I wonder if streaming would be a good option…

> **[Stream · Hugging Face](https://huggingface.co/docs/datasets/v3.5.1/stream)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> [@Best practices for a large dataset](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbest-practices-for-a-large-dataset%2F137632)%3A
>
> Hi, I have a ~1TB large dataset stored at the HF hub. I can download this on my disk and read it successfully. Nevertheless, it’s large enough that I can’t fit it in my RAM. What is the best practice for training a model on such a dataset? I tried loading the dataset with load\_dataset(..., streaming=True) and then having two buffers: one that is being loaded by training process onto GPU and one that, in a separate thread, streams from the dataset and fills up the other buffer. Then, when the i…

> [@How to load a large hf dataset efficiently?](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-load-a-large-hf-dataset-efficiently%2F69288%2F6)%3A
>
> It’s generally a good idea indeed if you want to save disk space or to not have to wait to download the full dataset. For example you can stream the dataset using the datasets library, by passing streaming=True to load\_dataset(). However even in streaming mode, you better have multiple shards in order to do parallel streaming. And ideally use file formats that work well with streaming like WebDataset or Parquet. @aaditya did try streaming mode on this dataset but the custom loading script of …

---

<div class="post-metadata">

**Author:** ![Victorano](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/victorano/32/32502_2.png) [@Victorano](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FVictorano)%5C
**Post date:** [May 2, 2025, 10:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049%2F3 "2025-05-02T22:19:05Z")

</div>

First, load the dataset from hf, then you can select how much rows you need.  
For example:

```auto
from datasets import load_dataset
dataset_name = "Helsinki-NLP/un_pc"
dataset = load_dataset(dataset_name, split="train")
train_dataset = dataset.select(range(200000))

```

Note that the full dataset will be downloaded on your computer but only the selected 200k rows will be the train\_dataset value

---

<div class="post-metadata">

**Author:** ![Zelgodiz](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zelgodiz/32/45662_2.png) [@Zelgodiz](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FZelgodiz)%5C
**Post date:** [May 5, 2025, 4:10am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-do-i-load-part-of-the-data-set%2F153049%2F4 "2025-05-05T04:10:39Z")

</div>

You can load a **subset** of your dataset in Hugging Face using the `load_dataset()` function with filtering options. Here are a few ways to do it:

### **1. Using `.select()` to Load a Specific Number of Rows**

If your dataset is already loaded, you can select **200,000 rows** like this:

```python
from datasets import load_dataset

dataset = load_dataset("your_dataset_name")
subset = dataset["train"].select(range(200000)) # Select first 200k rows

```

### **2. Using Streaming to Avoid Full Download**

If your dataset is **too large** to fit in memory, use **streaming mode** :

```python
dataset = load_dataset("your_dataset_name", split="train", streaming=True)
subset = dataset.take(200000) # Load only 200k rows

```

This prevents downloading the entire dataset at once.

### **3. Using `data_files` to Load a Specific File**

If your dataset consists of multiple files, you can load only a **specific portion** :

```python
dataset = load_dataset("your_dataset_name", data_files={"train": "train_part1.csv"})

```

For more details, check out the [Hugging Face documentation](https://huggingface.co/docs/datasets/loading) or [community discussions](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-just-part-of-dataset%2F38463). Let me know if you need help with a specific dataset! 🚀
