refactor: extract shared task utilities to reduce cross-task code duplication#1122
Merged
Conversation
Deduplicate the repeated YAML-loading boilerplate (open file, filter !function lines, yaml.safe_load) across 11 task utils into a single load_default_template_yaml() in _task_utils/default_template_yaml.py. Affected tasks: air_bench, blink, egoschema, erqa, illusionbench, mix_evals/image2text, mix_evals/video2text, perceptiontest/test, perceptiontest/val, where2place, worldqa.
Consolidate duplicated multi-choice response parsers (get_multi_choice_info, parse_mmmu_multi_choice_response, and variants for jmmmu, jmmmu_pro, videommmu) into a single shared module at _task_utils/mmmu_mcq_utils.py. Affected tasks: mmmu, mmmu/reasoning, mmmu_pro, mmmu_pro/reasoning, jmmmu, jmmmu_pro, videommmu, mmmu/utils_group_img.
Consolidate duplicated EvaluationTokenizer, remove_sp, compute_wer, and normalization helpers across 7 ASR task utils into a single shared module at tasks/asr_wer_utils.py. Affected tasks: common_voice_15, fleurs, gigaspeech, librispeech, open_asr, people_speech, tedlium.
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
default_template_yamlloader to shared_task_utils/default_template_yaml.py(11 task utils -> 1 shared, 9 lines)_task_utils/mmmu_mcq_utils.py(8 task utils -> 1 shared, 274 lines)tasks/asr_wer_utils.py(7 task utils -> 1 shared, 163 lines)Impact
Dedup Lines
_task_utils/default_template_yaml.py_task_utils/mmmu_mcq_utils.pytasks/asr_wer_utils.py