Skip to main content

A library for iterating over aggregated datasets from HuggingFace and local CSV files

Project description

dsiter

ds-iter (ds is short for "dataset" and iter for "iteration") is an opinionated, declarative dataset preparation/iteration tool that helps you create an single iterator over many datasets, useful for ML/data engineering tasks.

Problem

During the training of large-scale machine learning models (especially language models or NLP tasks), we're often working with many different datasets from various sources, with very different shapes and dimensions, sometimes reaching gigabytes of data.

Failure in implementing efficient memory usage within training or data preparation scripts often leads to operating system errors, such as OOM killed.

ML/data engineers tend to write custom scripts, often with bespoke pre-processing/post-processing mutations, and sometimes entirely different implementations of the data preparation step across projects. This can lead to reproducibility issues, as different team members using slightly different scripts produce inconsistent results. Additionally, debugging becomes difficult because OOM errors or preprocessing bugs are often non-deterministic and hard to trace.

Usage

step one: create yaml configuration file

create a yaml file (by default the library looks for datasets.yaml) and start adding your Hugginface 🤗 datasets using their repoId like below:

Example: See examples/datasets.yml for a complete configuration file with various dataset types.

datasets:
  - path: facebook/recycling_the_web

you can add as many Hugginface 🤗 datasets as you want:

datasets:
  - path: facebook/recycling_the_web
  - path: Lk123/InfoSeek
  - path: ...
  - path: ...

you can also load your own custom dataset files, supported formats are:

  • csv or tsv
  • parquet

just pass the relative/absolute path of the dataset with path key.

datasets:
  - path: ./files/dataset_dump.csv
  - path: ./files/other_dataset.tsv
  - path: ./files/other_other_dataset_0001.parquet

for each dataset you can target an array of specific columns to be returned within iterator:

datasets:
  - path: MathLLMs/MathVision
    columns:
      - questions

  - path: community-datasets/farsi_news
    columns:
      - title
      - summary

step two: python scripting

install the library using pip

pip install dsiter

and then:

Example: See examples/example.py for a complete working example.

from dsiter import DSIterCollection

collection = DSIterCollection()

for row in collection.iter_rows():
    print(row)

Calling iter_rows() lazily streams the dataset's rows through a generator, enabling efficient iteration and processing without loading the entire dataset into memory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsiter-0.1.2.tar.gz (110.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsiter-0.1.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file dsiter-0.1.2.tar.gz.

File metadata

  • Download URL: dsiter-0.1.2.tar.gz
  • Upload date:
  • Size: 110.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for dsiter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f7e26a4e655253059142346d6edfd60e44730cc11c2aa000398ebd5094b81a10
MD5 e7db90861868a2285703dd1276f2f1bc
BLAKE2b-256 4b7bbece2c202b5cadb4614049e3ffa5e8a402a4899f7cbb0c46f5c6e9aac80c

See more details on using hashes here.

File details

Details for the file dsiter-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dsiter-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for dsiter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 26d607d54fb07c6828c6d4e0c7cba65f939280adf7066622a04d80bea7480343
MD5 053ea18b326a85c120d88fcc947c70fa
BLAKE2b-256 07ee2c7f2983a4ba3bb1925648812fa65098303e93bcdcc97259114f87a4bfd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page