When streaming is the only option
For datasets larger than your disk — FineWeb, RedPajama, common-crawl-derived sets — streaming=True is mandatory. The returned IterableDataset never materializes; it pulls examples on demand from the underlying Parquet shards.
What changes
- No
len(), nods[i]. Forward-only iteration. mapstill works, but is lazy (transforms on iteration, not pre-baked).filterworks, but the rejection rate matters — if you filter 99%, you waste 99% of your I/O.shuffle(buffer_size=N)uses a reservoir sample of size N, not a global shuffle.
Multi-shard sharding for distributed training
iter_dataset = ds.shard(num_shards=8, index=worker_id) hands different shards to different DataLoader workers. The distributed hint in load_dataset(..., streaming=True) handles this automatically when you wrap with PyTorch's DataLoader in a DDP setup.