Add a pinned NERGAL 2.0.1 post-pass for built shards (v2#60)

#96
by ppuzio - opened
Fabryka AI org
•
edited 5 days ago

Prep for the NERGAL pass (slayerlabs/polish-dynaword-v2#60). No shard is changed; the pass itself runs after the v0.2.6 freeze, one source per PR.

  • src/nergal_pass.py <key> runs the built shard through SlayerLab/NERGAL 2.0.1, pinned to revision 960c515d96d34087ef1159c868a9d72e138834ab (tag v2.0.1). Every file in the snapshot (Hub download or --snapshot DIR) is checked against a sha256 pin (the same pins as dynaword-pipeline's nergal_snapshot.py).
  • It rewrites text, recounts token_count (changed rows only), and updates stats.json (tokens / characters) and sample.jsonl, keeping each file's format and line ending. It writes <key>.nergal.json: version, revision, options, device/dtype, counts, Parquet sha256 before/after. A shard that already has a record is refused. The sidecar formats are checked before the scrub, so a long run can't fail at the end.
  • Not rewritten: attribution text_sha256, manifests/checksums, card excerpts. The source's contract tests catch the stale ones; they get fixed in that source's PR along with the card's Privacy section and legal_note.
  • Placeholders: NERGAL ≥ 2.0.0 writes [PHONE], but AGENTS.md said [Telefon] (the pre-NERGAL scrubbers' tag; on main it appears in ted_pl 785×, sejm_interpellations 320×, kultura 12×). The pass renames [Telefon] → [PHONE] so a released shard uses one phone tag, and AGENTS.md now says [PII] / [PHONE].
  • src/nergal_requirements.txt: the pinned torch/transformers/tiktoken/pyarrow.

Checks:

  • src/test_nergal_pass.py: 10 tests with a stand-in scrubber (no torch).
  • Full suite: 713 passed.
  • Smoke run with the real pinned model (MPS, float32) on a synthetic 3-row shard: e-mail → [PII], phones → [PHONE], [Telefon] → [PHONE], the MP's name left in place. One miss: in tel. 601 222 333, PESEL 44051401359 the PESEL came out [PHONE]. The NERGAL card puts PESEL under [PII] and the rules give [PII]; the model labels the number a phone in a contact line (0.998) and the union ranks phone above pii. Alone, PESEL 44051401359. gives [PII]. A NERGAL bug, not policy.
  • render_sample.py: not applicable, no shard changed.

Known limits: one process, and the whole Parquet in memory (fine up to plwiki_user_talk's 380k rows). Masking can create new exact duplicates inside a source; dedup is not re-run.

🤖 Generated with Claude Code

ppuzio changed pull request status to closed
ppuzio deleted the refs/pr/96 ref

Sign up or log in to comment