Skip to content

feat: emit dataset statistics report alongside exports (#104)#113

Merged
dcfocus merged 1 commit into
lance-format:mainfrom
dcfocus:feat/issue-104-export-stats
Jun 27, 2026
Merged

feat: emit dataset statistics report alongside exports (#104)#113
dcfocus merged 1 commit into
lance-format:mainfrom
dcfocus:feat/issue-104-export-stats

Conversation

@dcfocus

@dcfocus dcfocus commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

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.

Stacked on #111 (#96) and #112 (#103). Review/merge those first; until then this PR shows their commits too (the stats commit is last).

What it does

  • ExportConfig.emit_stats gates a stats artifact computed during the existing export pass (no extra dataset re-materialization).
  • ExportStats covers everything the issue asks for:
    • 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 + reward_source breakdown (rollouts), plus the preference form.
  • With a train/eval split (Reproducible train/eval split helper for post-training exports #103), each side gets its own .stats.json.

Python

ctx.export_training("training/sft.jsonl", task="sft", emit_stats=True)
# -> training/sft.jsonl.stats.json

Tests

  • core (4): role/source/tenant counts + token stats + lifecycle exclusions, length-proxy fallback, rollout reward distribution + reward_source, flag gating.
  • python (2): stats contents + flag gating.

README updated.

Checks

  • cargo test -p lance-context-core --lib — 66 passed
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings — clean
  • ruff format --check, ruff check, pyright — clean
  • test_export_training.py — 12 passed

Acceptance criteria (#104)

  • Export optionally emits a stats JSON with the counts/distributions above
  • Token stats use state_metadata.tokens_used when available, with a documented fallback (whitespace word count)
  • Curation accounting reports excluded counts by reason
  • Stats computed in the export pass (no full re-materialization)
  • Tests verify counts/distributions against known fixtures

Closes #104

)

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
@dcfocus dcfocus force-pushed the feat/issue-104-export-stats branch from bc00d0f to 70cdf9d Compare June 27, 2026 06:24
@dcfocus dcfocus merged commit eebb33b into lance-format:main Jun 27, 2026
9 checks passed
@dcfocus dcfocus deleted the feat/issue-104-export-stats branch June 27, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit dataset statistics report alongside post-training exports

1 participant