Add frozen eval sets and scorer; document both

This commit is contained in:
Daniel Samson committed 2026-11-21 12:15:58 +00:00
1 parent 6965ab25db
commit b37df2b05a
9 files changed
+914

No files matched your search

+66
View File
@@ -52,3 +52,69 @@ 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.