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.2.tar.gz (4.8 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.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: milky-0.1.2.tar.gz
  • Upload date:
  • Size: 4.8 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.2.tar.gz
Algorithm Hash digest
SHA256 766b069cec95a1bff4cda26587b3db4b36aed32744964d0fb0a073fe9496eb2a
MD5 6bdb349f5b2ddfa90d53b8fe6dc1636f
BLAKE2b-256 e3e1578915317af4e8dcc56ac46181109320624e2bc76044399cf1010a2a77bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: milky-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 999760467f160506a98c0b81514ec8b13dfb81ab405aa757df1ffd07c6ea900d
MD5 094c6cb2a15c8fc69119a3683fe7038b
BLAKE2b-256 5b322944ef7fabc224a6b4055cdacadd7a7743f66dedb4bb7a8da58ccffeabce

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