premixdb
premixdb is a declarative language for building reproducible data mixtures to improve llm pretraining.
uv add premixdb
Capture, filter, mix, train
import premixdb as p
from torch.utils.data import DataLoader
with p.PremixDB(storage=".premixdb") as db:
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(),
]
)
print(query.preview())
mixtures = query.mix(tokens=256, sequence_length=64)
print(mixtures.weights)
print(mixtures.profile())
dataset = mixtures[0]
print(dataset.preview())
batch = next(iter(DataLoader(dataset.torch(), batch_size=1)))
A mix creates three candidate datasets by default. Repeat a recipe to reuse its
results. Keep .premixdb to reopen your corpora and datasets.
Use the fields you need
with p.PremixDB(storage=".premixdb") as db:
query = db.corpus("c4").query(
steps=[
p.where(p.language.en >= 0.75),
p.where(p.quality.educational_value >= 1.0),
]
)
print(query.profile())
print(query.preview())
Fields are computed on demand and cached. Model fields download their assets on first use. The default dataset tokenizer is bundled GPT-2; use your model's tokenizer for training.
Explore
uvx --python 3.12 premixdb shell
The shell opens with db, p, and an offline Shakespeare demo corpus.
From a checkout, use make shell (uvx --from . premixdb shell).
Use make install for an editable local CLI install.
Metadata
Release files for premixdb 0.1.0
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.0.tar.gz | 1.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| premixdb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.8 MB
Release files / premixdb-0.1.0.tar.gz
| Download URL | premixdb-0.1.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
baf23484db8e49edb17ac9fecdf83ca88e798a9ca91bd51b7101f32beed936c8
|
|
BLAKE2b-256 checksum How to use checksums |
e90d5528f4c86fd50dad845e0f68d804162262daf6196c92c5692ae2a79a5e2f
|
| 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.0-py3-none-any.whl
| Download URL | premixdb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7992b344d9dcdb7d82bda83eb4150f25f292cc209064329ce1bab648fda977a6
|
|
BLAKE2b-256 checksum How to use checksums |
695734a163f2c48b92aaf77e81b62b964309f469a5177ccce3949315878a9c1f
|
| 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}
|