Repository navigation
FIX: Reject surplus CSV fields that shift evaluation responses - #4851
biefan (biefan) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change that rejects malformed human-labeled CSV records.
No open issues 🎉
What changed in this PR
Fixes #4850 by rejecting malformed human-labeled CSV files that cause pandas to silently shift evaluation responses and labels.
Changes:
- Rejects inferred indexes with an error identifying the CSV and explaining comma quoting.
- Adds regression coverage for surplus fields in objective and harm datasets, plus correctly quoted multiline responses.
| File | Description |
|---|---|
tests/unit/score/test_human_labeled_dataset.py |
Tests malformed records and preservation of quoted responses. |
pyrit/score/scorer_evaluation/human_labeled_dataset.py |
Rejects inferred indexes before extracting evaluation data. |
Review effort: Balanced
|
Fixed the Windows regression test in 7baf2fc. The Windows failure log showed that the CSV writer produced CRLF inside the quoted response and the loader correctly preserved it, while the assertion expected LF. The test now writes LF and CRLF explicitly and checks that each survives the round trip. The dataset and evaluator suites passed locally on Python 3.13 and 3.14 (350 tests on each). |
|
The Windows matrix passed on The log reports: This PR changes the evaluation CSV loader and its tests. The timeout occurred in the Markdown scaling test covered by #4842. |
Description
Closes #4850.
A human-labeled CSV whose first data record has more fields than its header can make pandas infer an index from the leading fields. For example,
Good morning, Alice,greeting,1under a three-column header used to load as the responseAlicewith a valid positive label.The loader now rejects an inferred index before it extracts responses and labels. The error names the CSV and explains how to quote a comma inside a field. Regression tests exercise objective and harm datasets with one or two excess fields, and verify that a correctly quoted response containing both a comma and a newline round-trips intact.