Hugging Face, End to EndLesson 40 of 75

Module 5 · Datasets, and the work that happens before any model

Why a 300 GB dataset opens instantly

In this lesson

  • 8 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 3 of 10 in this chapter

This chapter’s goalInspect, stream, filter and transform a dataset far larger than your RAM, query the Hub’s parquet conversion with SQL before downloading anything, run duplicate, leakage and class-balance checks on your own data, and publish it with a card stating provenance and licence.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch2:05Not available
Full audiobookNot availableNot available
Memory-mapped or streamed: what you tradeRandom accessDisk it needsDownloadedInstantRow three million worksThe whole setLimited by disk, not RAMstreaming=TrueNoneIterate, and no len()NothingRows arrive over HTTPNeither is limited by RAM. The rule for choosing is how many passes you will make: stream when youwill read the data roughly once, download when you will read it several times, because re-streamingevery epoch means re-downloading every epoch.
Neither is limited by RAM. The rule for choosing is how many passes you will make: stream when you will read the data roughly once, download when you will read it several times, because re-streaming every epoch means re-downloading every epoch.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The thing that should not work

Python
ds = load_dataset("wikipedia", "20220301.en", split="train")
print(len(ds))      # 6,458,670
print(ds[3_000_000]["title"])

That is roughly 20 GB of text, opened on a laptop with 8 GB of RAM, and the row access returns immediately. Nothing was loaded into memory. Understanding why changes how you work with data for good.

Arrow, and memory mapping

The library stores datasets as Apache Arrow files on disk: a columnar binary layout where every value’s position is computable rather than searched for. It then memory-maps the file: asks the operating system to make the file’s bytes appear at an address range, without reading them.

When you touch row three million, the OS faults in the few pages that hold it. Pages you never touch are never read. Pages you stop using are evicted by the OS under memory pressure, with no work from Python.

Three consequences, all practical:

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Image Generation, in Practice exam.

Stuck on something?Ask Arjun, your AI tutor

How to cite: Addaly (2026) ‘Why a 300 GB dataset opens instantly’, in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/arrow-and-memory-mapping (Accessed: 29 November 2026).