leanstral-mathlib-calibration-corpora / docs /corpus-construction.md
robbiemu's picture
Initial Leanstral calibration corpora release
90e7936 verified
|
Raw
History Blame Contribute Delete
7.43 kB
# Corpus construction and split design
## Purpose
These corpora were built as post-training quantization inputs for Leanstral
1.5 119B-A6B. They represent the text presented to the model during Lean and
Mathlib workflows. They are not proof-agent rollouts, instruction-tuning
examples, or correctness labels.
The builder treats deterministic source and validation rules as authoritative.
Model-assisted review may flag a candidate for inspection, but it cannot admit
a record that fails deterministic checks or overturn a deterministic decision.
## Pinned inputs
```text
Mathlib commit:
5e932f97dd25535344f80f9dd8da3aab83df0fe6
Lean toolchain:
leanprover/lean4:v4.29.1
LeanDojo version:
1.0.9
builder project revision recorded by V1:
05e9d49ed350cd358ce0314cb0c563850b8fd8c7
DataSeek revision recorded by V1:
4fbe94ef64ee1f07f80a1bd8c52e0889f4e4e33a
tokenizer:
mistralai/Leanstral-1.5-119B-A6B:tekken.json
chat rendering:
mistral-common Tekken v15, Mistral [INST]/[SYSTEM_PROMPT] template
```
Final token counts use the real target Tekken tokenizer and chat rendering.
Records retain both structured `messages` and the exact `rendered_text` sent to
calibration.
## Six deployment-shaped categories
The 512-record empirical distribution is fixed at A140/B110/C90/D70/E60/F42.
| Code | Category | Input represented |
| --- | --- | --- |
| A | Proof completion | A real theorem statement and bounded source context with the proof hidden. |
| B | Proof repair with diagnostics | A controlled broken proof or source fragment paired with the real Lean diagnostic. |
| C | Retrieval/context-heavy proof | A theorem request with source-grounded premise snippets, imports, or broader context. |
| D | Repository-local edit | A bounded file excerpt, target declaration, and concrete edit request. |
| E | Proof trace/tactic state | Source-derived proof-state or tactic-sequence text without requiring a live model rollout. |
| F | Explanation/formalization | Lean explanation, translation, or natural-language-to-Lean instructions. |
The categories are input-distribution strata. Acceptance does not depend on
whether Leanstral answers the prompt correctly.
## Deterministic construction pipeline
For every candidate, the builder:
1. extracts a declaration, source span, module, and related source material
from the pinned Mathlib tree;
2. constructs a category-specific prompt while withholding material that would
leak the requested proof;
3. records canonical GitHub source provenance at the pinned commit;
4. renders the exact model-facing chat text;
5. counts tokens with the target Tekken tokenizer;
6. measures category, source, code/text ratio, context length, retrieval and
trace signals;
7. rejects hidden-proof leakage, malformed provenance, trivial tasks, and
exact or near duplicates according to deterministic rules; and
8. writes accepted and rejected records plus a run manifest and measurements.
`admission.soft_review_applied_to_decision` remains false. Soft review is
advisory and is not part of the admission authority.
## Record identity and leakage controls
Each published record carries a stable `sample_id`, source declaration, source
file, rendered text, and duplicate fingerprint. Split overlap was checked using
multiple identities rather than the sample ID alone:
- sample ID;
- declaration;
- source file where the protocol requires file-level separation;
- normalized rendered text;
- normalized user text; and
- the recorded duplicate fingerprint.
The 100-example `development` pack has zero sample-ID and fingerprint overlap
with the calibration variants. Its results informed V5 and V6, so it is
explicitly iterative validation rather than an untouched test.
The 144-example `release-validation` pack was frozen only after V1 had been
selected. It spans 138 source files and records zero overlap with V1–V6, the
development pack, and the historical validation pack across the protocol's
five identity checks. Model outputs were not used to choose its records.
## Calibration variants
### Variant 1: empirical baseline
V1 is the original 512-record A140/B110/C90/D70/E60/F42 distribution. It is
the selected release corpus.
### Variant 2: context enriched
V2 retains the category allocation while enriching eligible A, D, and F
records with real imports, namespaces, neighboring declaration statements,
and source-derived lemma hints. It tests whether V1 is under-contextualized.
### Variant 3: tail coverage
V3 changes category allocation to A100/B110/C120/D80/E80/F22 and deliberately
increases medium/long C, D, and E coverage. It tests whether a larger
long-context tail improves preservation.
### Variant 4: category-preserving length stratification
V4 retains A140/B110/C90/D70/E60/F42, builds an oversampled candidate pool,
and deterministically selects for greater length spread inside each category.
Eligible A, D, and F records receive the same source-grounded enrichment used
by V2.
### Variant 5: broad composite
V5 was designed after the first four profiles were evaluated. It selects whole
records—not scale values—from V1–V4 while retaining the empirical category
totals. Its final source counts are V1 363, V2 36, V3 45, and V4 68. The
development pack informed this design.
### Variant 6: constrained V1-centered composite
V6 retains 464 V1 records and substitutes 40 category-D plus 8 category-E
short/medium records drawn through V5's candidate evidence. Pairing is
deterministic, generally by nearest input-token count inside the category. It
was calibrated as one coherent profile; activation scales were never spliced
between profiles.
V6 improved mean KL relative to V1 in all five replicated starts but exceeded
the frozen NLL and Top-1 rejection margins in every start. It is published as
a negative experimental result, not a selected subset.
## Why Variant 1 is selected
Five normally autotuned cold starts evaluated frozen V1–V5 profiles against
one shared dynamic reference within each start. V1 won candidate NLL, signed
and absolute NLL preservation, Top-1 agreement, and flip count in all five
starts. V5's lower severe KL tail was real, but it consistently sacrificed the
central metrics. The fresh V6 test transferred much of that tail improvement
and reproduced the same central-quality cost.
The conclusion is specific and deliberately limited:
> Under normal FlashInfer startup variation, the exact frozen V1 corpus/profile
> pair best preserves ordinary predictive behavior under the project's frozen
> priorities. The available V5/V6 tail improvements could not be transferred
> without an unacceptable NLL and Top-1 cost.
## Length buckets
The serialized records use these measured Tekken ranges:
```text
tiny: <512 tokens
short: 512–2,047 tokens
medium: 2,048–8,191 tokens
long: 8,192–32,767 tokens
xlong: >=32,768 tokens
```
The public per-split manifests are generated from the JSONL files and contain
the actual category, length, token, source, and checksum statistics.
## Reproduction scope
The repository publishes the exact data and a methods description sufficient
to audit selection and reuse the samples with another quantizer. The original
builder workspace contains additional operational integrations and historical
runs that are intentionally not copied into this clean data release. That
omission does not change any published record or checksum.