Repository navigation
FIX: Use the canonical leading-comment rule when loading classifier CSVs - #3291
Queued
Chen Yufeiyang (feiiiiii5) wants to merge 8 commits into
Queued
Chen Yufeiyang (feiiiiii5) wants to merge 8 commits into
Chen Yufeiyang (feiiiiii5) wants to merge 8 commits into
Conversation
The two local classifier scorers hand-rolled how they skip a dataset's leading '#' comment lines, and neither matched HumanLabeledDataset._read_leading_comment_block: - LocalRefusalClassifierScorer dropped every line starting with '#', including data rows and lines inside quoted cells; the packaged refusal.csv already has one training response truncated by this (4161 vs 4257 characters). - LocalViolenceClassifierScorer skipped only the first line, so a file with several leading '#' lines (or a blank line first) quietly loaded zero rows and then failed with a misleading not-enough-training-data error. Both now use a shared strip_leading_comment_block() helper with the canonical scan: only the leading comment/blank block is removed, everything from the first content line on is data.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c89266be-249b-4382-bfd3-0a3b3c449ae3
Keep universal newline recognition without translating CR or CRLF in the leading-comment scan and both classifier CSV readers. Cover mixed quoted-cell and record separators, blank/comment prefixes, and non-newline separators. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c89266be-249b-4382-bfd3-0a3b3c449ae3
Preserve the contributor's concurrent fix and mixed-newline regression tests alongside the expanded separator matrix and latest main. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c89266be-249b-4382-bfd3-0a3b3c449ae3
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c89266be-249b-4382-bfd3-0a3b3c449ae3
Roman Lutz (romanlutz)
approved these changes
Oct 20, 2026
Roman Lutz (romanlutz)
enabled auto-merge
October 20, 2026 03:11
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 20, 2026
This branch has not been deployed
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.
Description
Both local classifier scorers hand-rolled how they skip a dataset's leading
#comment lines, and neither matchedHumanLabeledDataset._read_leading_comment_block(the rule settled in #2983):LocalRefusalClassifierScorerdropped every line starting with#, including data rows and lines inside quoted cells.refusal.csvin the package already has one training response truncated by this (4161 vs 4257 characters, row 70); a data row whose first cell starts with#was silently dropped altogether.LocalViolenceClassifierScorerskipped only the first line, so a file with two or more leading#lines (or a blank line before the comments) quietly loaded zero rows and then failed with a misleading "not enough training data"ValueError.Both loaders now use a shared
strip_leading_comment_block()helper (pyrit/common/csv_helper.py) with the same scan as the canonical reader: only the leading comment/blank block is removed; everything from the first content line on is data. Dataset bytes, hash pins and_RECIPE_VERSIONare untouched.Tests and Documentation
New regressions in
tests/unit/score/test_local_refusal_classifier_scorer.pyandtest_local_violence_classifier_scorer.py: both fail onmain(a#-prefixed row dropped / rows read as empty) and pass with the fix. Relevant suite green: the two classifier test files (-kloader/pin selection; the real-tokenizer cases need a working transformers env),test_human_labeled_dataset.py,test_scorer_eval_csv_schema.py;ruff check/ruff format --checkclean on the touched files (0.17.0, matching pre-commit). No JupyText sample is involved and no documentation change is needed since the rule itself is unchanged.