Commit c10e5bc
Align vision VQA eval: dynamic choice detection, configurable max_length, robust error handling (microsoft#2499)
## Description
Aligns the Olive JSON-based vision evaluation (`vision_vqa_pre_process`)
with the standalone `eval.py` scripts 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:
1. **0-based vs 1-based option numbering** — options were presented as
`0. opt, 1. opt...` but VLMs prefer 1-based (`1. opt, 2. opt...`)
2. **Overly strict output parsing** — `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`**:
- Use 1-based numbering for options and convert 0-based ground truth
index to 1-based
- Pass `num_choices` (actual count of options) instead of a boolean flag
- Add configurable `max_length` parameter (default 4096), passable from
JSON data config
- **`olive/evaluator/olive_evaluator.py`**:
- Build regex dynamically as `r"\\b([1-{num_choices}])\\b"` instead of
hardcoded `[1-4]`
- Only enable digit extraction when `num_choices` is 1-9 (single-digit
range)
- Read `max_length` from data config, falling back to 4096 default
- Wrap entire per-image block in try/except so corrupt images log a
warning with sample index instead of aborting the run
### Testing
Validated on AI2D (3088 samples) with Qwen2.5-VL-3B-Instruct CUDA model
— results now align with eval.py (~76% accuracy).
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent d4582d9 commit c10e5bc
2 files changed
Lines changed: 98 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| 392 | + | |
392 | 393 | | |
393 | 394 | | |
394 | 395 | | |
| |||
414 | 415 | | |
415 | 416 | | |
416 | 417 | | |
| 418 | + | |
| 419 | + | |
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
| |||
444 | 447 | | |
445 | 448 | | |
446 | 449 | | |
447 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
448 | 460 | | |
449 | 461 | | |
450 | 462 | | |
451 | 463 | | |
452 | 464 | | |
453 | 465 | | |
| 466 | + | |
454 | 467 | | |
455 | 468 | | |
456 | 469 | | |
| |||
462 | 475 | | |
463 | 476 | | |
464 | 477 | | |
465 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
466 | 481 | | |
467 | 482 | | |
468 | | - | |
469 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
470 | 486 | | |
471 | | - | |
472 | 487 | | |
473 | 488 | | |
474 | 489 | | |
475 | 490 | | |
476 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
477 | 501 | | |
478 | 502 | | |
479 | 503 | | |
480 | 504 | | |
481 | | - | |
| 505 | + | |
| 506 | + | |
482 | 507 | | |
483 | 508 | | |
484 | 509 | | |
| |||
496 | 521 | | |
497 | 522 | | |
498 | 523 | | |
499 | | - | |
| 524 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
| 850 | + | |
| 851 | + | |
855 | 852 | | |
856 | 853 | | |
857 | 854 | | |
| |||
872 | 869 | | |
873 | 870 | | |
874 | 871 | | |
| 872 | + | |
875 | 873 | | |
876 | 874 | | |
877 | 875 | | |
| |||
883 | 881 | | |
884 | 882 | | |
885 | 883 | | |
886 | | - | |
| 884 | + | |
| 885 | + | |
887 | 886 | | |
888 | 887 | | |
889 | 888 | | |
890 | 889 | | |
| 890 | + | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
937 | 946 | | |
938 | 947 | | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
939 | 955 | | |
940 | 956 | | |
941 | 957 | | |
| |||
0 commit comments