Skip to main content

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].torch()
next(iter(DataLoader(dataset, batch_size=1)))
{'input_ids': tensor([[45472, 10426,  1677,  ...,   475,   326,   314]]),
 'attention_mask': tensor([[1, 1, 1,  ..., 1, 1, 1]]),
 'labels': tensor([[45472, 10426,  1677,  ...,   475,   326,   314]])}

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, replacement=True, 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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for premixdb 0.1.2
File Size Uploaded
premixdb-0.1.2.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for premixdb 0.1.2
File Interpreter ABI Platform
premixdb-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.8 MB

Release files / premixdb-0.1.2.tar.gz

Download URL premixdb-0.1.2.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
7f7df1065bc7f2d68ae4f10a36808e23ee2c192a8b735f9832ddc44eb281fd21
BLAKE2b-256 checksum
How to use checksums
3fdf4d0cc915177a4362fa2f2b16cde80dec382e0f303618fb633c8d6a69bb87
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.2-py3-none-any.whl

Download URL premixdb-0.1.2-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
cc8fda167c44c689f5774acbdbf9077d7e5ed26bdda4d261c290afe9093f4f5d
BLAKE2b-256 checksum
How to use checksums
5ab662ce691eb5c1ef06c825ec3b8a7922ce996754ef95e8fad895e8153f7365
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 history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page