Skip to main content

Minimal dataset builder for User/Assistant ML training data

Project description

🥛 milky

Minimal dataset toolkit for building and cleaning User/Assistant .mlk training data.

Designed for small language model pipelines like Author.


📌 Overview

milky is a lightweight utility for:

  • appending training pairs
  • reading .mlk datasets
  • validating dataset format
  • sanitizing corrupted samples
  • repairing broken entries
  • dataset statistics
  • dataset quality scoring
  • automatic formatting (multiline-safe)

It is intentionally simple and file-based.


⚙️ Initialization

When imported, milky prints:

[YYYY-MM-DD] Milky initialized.

📄 Dataset Format (.mlk)

Each line follows:

User: <prompt> Assistant: <response><eos>

Example

User: What is AI? Assistant: AI is the study of intelligent systems.<eos>
User: Write a poem Assistant: The sea is calm tonight...<eos>

🧠 Multiline Handling

milky automatically converts real newlines into safe escaped format:

\n → \\n

So all samples remain single-line safe.


🚀 API Reference


append()

append(prompt: str, response: str, target_file: str) -> None

Appends a User/Assistant pair to a .mlk dataset.

Behavior:

  • validates .mlk extension
  • automatically formats input (cleaning + newline escaping)
  • ensures single-line storage
  • appends <eos> token

read()

read(target_file: str) -> list

Reads dataset file.

Returns:

  • raw list of dataset lines

Notes:

  • validates .mlk extension
  • no parsing or decoding applied

check()

check(file_path: str) -> list

Validates dataset structure.

Detects:

  • empty lines
  • missing User:
  • missing Assistant:
  • missing <eos>

Output:

  • colored CLI diagnostics
  • returns (line_number, error_type) list

sanitize()

sanitize(file_path: str, apply: bool = False)

Removes invalid dataset entries.

Removes:

  • empty lines
  • malformed samples

Behavior:

  • apply=False → preview only
  • apply=True → overwrites file

repair()

repair(file_path: str, apply: bool = False)

Attempts to fix malformed entries instead of deleting them.

Fixes:

  • adds missing <eos>
  • normalizes spacing
  • drops unfixable lines

Behavior:

  • apply=False → preview mode
  • apply=True → writes file

stats()

stats(file_path: str) -> dict

Computes dataset metrics.

Measures:

  • total lines
  • valid samples
  • empty lines
  • malformed lines
  • missing <eos>
  • average prompt length
  • average response length

Notes:

  • automatically decodes escaped newlines (\\n → \n)
  • used for dataset inspection before training

score()

score(file_path: str) -> float

Returns a 0–100 dataset quality score.

What it evaluates:

  • ratio of valid samples
  • malformed lines penalty
  • missing <eos> penalty
  • empty line penalty

Interpretation:

  • 90–100 → clean dataset (train-ready)
  • 70–89 → good but slightly noisy
  • 40–69 → needs cleaning
  • <40 → unsafe / unstable dataset

🧠 Design Philosophy

milky is:

  • minimal
  • dependency-free
  • file-based
  • strict format enforcement
  • optimized for small LLM pipelines

It does NOT:

  • support JSON / Parquet datasets
  • perform tokenization
  • handle streaming data
  • manage multi-file corpora

⚠️ Important Notes

  • .mlk format is strict
  • each sample must be single-line
  • <eos> is required for training stability
  • sanitize is destructive (use carefully)
  • repair is heuristic-based
  • formatting is automatic in append()

🥛 Why “milky”?

Because it turns raw text into structured training pairs — cleaning noise into model-ready data.


📦 Typical Workflow

append → check → stats → score → sanitize → repair → train

🚀 Example Workflow

append("Hello", "Hi!", "data.mlk")

errors = check("data.mlk")

info = stats("data.mlk")

quality = score("data.mlk")

cleaned, removed = sanitize("data.mlk", apply=True)

fixed, changes = repair("data.mlk", apply=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

milky-0.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

milky-0.1.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file milky-0.1.1.tar.gz.

File metadata

  • Download URL: milky-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for milky-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b6683d8b96f56b5aabdfe83b2014528c2dbf2c06c1e11f7a2297edf3975dbd8b
MD5 51aaa734d779099927e5801cf3e05aaa
BLAKE2b-256 66d947b9ce8ad38096459427043484089d9619e5c23b2e25145f680c5b45981c

See more details on using hashes here.

File details

Details for the file milky-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: milky-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for milky-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3f5e9264bbee6fffb9c3b422e61b9e08a64cc82abb5bca34686928ee351f9eb
MD5 2c5e19df24757adcabec6c78e843bc9a
BLAKE2b-256 a8dba0d9c8f9c394bbd7789d6bb3e25fe6f5fb23d393d93e523dc6af21100800

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page