Lord of the Datasets - Efficient NLP dataset preprocessing
Project description
LOTD - Lord Of The Datasets
Efficient NLP dataset preprocessing library for instruction tuning and general NLP tasks.
Features
- Chat and text tokenization
- Length filtering
- Padding collators
- HuggingFace dataset utilities (splitting, caching, dataloaders)
- Prebuilt Alpaca dataset loader
Documentation
This package provides MkDocs documentaion.
Usage examples can be found in examples directory.
Installation
pip install lotd
Example Usage
from lotd import ChatTokenizer, PadCollator, get_loaders, datasets
# Preprocess dataset
dataset = my_dataset.map(
ChatTokenizer(my_pretrained_tokenizer),
input_columns=["prompt", "output"],
batched=True,
batch_size=512,
)
# Filter by length
dataset = dataset.filter(
LengthFilter(min_length=0, max_length=max_length),
input_columns=["input_ids"],
batched=True,
batch_size=512,
)
# Create DataLoaders
train_loader, val_loader, test_loader = get_loaders(
dataset, collate_fn=PadCollator(pad_id=0)
)
# OR use pre-configured datasets
from lotd.datasets import alpaca
train_loader, val_loader, test_loader = alpaca(tokenizer=my_tokenizer)
Build
- Clone this repo:
git clone https://github.com/alex-karev/lotd.git
cd lotd
- Install build tools:
pip install --upgrade build setuptools wheel
- Build package:
python -m build
- Install:
pip install dist/lotd-0.1.0-py3-none-any.whl
Nix
You can include LOTD in another project with Nix Flakes:
{
description = "My NLP Project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
lotd = {
url = "github:alex-karev/lotd"; # LOTD flake
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, lotd }: let
pkgs = import nixpkgs { system = "x86_64-linux"; };
devShells.default = pkgs.mkShell {
name = "my-nlp-project";
packages = [
(pkgs.python312.withPackages (python-pkgs: [
lotd.packages.x86_64-linux.lotd
# other python packages
]))
];
};
};
}
License
See LICENSE
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
lotd-0.1.2.tar.gz
(46.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
lotd-0.1.2-py3-none-any.whl
(34.7 kB
view details)
File details
Details for the file lotd-0.1.2.tar.gz.
File metadata
- Download URL: lotd-0.1.2.tar.gz
- Upload date:
- Size: 46.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1a18df9a73faf2954078b85512f521da5ad7bae9a2063a30fe4a13710a4567
|
|
| MD5 |
525fc916ab31b0292342ef1d3a84d81e
|
|
| BLAKE2b-256 |
e92695e7462aa941050d2b2527c44fe4b5896d7a0257fd3ae05fa545cfef0eea
|
File details
Details for the file lotd-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lotd-0.1.2-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc457acc2984df41584f7d2184b9cbaf7f2424a8186584dbeaa085238bf46943
|
|
| MD5 |
f9a7e451ba82d660fbdf1ec8cac12312
|
|
| BLAKE2b-256 |
89d7c88e3e933c60deb11b2ad1246369cd422bbaad6f0f311cba641e33f465b3
|