feat: add column_map support to collate functions#561
Open
zamal-db wants to merge 1 commit intoPrunaAI:mainfrom
Open
feat: add column_map support to collate functions#561zamal-db wants to merge 1 commit intoPrunaAI:mainfrom
zamal-db wants to merge 1 commit intoPrunaAI:mainfrom
Conversation
Add an optional column_map parameter to all seven collate functions so users can pass custom HF dataset column names without renaming them first. Closes PrunaAI#297
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
After working through the evaluation metric issues in #560, I moved on to benchmarking against a couple of HF image-preference datasets. Tried loading
data-is-better-together/open-image-preferences-v1-binarizedviaPrunaDataModule.from_datasetsand immediately got aKeyError: 'image'because that dataset useschosen/promptinstead ofimage/text.The workaround is calling
dataset.rename_column()on every split before passing them in, but that gets old fast when you're iterating over several datasets. Noticed #297 describes the same problem and has been open for a while, so I went ahead and fixed it.What changed
Added an optional
column_mapparameter to all seven collate functions incollate.py. It accepts a dict mapping canonical names to actual dataset column names:No changes to
PrunaDataModuleitself were needed sincecollate_fn_argsalready flows through tofunctools.partial.column_map=None)_resolve_column()keeps things DRYimage_generation_collate,prompt_collate,prompt_with_auxiliaries_collate,audio_collate,image_classification_collate,text_generation_collate,question_answering_collateRelated Issue
Closes #297
Type of Change
How Has This Been Tested?
New
tests/data/test_collate.pywith 11 CPU tests covering every collate function with remapped columns, plus two end-to-end tests through the fullPrunaDataModule.from_datasetspipeline (one withcolumn_map, one without to verify backward compatibility). All pass withpytest -m cpu.Checklist
Additional Notes
None