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 = p.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].train.torch()
next(iter(DataLoader(dataset, batch_size=1)))
{'input_ids': tensor([[45472, 10426, 1677, ..., 475, 286, 477]]),
'attention_mask': tensor([[1, 1, 1, ..., 1, 1, 1]]),
'labels': tensor([[45472, 10426, 1677, ..., 475, 286, 477]])}
Full example
Run from the repository root using the small checked-in C4 and S2ORC-derived samples. Capture snapshots, filter them, and mix the results for PyTorch training. Language and quality models download on first use.
from pathlib import Path
from torch.utils.data import DataLoader
c4 = db.Corpus(
"c4",
p.Source.read_jsonl(Path("examples/data/c4.jsonl"), limit=8),
)
papers = db.Corpus(
"papers",
p.Source.read_jsonl(Path("examples/data/s2orc-train.jsonl"), key_column="id"),
)
query = c4.union(papers).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, replacement=True, sequence_length=64)
dataset = mixtures[0]
print(dataset.preview())
batch = next(iter(DataLoader(dataset.train.torch(), batch_size=1)))
Installation
To add as a dependency to your project use:
uv add premixdb
- Runnable examples
- RegMix training search: train C4 topic/content-type mixtures and select weights by validation loss
- Model data recipes: T5/C4, Falcon, Gopher, LLaMA 1, GPT-3 with local sample inputs
- Curation · Fields · Training
- Storage · Internals · Development
Metadata
Release files for premixdb 0.1.3
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.3.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| premixdb-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.1 MB
Release files / premixdb-0.1.3.tar.gz
| Download URL | premixdb-0.1.3.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9c3ecfdbef4e25e6b644f4d8837f11596c172b5511e4d05c701ebdeae67a611
|
|
BLAKE2b-256 checksum How to use checksums |
d4fd6d45473a22c8e7a945e0e2b6c63c50438c20507acc161cd57bd0eaad10c2
|
| 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.3-py3-none-any.whl
| Download URL | premixdb-0.1.3-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffa82708b8578d4b9174168dd6e34009227b1d23fe8b6032563b9e055bf1577a
|
|
BLAKE2b-256 checksum How to use checksums |
fd7a23a6b19b321a39e489c7b0613ee72cc6de68a0787a12c374f6df6531dc58
|
| 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}
|