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.3.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.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dsiter-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 06e3aa4d623678365980f107dabe33f4df612772cbdf75a838174b273d2b08b1
MD5 837d050cb4bb0115b8f1541a05733c6e
BLAKE2b-256 b3ad8ee42ebcfb563bfc9c3fba089c6c2cca06d503106085a009fa53d9767cec

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dsiter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 041825e2fe9b9f37d47a275486f224e296b00effe2670a043fedbda09fe71d9d
MD5 93397649d2f66fa92e428e8b747420d6
BLAKE2b-256 e5c2d64644591890db3ee34ab5f8d4249612358d978535663bb1acd17953e09d

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