Align vision VQA eval: dynamic choice detection, configurable max_length, robust error handling#2499
Merged
Merged
Conversation
1719469 to
96fc4c3
Compare
- Change option numbering from 0-based to 1-based (1, 2, 3, 4) in vision_vqa_pre_process to match how VLMs are typically prompted - Convert ground-truth answer index from 0-based to 1-based accordingly - Update extract_number regex from leading-only (^\d+) to search-anywhere (\b[1-4]\b) with fallback, matching eval.py's lenient parsing behavior This aligns the Olive JSON-based evaluation with the standalone eval.py script, fixing a ~10pp accuracy gap caused by 0-based numbering confusion and overly strict output parsing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Pass num_choices (len of options) from pre_process instead of boolean extract_number
- Evaluator builds regex pattern dynamically: r'\b([1-{num_choices}])\b'
- Only enables digit extraction when num_choices is 1-9 (single-digit range)
- Add explanatory comment to empty except clause (CodeQL fix)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add max_length parameter to vision_vqa_pre_process (default 4096)
- Pass max_length through VisionVQADataset to evaluator via input_dict
- Evaluator reads per-sample max_length, falling back to 4096 default
Users can now override max_length in their JSON data config:
"pre_process_args": {"max_length": 8192, ...}
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Corrupt or broken images could crash during Image.open, pil_image.save, og.Images.open, or processor() — not just during generation. Widen the try/except to catch any Exception so a single bad sample logs a warning and continues evaluation instead of aborting the entire run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Compute num_choices directly where options are validated, removing the separate has_options flag and the potentially-uninitialized 'options' reference that CodeQL flagged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a4d4cf3 to
3bd8d05
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xiaoyu-work
approved these changes
Jun 5, 2026
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
Aligns the Olive JSON-based vision evaluation (
vision_vqa_pre_process) with the standaloneeval.pyscripts in olive-recipes, and adds robustness improvements.Problem
The JSON eval was reporting ~66% accuracy on AI2D while eval.py reported ~76% on the same CUDA model. The gap was caused by:
0. opt, 1. opt...but VLMs prefer 1-based (1. opt, 2. opt...)re.match(r"^(\\d+)", pred)only matched a leading digit, missing valid responses like "The answer is 2"Changes
olive/data/component/pre_process_data.py:num_choices(actual count of options) instead of a boolean flagmax_lengthparameter (default 4096), passable from JSON data configolive/evaluator/olive_evaluator.py:r"\\b([1-{num_choices}])\\b"instead of hardcoded[1-4]num_choicesis 1-9 (single-digit range)max_lengthfrom data config, falling back to 4096 defaultTesting
Validated on AI2D (3088 samples) with Qwen2.5-VL-3B-Instruct CUDA model — results now align with eval.py (~76% accuracy).