Skip to content

Add config-driven corpus normalizer for base datasets - #1

Merged
SheeshDarth merged 1 commit into
mainfrom
sp/corpus-normalizer
Aug 7, 2026
Merged

Add config-driven corpus normalizer for base datasets#1
SheeshDarth merged 1 commit into
mainfrom
sp/corpus-normalizer

Conversation

@SheeshDarth

Copy link
Copy Markdown
Owner

What (S1 — Data & Bench, Week 1)

Normalizes base corpora into the canonical Sample schema as JSONL — the data foundation S2's feature suite and S3's fine-tune grid both consume.

  • src/ingestion/normalize_corpora.py — pure _normalize_rows() core that reuses the existing normalize_record() / write_jsonl() rather than duplicating validation. Skips blank rows (WikiText is full of them), stamps the clean human baseline (source=human, generation=0), and derives ids from the source row index so re-runs are byte-identical. datasets / yaml are imported lazily, so the module and its tests load offline.
  • configs/corpora.yaml — WikiText-2 (train/validation/test) + TinyStories (capped slice). Config-driven, no magic numbers.
  • tests/test_normalize_corpora.py — 7 offline tests.
  • requirements.txt — add pyyaml.

Verification

  • pytest -q17 passed (10 existing + 7 new)
  • python -m src.ingestion.normalize_corpora --help → CLI wired
  • Config parses and drives a full normalize → write → reload roundtrip

To produce the actual data (not committed — data/ is gitignored):

pip install datasets pyyaml
python -m src.ingestion.normalize_corpora --config configs/corpora.yaml

Review note

Requesting one teammate approval per the Definition of Done. Worth a look at the id scheme: ids key on the source row index, so skipped blank rows leave intentional gaps (0, 2, 5...) — this keeps ids stable if filtering rules ever change.

S1 (Data & Bench) Week-1 deliverable. Normalizes Hugging Face corpora into the
canonical Sample schema as JSONL, so every downstream module consumes one
format.

- src/ingestion/normalize_corpora.py: pure _normalize_rows() core reusing the
  existing normalize_record()/write_jsonl(); skips blank rows (WikiText is full
  of them), marks rows as the clean human baseline (source=human, generation=0),
  and derives ids from the source row index so re-runs are reproducible.
  `datasets` and `yaml` are imported lazily, keeping the module importable
  offline.
- configs/corpora.yaml: WikiText-2 (all splits) + TinyStories (capped slice).
- tests/test_normalize_corpora.py: 7 offline tests (blank skipping, provenance
  defaults, deterministic ids, row cap, custom text field, split validation).
- requirements.txt: add pyyaml.

Run: python -m src.ingestion.normalize_corpora --config configs/corpora.yaml
@SheeshDarth
SheeshDarth merged commit 9f2dedd into main Aug 7, 2026
1 check passed
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.

1 participant