feat: multi-model and multi-label classify-warc output#22
Merged
Conversation
`classify-warc` now scores each record against any number of fasttext models in one pass, and any number of labels per model, instead of one label from one model. `--model-repo`/`--model-file`/`--labels` are parallel-list flags; `*` (the default for `--labels`) expands to every label of that model via `model.get_labels()`. Output columns are `score_<label>` for a single model and `score_m<idx>_<label>` for multiple, so two models can share a label name (e.g. both GneissWeb classifiers emit `__label__cc`) without colliding. Also: `--overwrite` to replace an existing output instead of failing; `--resume-from-output` validates the prior CSV's header is byte-equal to the new run's schema (with a structured added/removed diff on mismatch); per-label stats land in the sidecar as `score.<column>.*`.
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
classify-warcnow scores each record against N fasttext models × M labels per model in one pass, via parallel-list--model-repo/--model-file/--labelsflags (with*= all labels of that model, the default).score_<label>for a single model,score_m<idx>_<label>for multiple — so two models can share a label name (e.g. both GneissWeb classifiers emit__label__cc) without collision.--overwriteto replace an existing output instead of failing fast.--resume-from-outputvalidates that the prior CSV's header byte-matches the new run's schema, with a structured added/removed-columns diff on mismatch.score.<column>.<stat>; the sidecar'sarg.score_columnsrow records the resolved label vocabulary so a run is reproducible from the summary alone.SCORE_COL(auto-detected fromscore_*columns, with aprediction_scorefallback for legacy CSVs).Test plan
make check— ruff lint, ruff format, pytest (63 pass, 1 skipped real-model)pytest --run-real) — language-id classifier round-trip with new column namingscore___label__scienceandscore___label__cc, per-row sum ≈ 1.0, quantum-mechanics doc → 1.0 sciencescore_m0___label__cc, score_m0___label__science, score_m1___label__hq, score_m1___label__cc(auto-namespaced, no collision)--resume-from-outputagainst a CSV with different columns errors with a structured added/removed diff--overwritewarns + rewrites; absence still errors with a message pointing at the new flagprediction_scorefallback path