fix: normalize benchmark prompt CSV quoting before dataset creation - #9479
Merged
Conversation
The AILuminate reserve prompt set quotes prompt_text inconsistently: a prompt containing a newline or a double quote is quoted, but one containing a comma is not. A plain csv.DictReader splits that row across extra fields and drops the tail, so the prompt reached the model truncated with no error anywhere. The benchmark owner now repairs this in the prep step and uploads a re-quoted copy, so the enclave job keeps its plain csv.DictReader and the model owner reviews unchanged code. prompt_text is the last column, so anything csv splits off past the header belongs to it and re-joining on commas restores the original text exactly. The checked-in sample CSVs now carry the same inconsistent quoting as the real file so this path is actually exercised.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Problem
The AILuminate reserve prompt set quotes
prompt_textinconsistently — a prompt containing a newline or a double quote is quoted, but a prompt containing a comma is not. A plaincsv.DictReadersplits that row into 5 fields, puts the tail under the implicit restkey, and nobody reads it. The prompt reached the model truncated mid-sentence, the completion looked plausible, andsafety_eval_results.jsonreported it as a normal result — no error at any point.Found while checking whether the job would run on a real reserve-prompt file: one of 9 rows lost 13 characters silently.
Changes
read_prompt_csvreads withrestkeyand folds the spilled tail back intoprompt_text;normalize_prompt_csvwrites the result back out withcsv.DictWriter. Safe becauseprompt_textis the last column, so anything past the header belongs to it, and extras only appear for an unquoted field where the split was purely on commas — re-joining on,restores the text exactly.prompts/raw/and writes the re-quoted copy to theprompts/mock/andprompts/private/pathscreate_datasetuploads; the dev notebook folds it intostage_prompt_csv, which already copied into a temp dir.JOB_CODEis unchanged in both notebooks — still a plaincsv.DictReader. The fix stays on the benchmark owner's side, so the model owner reviews and approves exactly the code they did before.Both notebooks that read
data/*.csvare updated. Every othersafety_promptsreference in the repo uses the inline.txtprompts and is unaffected.Test plan
Executed the patched cells and then the unchanged
JOB_CODEwithsetup_model/generatestubbed:naive == repaired rows: Trueis the guarantee: a plainDictReaderon the upload returns exactly what the repairing reader parsed from the messy source. Same for the mock file and the dev notebook's mock job.pre-commit run --all-filespasses with no files modified.Not covered: real inference. Weights, JAX, and the enclave path are untested here — this only exercises CSV parsing and the output JSON contract.
Note for reviewers
A field can only be left unquoted in the sample data if it has no embedded
"and no trailing whitespace — thetrim trailing whitespacehook otherwise eats a trailing space and silently alters the prompt. That bit me once; the generator now asserts on it, anddata/README.mdrecords it.The colab notebook fetches these CSVs from
raw.githubusercontent.com/.../dev/, so it keeps getting the old clean files until this merges.