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.1.tar.gz (110.4 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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dsiter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4a63e972b8b783beb1fea638f1f9e1add485c7fdf52dbab5b27627198c4ebeb8
MD5 403e7b88a496b9bf46fb3816b178545c
BLAKE2b-256 110fbea5f6d7565d268cfd7de03e4fad9d545457d7bc4a9942803e33b75edd44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dsiter-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5929edc96e8d9b5d88c4470cc41415fa8c8e21f9535633d096ac4cc705f37a9f
MD5 7655fcb9adaf638390eca33b78026e4d
BLAKE2b-256 d922171cee048cc212ace1e6c01a8c1041ffa4dff5063c327a1d926977760707

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