Files
kuberdata/README.md
T

6.0 KiB

kuberdata

Large Language Model training dataset

Setup

Prerequisites

  • uv — a fast Python package and project manager. Install it with:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

    (or brew install uv on macOS)

  • A Python interpreter (e.g. 3.10+). If none is installed, uv can fetch one automatically:

    uv python install 3.12
    

Create a virtual environment

From the repository root, create and activate a virtual environment with uv:

# Create .venv (a Python interpreter is selected or fetched automatically)
uv venv

# Activate it
source .venv/bin/activate

Usage

dir-to-jsonl script

scripts/dir-to-jsonl.py reads all .json files in a directory, minifies each one, and appends them as lines to an output JSONL file. It uses only the Python standard library, so no extra packages are required.

python scripts/dir-to-jsonl.py <directory> <output.jsonl>

Example:

python scripts/dir-to-jsonl.py data/kubernetes-documentation-website/training training.jsonl

Notes:

  • The output file is appended to, so delete it first if you want a fresh build.
  • Files that fail to parse are skipped with a warning on stderr.

filter-common-corpus script

scripts/filter-common-corpus.py keeps openly licensed English prose from Common Corpus Parquet shards (PleIAs/common_corpus, common_corpus_1). It needs pyarrow, which is installed in this project's .venv.

.venv/bin/python scripts/filter-common-corpus.py \
  --input-file sources/raw/common_corpus_1/subset_9_1.parquet \
  --output-file corpora/english-prose.jsonl \
  --manifest-file corpora/english-prose.manifest.json

Rules:

  • English, Written documents only (no code, transcripts or semantic data).
  • Collections: Wikipedia, English-PD, US-PD-Books.
  • Licenses: Public Domain, CC0, CC-By, CC-By-SA. MIT, Apache and "Various" are excluded.
  • At least 50 words, mostly letters, and no <|im_*|> or <|pad|> tokens.
  • Exact duplicates are removed.

Each output line keeps identifier, collection and license, so attribution travels with the text. CC-By-SA documents carry share-alike obligations, and the manifest counts them. The manifest records input and output SHA-256 hashes and the number removed by each rule. Both output files are fresh; the script refuses to overwrite them.

Known limit: US-PD-Books contains OCR-damaged pages that pass the letter-ratio check. A dictionary-based OCR check is the next improvement.

Evaluation sets (eval/)

These sets are frozen and must never be used for training. They are committed to git so results can be compared across runs. Regenerate with the seeded script, and check that the output is unchanged before trusting an old result.

File Contents How answers were made
tool_calls.jsonl Requests with the expected kubectl_* call (or null when no tool is needed) Written from templates by scripts/build-eval.py, seed 20260101
manifest_reasoning.jsonl Synthetic cluster snapshots with a question and expected names Computed by code from the snapshot
concepts.jsonl 24 Kubernetes questions, each written from a held-out docs page (source field), with a reference answer and key terms Written by hand from pages excluded from training; checked for 8-word overlap with the training text
technical_heldout.jsonl Kubernetes docs, OpenAPI and deployment-docs records held out from training by path hash (about 10%) Selected by scripts/split-technical-docs.py
english_heldout.jsonl 200 documents sampled uniformly from corpora/english-prose.jsonl, capped at 600 words Sampled by code
english_heldout_ids.txt Identifiers of the held-out English documents Must be excluded from the training corpus
tools.json The tool schema shown to the model for tool_calls.jsonl Written by hand

Scoring is done by scripts/score-eval.py. It reads a predictions file with one {"id": ..., "reply": ...} line per item, and reports:

  • Tool calls: JSON parse rate, exact match on name and arguments, tool-name accuracy, and how often a tool was called when none was needed.
  • Manifest reasoning: exact match on the set of pod names found in the reply.
  • Concepts: key-term recall. This is only a rough check; it doesn't judge correctness.
.venv/bin/python scripts/score-eval.py --predictions predictions.jsonl --report report.json

English held-out perplexity needs the model, so score it with kubertrainer's test-model.py using eval/english_heldout.jsonl as the test file.

Training corpus: scripts/exclude-heldout.py writes corpora/english-train.jsonl with every held-out document removed, matched by identifier. It fails if any held-out identifier is missing.

Known limits: the generated items come from templates, so they test recognition of these phrasings, not general language. The concept questions are answered from held-out pages, so they test generalization beyond the training text. They are still paraphrases of general Kubernetes material, so treat them as a rough check. Earlier concept items were written from training pages and were retired; they remain in git history.

Kubernetes text (sources/kubernetes-sources.json)

The pinned sources are the English Kubernetes docs (kubernetes/website, CC BY 4.0) and the OpenAPI spec (kubernetes/kubernetes, Apache-2.0). Clone them into sources/raw/ at the commits in the manifest, then run:

.venv/bin/python scripts/build-k8s-text.py \
  --website sources/raw/kubernetes-website --website-commit <commit> \
  --swagger sources/raw/openapi/swagger.json --swagger-commit <commit> \
  --swagger-sha256 <sha256>

This writes corpora/kubernetes-docs.jsonl (1,381 pages, about 1.6M words) and corpora/kubernetes-openapi.jsonl (1,985 operation and object descriptions, about 0.27M words). Each record keeps its source path, commit and license. Docs are cleaned of front matter, Hugo shortcodes and HTML. OpenAPI prose is generated from the spec, not written by hand.