premixdb
premixdb is a declarative library for building reproducible data mixtures to improve llm pretraining.
Quick start
Run a premixdb shell without installing the library:
uvx --python 3.12 premixdb shell
The shell has already run these commands so you have p and db available:
import premixdb as p
db = PremixDB()
You can also use the tiny_shakespeare demo corpus of his plays:
from torch.utils.data import DataLoader
dataset = db.corpus('demo').query().mix()[0].torch()
batch = next(iter(DataLoader(dataset, batch_size=1)))
{'input_ids': tensor([[ 35, 52, 7336, ..., 628, 50256, 5097]]),
'attention_mask': tensor([[1, 1, 1, ..., 1, 1, 1]]),
'labels': tensor([[ 35, 52, 7336, ..., 628, 50256, 5097]])}
Full example
Capture a corpus snapshot. Filter the snapshot with a query. Mix query results into datasets. Train with Pytorch.
from torch.utils.data import DataLoader
c4 = db.corpus(
"c4",
p.HuggingFaceSource("datablations/c4-filter-small"),
limit=8,
)
oscar = db.corpus(
"oscar",
p.HuggingFaceSource("datablations/oscar-filter-small"),
limit=8,
)
query = c4.union(oscar).query(
steps=[
p.where(p.text.characters >= 200),
p.dedupe(),
p.where(p.language.en >= 0.75),
p.where(p.quality.educational_value >= 1.0),
]
)
mixtures = query.mix(tokens=256, sequence_length=64)
dataset = mixtures[0]
print(dataset.preview())
batch = next(iter(DataLoader(dataset.torch(), batch_size=1)))
Installation
To add as a dependency to your project use:
uv add premixdb
Metadata
Release files for premixdb 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| premixdb-0.1.1.tar.gz | 1.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| premixdb-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.8 MB
Release files / premixdb-0.1.1.tar.gz
| Download URL | premixdb-0.1.1.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a32cb5117a339d78b9c1b8eb8ee039a7fbf08e21ee02114124c9b44d5e6eaa43
|
|
BLAKE2b-256 checksum How to use checksums |
58a0ab82a3d3e5fd3b3a88d775803ad0be1b2705f5457bd497392ea9419862d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / premixdb-0.1.1-py3-none-any.whl
| Download URL | premixdb-0.1.1-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6761d91615545b65d30e4dd5eabd6dedce7a5633040e9ad1a2587cca0079a99
|
|
BLAKE2b-256 checksum How to use checksums |
6bf524f40022fe23c35e6a7049f800cfc38fe014e671b58cd002d732048a0d75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|