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
Metadata
Release files for lotd 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lotd-0.1.4.tar.gz | 46.8 kB | Without provenance | Details for lotd-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lotd-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for lotd-0.1.4-py3-none-any.whl |
Total release size: 82.0 kB
Release files / lotd-0.1.4.tar.gz
| Download URL | lotd-0.1.4.tar.gz |
|---|---|
| Size | 46.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0abdb9a6facfe14b60a6ccaf205b173a03b88b395c33bf2367e8f6270c420ad
|
|
BLAKE2b-256 checksum How to use checksums |
20fb388c94841486edc3bff57dda175962038bb80d984afc65c39c3667bc3c81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Release files / lotd-0.1.4-py3-none-any.whl
| Download URL | lotd-0.1.4-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
130bdf61bb376b4d06a464cecadd8c2c92890d1170b522b5e6838471f94eb3db
|
|
BLAKE2b-256 checksum How to use checksums |
1394db16f1afaf8a900c27a36d1468944390024d52f3dbc3d19a5b5a8c378b38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Security for lotd 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.