feat: emit dataset statistics report alongside exports (#104)#113
Merged
Conversation
) Follow-up to lance-format#96. Adds an optional `<output_path>.stats.json` report so a training cut is auditable at a glance without loading the JSONL. - `ExportConfig.emit_stats` gates a stats artifact computed during the existing export pass (no extra dataset re-materialization). - `ExportStats` covers: - counts: examples, by `role`, by `source`, by `tenant`; - token stats (min/median/p95/max/mean) from `state_metadata.tokens_used`, falling back to a whitespace word-count proxy, with a `source` field (`tokens_used` / `length_proxy` / `mixed`); - grouping: `num_groups` + records-per-group distribution; - curation accounting: records excluded by reason (lifecycle, reward threshold, dedup, decontamination), derived from the curation counts; - reward distribution and `reward_source` breakdown (rollouts), plus the preference form. - With a train/eval split, each side gets its own `.stats.json`. Python: `ctx.export_training(..., emit_stats=True)` writes the sibling report; read it from `<output_path>.stats.json`. Tests: core (role/source/tenant counts, token stats + length-proxy fallback, lifecycle exclusions, rollout reward distribution, flag gating) and python (stats contents + flag gating). README updated. Stacked on lance-format#96 (PR lance-format#111) and lance-format#103 (PR lance-format#112). Closes lance-format#104
bc00d0f to
70cdf9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #96: emits an optional dataset statistics report (
<output_path>.stats.json) alongside each export so a training cut is auditable at a glance — without loading the JSONL. Closes #104.What it does
ExportConfig.emit_statsgates a stats artifact computed during the existing export pass (no extra dataset re-materialization).ExportStatscovers everything the issue asks for:role, bysource, bytenant;state_metadata.tokens_used, falling back to a whitespace word-count proxy, with asourcefield (tokens_used/length_proxy/mixed);num_groups+ records-per-group distribution;reward_sourcebreakdown (rollouts), plus the preference form..stats.json.Python
Tests
README updated.
Checks
cargo test -p lance-context-core --lib— 66 passedcargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings— cleanruff format --check,ruff check,pyright— cleantest_export_training.py— 12 passedAcceptance criteria (#104)
state_metadata.tokens_usedwhen available, with a documented fallback (whitespace word count)Closes #104