gollek-ml-data
The gollek-ml-data module provides abstractions for data ingestion, processing, and batching. It implements a familiar Dataset and DataLoader pattern for efficient multi-threaded data loading.
🌟 Overview
Training deep learning models requires efficient handling of potentially massive datasets. This module provides standard patterns for loading common formats (CSV, Text, Images) and abstractions for building custom data pipelines with on-the-fly transformations.
🚀 Key Features
- Dataset Abstraction: Unified interface for indexed and iterable datasets.
- Multithreaded DataLoader: High-performance batching with pre-fetching and shuffling support.
- Predefined Datasets:
TextDataset: Stream-based loading of raw text files.CsvDataset: Fast parsing of tabular data.
- Support for Large Data:
StreamingDatasetallows processing of datasets that exceed system RAM. - Compatibility Layer: legacy dataset helpers such as
tech.kayys.gollek.train.data.ImageDatasetandtech.kayys.gollek.train.data.TokenizedDatasetremain available while migration continues.
📦 Installation
Add the following dependency to your pom.xml:
<dependency>
<groupId>tech.kayys.gollek</groupId>
<artifactId>gollek-ml-data</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
🛠️ Usage Examples
Loading a CSV Dataset
import tech.kayys.gollek.ml.data.CsvDataset;
import tech.kayys.gollek.ml.data.DataLoader;
CsvDataset dataset = new CsvDataset(Path.of("data/train.csv"), ",", true);
// Create DataLoader for batching
DataLoader<Map<String, String>> loader = new DataLoader<>(dataset, 32, true, false);
// Use in training loop
for (List<Map<String, String>> batch : loader) {
// ... convert rows to tensors
}
Working with Text Data
import tech.kayys.gollek.ml.data.TextDataset;
TextDataset trainData = new TextDataset(Path.of("corpus.txt"));
📖 API Highlights
tech.kayys.gollek.ml.data.DataLoader
The primary engine for data batching.
| Method | Description |
|---|---|
builder(Dataset d) |
Returns a builder for configuring batch size, workers, and shuffling. |
iterator() |
Returns an iterator that yields Batch objects. |
size() |
Returns the number of batches in the dataset. |
Dataset Implementations (Canonical)
CsvDataset: parses CSV rows to key/value maps.TextDataset: reads text lines or corpus-style textual data.StreamingDataset: interface for datasets read lazily from large sources.
Compatibility Dataset Surfaces
tech.kayys.gollek.train.data.ImageDatasettech.kayys.gollek.train.data.TokenizedDatasettech.kayys.gollek.train.data.DataLoader
These legacy classes are still available for older codepaths, but new module references should prefer tech.kayys.gollek.ml.data.*.