121 lines
4.7 KiB
Markdown
121 lines
4.7 KiB
Markdown
# kuberdata
|
|
|
|
Large Language Model training dataset
|
|
|
|
## Setup
|
|
|
|
### Prerequisites
|
|
|
|
- [uv](https://docs.astral.sh/uv/) — a fast Python package and project manager. Install it with:
|
|
|
|
```sh
|
|
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:
|
|
|
|
```sh
|
|
uv python install 3.12
|
|
```
|
|
|
|
### Create a virtual environment
|
|
|
|
From the repository root, create and activate a virtual environment with uv:
|
|
|
|
```sh
|
|
# 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.
|
|
|
|
```sh
|
|
python scripts/dir-to-jsonl.py <directory> <output.jsonl>
|
|
```
|
|
|
|
Example:
|
|
|
|
```sh
|
|
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`.
|
|
|
|
```sh
|
|
.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` | 35 Kubernetes concept questions with a reference answer and key terms | Written by hand; review before relying on them |
|
|
| `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.
|
|
|
|
```sh
|
|
.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. Some concept questions will overlap with the Kubernetes docs,
|
|
so keep those docs out of the training data if you use this set to judge knowledge.
|