cd /news/ai-tools/download-a-fraction-of-data-from-hug… · home › topics › ai-tools › article
[ARTICLE · art-144626] src=discuss.huggingface.co ↗ pub= topic=ai-tools verified=true sentiment=· neutral

Download a fraction of data from HuggingFace Datasets

A Hugging Face user asked how to download roughly 15GB from each language subsection of the bigcode/the-stack dataset instead of pulling entire subdirectories via load_dataset, and community respondents pointed to the allow_patterns filter in snapshot_download plus the datasets library's data_dir and data_files options. The original poster confirmed they resolved the issue by using HfApi to list repo files and their sizes, though respondents noted that approach does not let you specify a target size or file count directly. A later commenter, Deniz, asked whether the same method works for 20-30GB zipped files that they do not want to download whole.

read1 min views1 publishedOct 3, 2026
Download a fraction of data from HuggingFace Datasets
Image: Discuss (auto-discovered)

hey all, I want to download about 15GBs of data from each subsection/language of the stack dataset. Is there any way to do this?

I can download the entire subsection using following code snippet, but i want a fraction of the data(decided by a percentage or number of files).

from  datasets  import  load_dataset
ds = load_dataset("bigcode/the-stack", data_dir="data/c", split="train")

Thanks in advance

I think it should be possible if you specify the directory name in the allow_patterns filter for snapshot_download.

I’m not very familiar with it, but it seems that the datasets library itself also has functions to extract a part of a dataset.

yeah, it has data_dir and data_files, but what I was looking for was be able to download 10 GBs or 10 files of data , what the above will do is download the complete sub directory.

I think this is close, but technically speaking, it’s not the number of files, and you can’t specify the size.

You can use HfApi to get a list of the files in a repo and see their sizes, but that’s almost like doing it manually…

yes, thats what I did, thanks for the help btw.

Hello,

Is the method applicable for zipped filestoo?

I have some zippred files aroudn 20 30 GB but I dont want to download them as a whole

Best,

Deniz

── more in #ai-tools 4 stories · sorted by recency
── more on @hugging face 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/download-a-fraction-…] indexed:0 read:1min 2026-10-03 · —