Add vision-mix-2026-10-v3: training manifests for QEV-0.8B/2B v3
Browse files- CHANGELOG.md +10 -0
- LICENSES.md +4 -0
- NOTICE +4 -0
- README.md +64 -1
- checksums.json +31 -5
- vision-mix-2026-10-v3/README.md +121 -0
- vision-mix-2026-10-v3/counts.json +448 -0
- vision-mix-2026-10-v3/excluded.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/ai2d.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/aokvqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/chartqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/cord_train.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/docvqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/funsd_train.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/hateful_memes.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/iconqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/infographic_vqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/mind2web.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/mind2web_k.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/options_in_image.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/scienceqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/screen2words.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/synthetic.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/tallyqa.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/visual7w.jsonl +0 -0
- vision-mix-2026-10-v3/manifests/vsr.jsonl +0 -0
- vision-mix-2026-10-v3/scripts/build_mix_v2.py +374 -0
- vision-mix-2026-10-v3/scripts/build_mix_v3.py +224 -0
- vision-mix-2026-10-v3/scripts/build_shift_dev.py +861 -0
- vision-mix-2026-10-v3/scripts/validate_mix_v3.py +132 -0
CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
# Changelog
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## 2026-10-20
|
| 4 |
|
| 5 |
- Added `vision-mix-2026-10/`, the training data for QEV-2B and QEV-0.8B:
|
|
|
|
| 1 |
# Changelog
|
| 2 |
|
| 3 |
+
## 2026-10-26
|
| 4 |
+
|
| 5 |
+
- Added `vision-mix-2026-10-v3/`, the training data for the v3 releases of QEV-0.8B (revision bb7107f) and QEV-2B (revision 7534f3b):
|
| 6 |
+
- coverage-mix manifests for all 18 sources (ids, gold letters, hashes, and the generator labels, seeds and item-id references that describe how each item was built)
|
| 7 |
+
- the list of the 2,063 items excluded as near-duplicates of evaluation or DEV images
|
| 8 |
+
- the v3 build and audit scripts
|
| 9 |
+
- a new viewer configuration, `vision-2026-10-v3-coverage-manifest`
|
| 10 |
+
- NLVR2 data and synthetic items are unchanged and are referenced from `vision-mix-2026-10/` rather than copied.
|
| 11 |
+
- Updated README.md, LICENSES.md and NOTICE. `vision-mix-2026-10/` and the historical corpora are unchanged.
|
| 12 |
+
|
| 13 |
## 2026-10-20
|
| 14 |
|
| 15 |
- Added `vision-mix-2026-10/`, the training data for QEV-2B and QEV-0.8B:
|
LICENSES.md
CHANGED
|
@@ -56,3 +56,7 @@ See `licenses/`; each corpus ZIP includes these notices.
|
|
| 56 |
The `vision-mix-2026-10/` folder contains no third-party images or text. For the 17 third-party sources, it holds ids, gold letters and SHA-256/dHash values only. The source table in `vision-mix-2026-10/README.md` gives each source and the license stated where it was downloaded. Rebuilding the items requires accepting each source's own terms. FUNSD allows non-commercial research use only, and Hateful Memes is research-only.
|
| 57 |
|
| 58 |
The synthetic set (`vision-mix-2026-10/synthetic/`), the NLVR2 teacher probabilities (outputs of QEV 0.2.1) and the build scripts are Apache-2.0. NLVR2 ids and labels refer to the official NLVR2 release (lil-lab/nlvr), and its terms apply to the statements and images.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
The `vision-mix-2026-10/` folder contains no third-party images or text. For the 17 third-party sources, it holds ids, gold letters and SHA-256/dHash values only. The source table in `vision-mix-2026-10/README.md` gives each source and the license stated where it was downloaded. Rebuilding the items requires accepting each source's own terms. FUNSD allows non-commercial research use only, and Hateful Memes is research-only.
|
| 57 |
|
| 58 |
The synthetic set (`vision-mix-2026-10/synthetic/`), the NLVR2 teacher probabilities (outputs of QEV 0.2.1) and the build scripts are Apache-2.0. NLVR2 ids and labels refer to the official NLVR2 release (lil-lab/nlvr), and its terms apply to the statements and images.
|
| 59 |
+
|
| 60 |
+
## October 2026 vision mix v3
|
| 61 |
+
|
| 62 |
+
`vision-mix-2026-10-v3/` uses the same third-party sources as `vision-mix-2026-10/`, under the same terms, and adds 157 rows from the Hateful Memes and A-OKVQA train splits. It contains no third-party images or text, including the re-rendered Mind2Web screenshots and the distractor texts of regenerated items. Third-party items are described by ids, labels, hashes, generator labels and seeds only. The build scripts are Apache-2.0. The synthetic items and NLVR2 teacher probabilities it refers to are those in `vision-mix-2026-10/`.
|
NOTICE
CHANGED
|
@@ -76,3 +76,7 @@ CORD v2 (naver-clova-ix/cord-v2), FUNSD (Jaume et al., 2019), Hateful Memes (Kie
|
|
| 76 |
Multimodal-Mind2Web (osunlp/Multimodal-Mind2Web), and the AI2D, DocVQA, IconQA, InfographicVQA, Screen2Words,
|
| 77 |
TallyQA, Visual7W and VSR subsets of HuggingFaceM4/the_cauldron, plus NLVR2 (Suhr et al., 2019; lil-lab/nlvr).
|
| 78 |
Each remains under its own terms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
Multimodal-Mind2Web (osunlp/Multimodal-Mind2Web), and the AI2D, DocVQA, IconQA, InfographicVQA, Screen2Words,
|
| 77 |
TallyQA, Visual7W and VSR subsets of HuggingFaceM4/the_cauldron, plus NLVR2 (Suhr et al., 2019; lil-lab/nlvr).
|
| 78 |
Each remains under its own terms.
|
| 79 |
+
|
| 80 |
+
October 2026 vision mix v3 (QEV-0.8B and QEV-2B v3). Same sources as the October 2026 vision mix, with additional
|
| 81 |
+
rows from the Hateful Memes and A-OKVQA train splits. Only ids, labels and hashes of third-party items are included;
|
| 82 |
+
no third-party images or text, and no images derived from them, are redistributed. Each source remains under its own terms.
|
README.md
CHANGED
|
@@ -12,7 +12,58 @@ tags:
|
|
| 12 |
- multimodal
|
| 13 |
- typed-decisions
|
| 14 |
- synthetic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
configs:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
- config_name: vision-2026-10-coverage-manifest
|
| 17 |
data_files:
|
| 18 |
- split: train
|
|
@@ -185,7 +236,19 @@ configs:
|
|
| 185 |
|
| 186 |
# QEV data
|
| 187 |
|
| 188 |
-
Training data for QEV decision models: the October 2026 vision
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
## October 2026 vision release: QEV-2B and QEV-0.8B
|
| 191 |
|
|
|
|
| 12 |
- multimodal
|
| 13 |
- typed-decisions
|
| 14 |
- synthetic
|
| 15 |
+
dataset_info:
|
| 16 |
+
- config_name: vision-2026-10-v3-coverage-manifest
|
| 17 |
+
features:
|
| 18 |
+
- name: id
|
| 19 |
+
dtype: string
|
| 20 |
+
- name: source
|
| 21 |
+
dtype: string
|
| 22 |
+
- name: subtask
|
| 23 |
+
dtype: string
|
| 24 |
+
- name: vision_only
|
| 25 |
+
dtype: bool
|
| 26 |
+
- name: n_images
|
| 27 |
+
dtype: int64
|
| 28 |
+
- name: image_sha256
|
| 29 |
+
sequence: string
|
| 30 |
+
- name: image_dhash64
|
| 31 |
+
sequence: string
|
| 32 |
+
- name: n_options
|
| 33 |
+
dtype: int64
|
| 34 |
+
- name: gold
|
| 35 |
+
dtype: string
|
| 36 |
+
- name: option_sha256
|
| 37 |
+
sequence: string
|
| 38 |
+
- name: holdout
|
| 39 |
+
dtype: bool
|
| 40 |
+
- name: added_v3
|
| 41 |
+
dtype: bool
|
| 42 |
+
- name: construction
|
| 43 |
+
dtype: string
|
| 44 |
+
- name: option_generators
|
| 45 |
+
sequence: string
|
| 46 |
+
- name: other_image_gold_ref
|
| 47 |
+
sequence: string
|
| 48 |
+
- name: seed
|
| 49 |
+
dtype: string
|
| 50 |
+
- name: rerender_palette
|
| 51 |
+
dtype: string
|
| 52 |
+
- name: rerender_labels
|
| 53 |
+
sequence: string
|
| 54 |
+
- name: rerender_negative_modes
|
| 55 |
+
sequence: string
|
| 56 |
+
- name: rerender_gold_slot
|
| 57 |
+
dtype: int64
|
| 58 |
+
- name: upstream_key
|
| 59 |
+
dtype: string
|
| 60 |
+
- name: upstream_label
|
| 61 |
+
dtype: int64
|
| 62 |
configs:
|
| 63 |
+
- config_name: vision-2026-10-v3-coverage-manifest
|
| 64 |
+
data_files:
|
| 65 |
+
- split: train
|
| 66 |
+
path: vision-mix-2026-10-v3/manifests/*.jsonl
|
| 67 |
- config_name: vision-2026-10-coverage-manifest
|
| 68 |
data_files:
|
| 69 |
- split: train
|
|
|
|
| 236 |
|
| 237 |
# QEV data
|
| 238 |
|
| 239 |
+
Training data for QEV decision models: the October 2026 vision mixes for [QEV-2B](https://huggingface.co/ken-jo/QEV-2B) and [QEV-0.8B](https://huggingface.co/ken-jo/QEV-0.8B) (the first release and v3), and historical snapshots for [QEV 0.2.1](https://huggingface.co/ken-jo/qev).
|
| 240 |
+
|
| 241 |
+
## October 2026 vision mix v3: QEV-2B and QEV-0.8B v3
|
| 242 |
+
|
| 243 |
+
The v3 releases of [QEV-0.8B](https://huggingface.co/ken-jo/QEV-0.8B/tree/bb7107f413e855949462b900b26a622f4817160e) (revision `bb7107f`) and [QEV-2B](https://huggingface.co/ken-jo/QEV-2B/tree/7534f3b77eddaff5de4e6e75801677b976b5d2f5) (revision `7534f3b`) were trained on a revised mix, documented in [`vision-mix-2026-10-v3/`](vision-mix-2026-10-v3/README.md):
|
| 244 |
+
|
| 245 |
+
- **Diversified distractors:** the options of 16,195 items in seven sources were regenerated with 3 to 6 options each, mixing answers from other images, perturbed values and same-image annotations. The earlier "other questions about the same image" scheme appears in 30% of these items. 60% of Mind2Web items were re-rendered with new marks and negatives.
|
| 246 |
+
- **Targeted fixes:** 707 CORD field-presence items gained receipt-text decoys, and 157 new upstream TRAIN rows (127 Hateful Memes, 30 A-OKVQA) replaced rows removed by the near-duplicate filter.
|
| 247 |
+
- **Exclusions:** 2,063 items whose images are near-duplicates (dHash distance 4 or less) of evaluation-board or internal DEV images were removed.
|
| 248 |
+
- **Coverage mix:** 51,091 items from 18 sources (49,275 trained on, 1,816 held out for selection). The manifests (config `vision-2026-10-v3-coverage-manifest`) list ids, gold letters, hashes and how each item was built. They contain no third-party text or images.
|
| 249 |
+
- **Unchanged:** NLVR2 ids and teacher probabilities, and the synthetic items (v3 uses 5,414 of them), are those in `vision-mix-2026-10/`. The 4,658 replay items are again not released.
|
| 250 |
+
|
| 251 |
+
The sources and licenses are those of the first October 2026 release below.
|
| 252 |
|
| 253 |
## October 2026 vision release: QEV-2B and QEV-0.8B
|
| 254 |
|
checksums.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
| 35 |
"licenses/CC-BY-4.0.txt": "d557539df68e771cc1eedcc91d13f70fca930e508d11eedcafa4b15db49e3744",
|
| 36 |
"licenses/CC-BY-SA-4.0.txt": "cde7883b9050a1104f4ac19a1572aafd6e5d7323b68351aaf51fbf4beba54966",
|
| 37 |
"licenses/trashnet-MIT.txt": "e33347ae1589c1c7d7de5cf2e433e6c8060256273c7287a29d7c6e1e45c466f1",
|
| 38 |
-
"LICENSES.md": "
|
| 39 |
"manifests/foundation-v11.json": "17ff29e23edfbbe7e09355343c919f09d77be66f08e0d46d278c9f83ceeb660f",
|
| 40 |
"manifests/policy-v3.json": "bcf64862ba4d4778a6b24023646d65a2a7e31d7152c86a0dfa187ac6db0c233d",
|
| 41 |
"manifests/policy-v6.json": "6ff0c56cd32b3907925cd318ee069c2821ca032e0984feffa4eb7b21f704705c",
|
|
@@ -51,8 +51,8 @@
|
|
| 51 |
"manifests/workflow-v13-final.json": "09d670be1d050fb0ed74f427d5e321d82dd019f3285f298a7fa62313a9850f05",
|
| 52 |
"manifests/workflow-v13g.json": "0f458d3cf012ddf68641e48f5fe645b8d5c9749d451ca21d130c28a80916ac3d",
|
| 53 |
"manifests/workflow-v13h.json": "18a1eb9bb1a7c00725e1b29f495db31bd6d6728161e935fa6a845363a8dae42a",
|
| 54 |
-
"NOTICE": "
|
| 55 |
-
"README.md": "
|
| 56 |
"viewer/foundation-v11/calibration.jsonl": "e4dfaaad2a112e8b2d184af5cfd1940d763e17121ad0020f054857c910f83aa7",
|
| 57 |
"viewer/foundation-v11/dev.jsonl": "5c9ef6496710be1ff769d05556493eb09a6d66abbaf1fb8b98e3e66a2c748529",
|
| 58 |
"viewer/foundation-v11/test.jsonl": "a5a8ebe312231906b7c0a3e13df4e34f1e1af7827746f35792d541d3c0cf29c0",
|
|
@@ -141,5 +141,31 @@
|
|
| 141 |
"vision-mix-2026-10/scripts/dl_docs.py": "38234c88824cb7975d07ee2d503fc8c0ac8ec02ea8be73fb3f9fbe248b04a8af",
|
| 142 |
"vision-mix-2026-10/scripts/dl_docs.sh": "0d16cbf6bea9d719e46efdd23788de5f1b6800a9cd3aa18fe6b663d49065e06b",
|
| 143 |
"vision-mix-2026-10/synthetic/images.zip": "1477c5589fe94788656a9cdfae0f2eeee73dd42d9954c4190db039c0434a235c",
|
| 144 |
-
"vision-mix-2026-10/synthetic/items.jsonl": "17770f5358396c59e0c0eaa81d8938f6498613f1a0ea694171f546f84a62a276"
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
"licenses/CC-BY-4.0.txt": "d557539df68e771cc1eedcc91d13f70fca930e508d11eedcafa4b15db49e3744",
|
| 36 |
"licenses/CC-BY-SA-4.0.txt": "cde7883b9050a1104f4ac19a1572aafd6e5d7323b68351aaf51fbf4beba54966",
|
| 37 |
"licenses/trashnet-MIT.txt": "e33347ae1589c1c7d7de5cf2e433e6c8060256273c7287a29d7c6e1e45c466f1",
|
| 38 |
+
"LICENSES.md": "19404ec31cf09e9ccdb72cf36a6eab89502e7791859c8c2646c2bc238930085d",
|
| 39 |
"manifests/foundation-v11.json": "17ff29e23edfbbe7e09355343c919f09d77be66f08e0d46d278c9f83ceeb660f",
|
| 40 |
"manifests/policy-v3.json": "bcf64862ba4d4778a6b24023646d65a2a7e31d7152c86a0dfa187ac6db0c233d",
|
| 41 |
"manifests/policy-v6.json": "6ff0c56cd32b3907925cd318ee069c2821ca032e0984feffa4eb7b21f704705c",
|
|
|
|
| 51 |
"manifests/workflow-v13-final.json": "09d670be1d050fb0ed74f427d5e321d82dd019f3285f298a7fa62313a9850f05",
|
| 52 |
"manifests/workflow-v13g.json": "0f458d3cf012ddf68641e48f5fe645b8d5c9749d451ca21d130c28a80916ac3d",
|
| 53 |
"manifests/workflow-v13h.json": "18a1eb9bb1a7c00725e1b29f495db31bd6d6728161e935fa6a845363a8dae42a",
|
| 54 |
+
"NOTICE": "5373aca29389812bb14df85aa55c87873347228713da603c4f6f08ba4d52da37",
|
| 55 |
+
"README.md": "2c1fda60499c90fb53950288d02f5756f32162ea3b37b0fe68581b01106137b0",
|
| 56 |
"viewer/foundation-v11/calibration.jsonl": "e4dfaaad2a112e8b2d184af5cfd1940d763e17121ad0020f054857c910f83aa7",
|
| 57 |
"viewer/foundation-v11/dev.jsonl": "5c9ef6496710be1ff769d05556493eb09a6d66abbaf1fb8b98e3e66a2c748529",
|
| 58 |
"viewer/foundation-v11/test.jsonl": "a5a8ebe312231906b7c0a3e13df4e34f1e1af7827746f35792d541d3c0cf29c0",
|
|
|
|
| 141 |
"vision-mix-2026-10/scripts/dl_docs.py": "38234c88824cb7975d07ee2d503fc8c0ac8ec02ea8be73fb3f9fbe248b04a8af",
|
| 142 |
"vision-mix-2026-10/scripts/dl_docs.sh": "0d16cbf6bea9d719e46efdd23788de5f1b6800a9cd3aa18fe6b663d49065e06b",
|
| 143 |
"vision-mix-2026-10/synthetic/images.zip": "1477c5589fe94788656a9cdfae0f2eeee73dd42d9954c4190db039c0434a235c",
|
| 144 |
+
"vision-mix-2026-10/synthetic/items.jsonl": "17770f5358396c59e0c0eaa81d8938f6498613f1a0ea694171f546f84a62a276",
|
| 145 |
+
"CHANGELOG.md": "a8f38bcfff5d1bc08c5836f7c2631beacc6308424b18cc86c018e01fd0ec8daa",
|
| 146 |
+
"vision-mix-2026-10-v3/README.md": "975fd26b520758945ae79ce8a65a669bd28f40ccfd768671c4397f409ba59e7c",
|
| 147 |
+
"vision-mix-2026-10-v3/counts.json": "6f84268a4dbdf7dec59540db57bb23102061089f2261b9cb653b126e1044e71e",
|
| 148 |
+
"vision-mix-2026-10-v3/excluded.jsonl": "61e06854af09eceb752d0f01279ccdc4427cfff39650698c3853db405f54071b",
|
| 149 |
+
"vision-mix-2026-10-v3/manifests/ai2d.jsonl": "c66c3f33d9a3b147259f83467d68892aeed9e889456fb8e861f769f059f844c3",
|
| 150 |
+
"vision-mix-2026-10-v3/manifests/aokvqa.jsonl": "4323f085be6238e0e0ca4ff82b88f28018b9387c538779a588e5052d634104d4",
|
| 151 |
+
"vision-mix-2026-10-v3/manifests/chartqa.jsonl": "3aa9a2454e11938ee7933e64ac8b002a57b660ab704890338685409c27a0a101",
|
| 152 |
+
"vision-mix-2026-10-v3/manifests/cord_train.jsonl": "6eb8568c34f98839efc48de9c573b6daba5d22731ecd5eed016afefee5558080",
|
| 153 |
+
"vision-mix-2026-10-v3/manifests/docvqa.jsonl": "2b062c493367a2dfcbccae0d860b2e4da14f3d9425c4d7a53303acb92c221ee1",
|
| 154 |
+
"vision-mix-2026-10-v3/manifests/funsd_train.jsonl": "8e1f718586080de2777cf0eb07a78351f3f8be7d5046108ece1f4a3603e05bb4",
|
| 155 |
+
"vision-mix-2026-10-v3/manifests/hateful_memes.jsonl": "f484defe3a1eaf62b6df492859409f6c5de923a1776f9684c1226a2f9ffd6160",
|
| 156 |
+
"vision-mix-2026-10-v3/manifests/iconqa.jsonl": "39fd4c152b603e62638672a128229742b9f0fb6586e4ee87a3f83efcbc3b8715",
|
| 157 |
+
"vision-mix-2026-10-v3/manifests/infographic_vqa.jsonl": "9b3778abdafc4c91932639b85a42dc0cff4780609018057104bd74fbcfff0a6c",
|
| 158 |
+
"vision-mix-2026-10-v3/manifests/mind2web.jsonl": "1729fdb8b6c8b19b5feaf9a9554d67e4f5a4a0c0b0c399caa9ee5a2871006e64",
|
| 159 |
+
"vision-mix-2026-10-v3/manifests/mind2web_k.jsonl": "bcad02179e7fa01640caf13d2748afa8e096f620937898de0c71de144e66e5a3",
|
| 160 |
+
"vision-mix-2026-10-v3/manifests/options_in_image.jsonl": "1c2582f6c08b12221bf8feef7166d8b0c33117238dadb7a0efd6ab0d2ec0d716",
|
| 161 |
+
"vision-mix-2026-10-v3/manifests/scienceqa.jsonl": "c1916170a69f187d6d5738b33836b173f673d44cd664d4e5820c1121ec041bf9",
|
| 162 |
+
"vision-mix-2026-10-v3/manifests/screen2words.jsonl": "dde057611db6c88837815eb139d9caa37c3879298e12ac1dbafb3670310c2de3",
|
| 163 |
+
"vision-mix-2026-10-v3/manifests/synthetic.jsonl": "ef786062da77b8a38f346c5d50e0467c9b866e947f4fba9f21bb5ec76013cdaa",
|
| 164 |
+
"vision-mix-2026-10-v3/manifests/tallyqa.jsonl": "a3b4e913827be10638ac9e3aa12b93478adec6306f06a01a84df1a4bf762dacd",
|
| 165 |
+
"vision-mix-2026-10-v3/manifests/visual7w.jsonl": "21d1f079ac1d2ce97cf4c142d56eb4e974b3bc27c9b85ef832cf0b14dec4821f",
|
| 166 |
+
"vision-mix-2026-10-v3/manifests/vsr.jsonl": "63bd50e8af7cad2b01f2d81a25dd5d4f81915a1ad10dda324b12a52912ea0cdd",
|
| 167 |
+
"vision-mix-2026-10-v3/scripts/build_mix_v2.py": "73a439f078bb79d97f7e83b3a58bfacbf14335aef89c19cbd3825e94fbb81aee",
|
| 168 |
+
"vision-mix-2026-10-v3/scripts/build_mix_v3.py": "2e2897945aab929cf2907c01ce6df245bc16dcea1c4ae8ad9afd00e3f3343cb1",
|
| 169 |
+
"vision-mix-2026-10-v3/scripts/build_shift_dev.py": "5b45142fe622e364ffc7e6ba30be52bfd2393cf6db13c494aaf00e7ddb7956a5",
|
| 170 |
+
"vision-mix-2026-10-v3/scripts/validate_mix_v3.py": "8f8691603872a0a8104598fe95e99cc766ff1f3a76253afaa28abbba62deabad"
|
| 171 |
+
}
|
vision-mix-2026-10-v3/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# QEV vision training data, October 2026, v3
|
| 2 |
+
|
| 3 |
+
This folder documents the coverage mix used to train the v3 releases of [QEV-0.8B](https://huggingface.co/ken-jo/QEV-0.8B/tree/bb7107f413e855949462b900b26a622f4817160e) (revision `bb7107f`) and [QEV-2B](https://huggingface.co/ken-jo/QEV-2B/tree/7534f3b77eddaff5de4e6e75801677b976b5d2f5) (revision `7534f3b`). It is a revision of [`vision-mix-2026-10/`](../vision-mix-2026-10/README.md), which documents the earlier October 2026 releases and stays unchanged. Read that README first. This one covers only what is different.
|
| 4 |
+
|
| 5 |
+
The counts match the training logs of all three v3 runs: 49,275 coverage-mix training items, 1,816 coverage-mix holdout items, 2,048 NLVR2 items (1,669 teacher targets kept) and 4,658 replay items.
|
| 6 |
+
|
| 7 |
+
As before, this folder holds **no third-party images, questions, answer options or re-rendered images**. It contains:
|
| 8 |
+
|
| 9 |
+
| Path | What it is | Included content |
|
| 10 |
+
| --- | --- | --- |
|
| 11 |
+
| `manifests/<source>.jsonl` | One row per coverage-mix item for all 18 sources (51,091 rows) | The fields of the 2026-10 manifests (item id, source, subtask, gold letter, number of options, SHA-256 of each option string, SHA-256 and 64-bit dHash of each image as built, holdout flag), plus how each item was constructed (see below) |
|
| 12 |
+
| `excluded.jsonl` | The 2,063 items of the 2026-10 mix that v3 drops | Item id, source, exclusion reason, image SHA-256 and dHash |
|
| 13 |
+
| `scripts/` | `build_shift_dev.py`, `build_mix_v2.py`, `build_mix_v3.py`, `validate_mix_v3.py` | The code that built and audited this mix |
|
| 14 |
+
| `counts.json` | Per-source counts, exclusions, constructions, distractor generators and option-count histograms | |
|
| 15 |
+
|
| 16 |
+
The following are unchanged from 2026-10 and are not copied here:
|
| 17 |
+
|
| 18 |
+
- **Synthetic items.** The 5,414 synthetic items in v3 are a subset of the 6,000 items in [`vision-mix-2026-10/synthetic/`](../vision-mix-2026-10/synthetic/) (Apache-2.0), with identical questions, options, gold letters and images. `manifests/synthetic.jsonl` lists which ones were used. The other 586 were dropped by the near-duplicate filter.
|
| 19 |
+
- **NLVR2.** v3 training used the same 2,048 TRAIN and 256 DEV NLVR2 ids, with the same gold labels and QEV 0.2.1 teacher probabilities, as [`vision-mix-2026-10/nlvr2/`](../vision-mix-2026-10/nlvr2/). The 512 TEST ids are also unchanged.
|
| 20 |
+
|
| 21 |
+
## What changed versus 2026-10
|
| 22 |
+
|
| 23 |
+
The 2026-10 mix built most multiple-choice items with the same scheme: four options, where the wrong options are answers to other questions about the same image. The public InfographicVQA rows of the Decision Index vision board are built the same way. v3 diversifies the distractors so that the model has to read the image rather than rely on one construction. It also adds a few targeted fixes. No gold answer and no question was changed.
|
| 24 |
+
|
| 25 |
+
1. **Diversified distractors.** For `ai2d`, `chartqa`, `cord_train`, `docvqa`, `funsd_train`, `infographic_vqa` and `screen2words`, the options of every non-binary item were regenerated (16,195 items). Each item gets 3, 4, 5 or 6 options, spread evenly. Each distractor comes from one of these seeded generators:
|
| 26 |
+
- `original`: the 2026-10 scheme, an answer to another question about the same image. Only 30% of regenerated items (4,867) use it at all, and it supplies 14% of their distractors.
|
| 27 |
+
- `other_image_gold`: the gold answer of another item from the same source with the same answer type (number or text type).
|
| 28 |
+
- `perturb_gold`: a numeric or text perturbation of the gold answer.
|
| 29 |
+
- `same_image_annotation`: other text from the same image's upstream annotations or OCR, where the dataset has them (not for ChartQA).
|
| 30 |
+
|
| 31 |
+
Screen2Words uses only `original` and `other_image_gold`, because shortening or reordering a caption can leave another correct summary.
|
| 32 |
+
|
| 33 |
+
A distractor is never equal to the gold answer after normalisation, and numbers are compared numerically, so no item has a second correct option. Binary Yes/No items (the 1,451 CORD field-presence items and 500 FUNSD items) were not regenerated by this step.
|
| 34 |
+
2. **Re-rendered Mind2Web.** In `mind2web` and `mind2web_k`, 60% of items (2,948 and 1,335) were re-rendered from the upstream screenshot. Each re-render marks the target and 2 to 5 negative boxes, which alternate between spatially close and random upstream candidates. About a third use the original A–D mark style with 4 boxes (1,338 items); the rest use bracketed letters with 3 to 6 boxes (2,945 items). The other 40% are unchanged from 2026-10, so the original A–D style still covers at least 40% of Mind2Web items.
|
| 35 |
+
3. **Near-duplicate exclusion.** Every training image within dHash distance 4 of an image on the Decision Index vision board (11,542 hashes) or in our internal distractor-shift DEV set (1,636 images), or with the same SHA-256 as a DEV image, was removed together with its items. This dropped 2,063 items, listed in `excluded.jsonl`. Holdout items were removed but not replaced.
|
| 36 |
+
4. **CORD presence decoys.** In `cord_train`, 707 of the 1,415 field-presence training items (chosen by a seeded hash of the id) now have 3 to 6 options: Yes, No and text from the same receipt's upstream annotation. The other 708 training items and the 36 holdout items stay Yes/No.
|
| 37 |
+
5. **157 added upstream TRAIN rows.** The near-duplicate filter removed 127 Hateful Memes items and 30 A-OKVQA items. They were replaced with new rows from the same upstream train splits: 127 Hateful Memes rows (55 hateful, 72 not hateful, restoring the removed label counts) and 30 A-OKVQA rows. The new rows passed the same image screening plus a near-duplicate check against the source's other images. They are training-only: none is in the holdout, and the trainer loads them only when `V3_TRAIN_ADDITIONS=1` is set (it was set for all v3 runs).
|
| 38 |
+
|
| 39 |
+
Sources not named above are unchanged apart from the exclusions.
|
| 40 |
+
|
| 41 |
+
## Counts per source
|
| 42 |
+
|
| 43 |
+
| Source | 2026-10 items | Excluded | Added | v3 items | Holdout | Trained | Changed construction |
|
| 44 |
+
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
| 45 |
+
| `ai2d` | 2,000 | 5 | 0 | 1,995 | 96 | 1,899 | 1,995 |
|
| 46 |
+
| `aokvqa` | 5,000 | 30 | 30 | 5,000 | 118 | 4,882 | 0 |
|
| 47 |
+
| `chartqa` | 4,000 | 1,015 | 0 | 2,985 | 94 | 2,891 | 2,985 |
|
| 48 |
+
| `cord_train` | 2,886 | 7 | 0 | 2,879 | 120 | 2,759 | 2,135 |
|
| 49 |
+
| `docvqa` | 4,984 | 60 | 0 | 4,924 | 119 | 4,805 | 4,924 |
|
| 50 |
+
| `funsd_train` | 1,496 | 0 | 0 | 1,496 | 74 | 1,422 | 996 |
|
| 51 |
+
| `hateful_memes` | 1,592 | 127 | 127 | 1,592 | 73 | 1,519 | 0 |
|
| 52 |
+
| `iconqa` | 1,952 | 16 | 0 | 1,936 | 94 | 1,842 | 0 |
|
| 53 |
+
| `infographic_vqa` | 1,875 | 0 | 0 | 1,875 | 93 | 1,782 | 1,875 |
|
| 54 |
+
| `mind2web` | 5,000 | 86 | 0 | 4,914 | 120 | 4,794 | 2,948 |
|
| 55 |
+
| `mind2web_k` | 2,261 | 35 | 0 | 2,226 | 113 | 2,113 | 1,335 |
|
| 56 |
+
| `options_in_image` | 2,014 | 10 | 0 | 2,004 | 100 | 1,904 | 0 |
|
| 57 |
+
| `scienceqa` | 4,000 | 83 | 0 | 3,917 | 117 | 3,800 | 0 |
|
| 58 |
+
| `screen2words` | 1,993 | 1 | 0 | 1,992 | 90 | 1,902 | 1,992 |
|
| 59 |
+
| `synthetic` | 6,000 | 586 | 0 | 5,414 | 115 | 5,299 | 0 |
|
| 60 |
+
| `tallyqa` | 1,999 | 1 | 0 | 1,998 | 91 | 1,907 | 0 |
|
| 61 |
+
| `visual7w` | 2,000 | 1 | 0 | 1,999 | 100 | 1,899 | 0 |
|
| 62 |
+
| `vsr` | 1,945 | 0 | 0 | 1,945 | 89 | 1,856 | 0 |
|
| 63 |
+
| **Total** | **52,997** | **2,063** | **157** | **51,091** | **1,816** | **49,275** | **21,185** |
|
| 64 |
+
|
| 65 |
+
Of the 2,063 exclusions, 1,117 are near a DEV image and 946 are near a board image. ChartQA alone loses 1,012 items to the DEV set, which was built from the same upstream train split. `counts.json` breaks this down per source.
|
| 66 |
+
|
| 67 |
+
The licenses and upstream revisions are those of the [2026-10 source table](../vision-mix-2026-10/README.md#sources-and-terms). The 157 added rows come from the same Hateful Memes and A-OKVQA train splits. FUNSD (non-commercial research use) and Hateful Memes (research-only) are again listed by id, label and hash only.
|
| 68 |
+
|
| 69 |
+
## Manifest fields
|
| 70 |
+
|
| 71 |
+
Each row has the 2026-10 fields, with the same conventions: `option_sha256` is the SHA-256 of each option string (UTF-8) in the final option order, `image_sha256` and `image_dhash64` describe each image as built, and `holdout` uses the rule of the 2026-10 README over the original 2026-10 item order. The new fields are:
|
| 72 |
+
|
| 73 |
+
| Field | Meaning |
|
| 74 |
+
| --- | --- |
|
| 75 |
+
| `construction` | `unchanged` (identical to the 2026-10 item), `regenerated_options` (change 1), `web_rerender` (change 2), `presence_ocr_v3` (change 4) or `added_v3` (change 5) |
|
| 76 |
+
| `added_v3` | `true` for the 157 added rows |
|
| 77 |
+
| `option_generators` | For `regenerated_options` and `presence_ocr_v3` rows: the generator of each option in final order (`gold`, `original`, `other_image_gold`, `perturb_gold`, `same_image_annotation`, `opposite_boolean`). Empty for other rows |
|
| 78 |
+
| `other_image_gold_ref` | For rows with at least one `other_image_gold` option: one entry per option, giving for each `other_image_gold` option the id of an item in the same source whose gold answer is that option, and `""` for the other options. Several items can share a gold answer; this gives the first one in file order, and `option_sha256` remains the exact check. Empty for other rows |
|
| 79 |
+
| `seed` | The string that seeds this item's random choices, for example `20261022:options:<id>` or `20261022:web:<id>`. `""` for unchanged items and the Hateful Memes additions |
|
| 80 |
+
| `rerender_palette`, `rerender_labels`, `rerender_negative_modes`, `rerender_gold_slot` | For `web_rerender` rows: the mark style (`kit` or `bracket`), the letter of each box, whether each negative was chosen as `spatial` (close) or `random`, and the index of the gold box. `""`, empty lists and `-1` for other rows. Box coordinates are not included; the build script recomputes them from the upstream candidates |
|
| 81 |
+
| `upstream_key`, `upstream_label` | For added rows: the key in the upstream train split (the Hateful Memes id, or the A-OKVQA parquet row index) and, for Hateful Memes, its 0/1 label. `""` and `-1` for other rows |
|
| 82 |
+
|
| 83 |
+
For re-rendered Mind2Web items, `image_sha256` and `image_dhash64` describe the re-rendered image.
|
| 84 |
+
|
| 85 |
+
## Rebuilding
|
| 86 |
+
|
| 87 |
+
The v3 mix is built in three steps on top of the 2026-10 build:
|
| 88 |
+
|
| 89 |
+
1. Build the 2026-10 coverage mix as described in the [2026-10 README](../vision-mix-2026-10/README.md#rebuilding-the-coverage-mix), with the scripts in `vision-mix-2026-10/scripts/`.
|
| 90 |
+
2. Run `scripts/build_mix_v2.py`. It applies the exclusions and changes 1 and 2. All random choices are seeded from `20261022` plus the item id, so a rebuild from the same upstream revisions gives the same options, option order and renders.
|
| 91 |
+
3. Run `scripts/build_mix_v3.py`. It applies changes 4 and 5, seeded from `20261023`.
|
| 92 |
+
|
| 93 |
+
`scripts/validate_mix_v3.py` is the audit that was run on the result. To compare a rebuild with this release, check each item's `gold`, `option_sha256` and `image_sha256` against `manifests/<source>.jsonl`. When your image decoder differs, `image_dhash64` is the stable check.
|
| 94 |
+
|
| 95 |
+
Path assumptions and limits:
|
| 96 |
+
|
| 97 |
+
- The scripts expect `qev-data/raw` (upstream downloads), `qev-data/train` (the 2026-10 build) and `qev-data/scripts` (with `build_docs.py` and `build_mix.py`) under a base directory, which is your home directory unless `QEV_HOME` is set. They write `train-v2/` and `train-v3/` next to themselves. `build_shift_dev.py` also imports helpers from a [Decision Index](https://github.com/apolinario/decision-index) checkout at `bench/decision-index` under the same base directory. Apart from the shebang line and the `QEV_HOME` override, the scripts are the ones that built this release.
|
| 98 |
+
- The exclusion step in `build_mix_v2.py` reads our internal DEV images and the board's dHash cache, which are not published. To rebuild without them, skip that step and drop the items listed in `excluded.jsonl` instead. Remove them before the regeneration step: the option count of each regenerated item depends on its position among the surviving items.
|
| 99 |
+
- The trainer is in [ken-jo/qev](https://github.com/ken-jo/qev).
|
| 100 |
+
|
| 101 |
+
## Training runs
|
| 102 |
+
|
| 103 |
+
| Model | Revision | Start | Data per pass | Passes | Optimizer steps |
|
| 104 |
+
| --- | --- | --- | --- | ---: | ---: |
|
| 105 |
+
| [QEV-0.8B](https://huggingface.co/ken-jo/QEV-0.8B/tree/bb7107f413e855949462b900b26a622f4817160e) | `bb7107f` | the QEV-0.8B base checkpoint used by the previous release | 49,275 coverage items, 2,048 NLVR2, 4,658 replay | 2 | 5,419 per pass |
|
| 106 |
+
| [QEV-2B](https://huggingface.co/ken-jo/QEV-2B/tree/7534f3b77eddaff5de4e6e75801677b976b5d2f5) | `7534f3b` | QEV 0.2.1 (Qwen3.5-2B + LoRA, merged) | the same | 1 | 3,652 |
|
| 107 |
+
|
| 108 |
+
Both runs used LoRA rank 8, alpha 16, merged into the released weights. The 0.8B second pass restarts the optimizer from the end of the first. In both cases the released checkpoint is the end of training, which had the highest selection score among the saved checkpoints. The selection score is the mean of the 1,816-item holdout, NLVR2 DEV and the internal diagnostics, averaged with the internal distractor-shift DEV set. No public evaluation rows were used in training or selection.
|
| 109 |
+
|
| 110 |
+
The fast-mode heads (`exit16.safetensors`) of both releases were trained on a seeded sample of the **2026-10** coverage mix and the replay units, as before; see [`vision-mix-2026-10/`](../vision-mix-2026-10/README.md).
|
| 111 |
+
|
| 112 |
+
## Not released
|
| 113 |
+
|
| 114 |
+
- **Replay (4,658 items)** and its QEV 0.2.1 targets, as in 2026-10.
|
| 115 |
+
- **The internal diagnostics** used for selection, as in 2026-10.
|
| 116 |
+
- **The internal distractor-shift DEV set** used for selection. It was built from the upstream train splits with `scripts/build_shift_dev.py`; every training image near one of its images was excluded (change 3).
|
| 117 |
+
- **All third-party images and text,** including the re-rendered Mind2Web screenshots and the 30 new A-OKVQA images. The distractor texts of regenerated items are not released either; `option_generators` and `other_image_gold_ref` record where they came from.
|
| 118 |
+
|
| 119 |
+
## Contamination checks
|
| 120 |
+
|
| 121 |
+
A fresh audit of all 46,971 distinct images referenced by the v3 mix found no SHA-256 match with a DEV image and no image within dHash distance 4 of any DEV image or any board image. A post-hoc audit of the v3 coverage-mix training images against every board evaluation image, with a looser threshold, is summarised in the limitations section of each model card. `image_dhash64` uses the same hash, so these checks can be repeated from the manifests.
|
vision-mix-2026-10-v3/counts.json
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"sources": {
|
| 3 |
+
"ai2d": {
|
| 4 |
+
"items": 1995,
|
| 5 |
+
"holdout": 96,
|
| 6 |
+
"train": 1899,
|
| 7 |
+
"added_v3": 0,
|
| 8 |
+
"excluded_vs_2026_10": 5,
|
| 9 |
+
"exclusion_reasons": {
|
| 10 |
+
"board_dhash": 3,
|
| 11 |
+
"dev_dhash": 2
|
| 12 |
+
},
|
| 13 |
+
"construction": {
|
| 14 |
+
"regenerated_options": 1995
|
| 15 |
+
},
|
| 16 |
+
"distractor_generators": {
|
| 17 |
+
"original": 952,
|
| 18 |
+
"same_image_annotation": 2424,
|
| 19 |
+
"other_image_gold": 2552,
|
| 20 |
+
"perturb_gold": 1053
|
| 21 |
+
},
|
| 22 |
+
"option_count_histogram": {
|
| 23 |
+
"3": 499,
|
| 24 |
+
"4": 499,
|
| 25 |
+
"5": 499,
|
| 26 |
+
"6": 498
|
| 27 |
+
},
|
| 28 |
+
"regenerated_items_using_original_scheme": 599,
|
| 29 |
+
"regenerated_items": 1995
|
| 30 |
+
},
|
| 31 |
+
"aokvqa": {
|
| 32 |
+
"items": 5000,
|
| 33 |
+
"holdout": 118,
|
| 34 |
+
"train": 4882,
|
| 35 |
+
"added_v3": 30,
|
| 36 |
+
"excluded_vs_2026_10": 30,
|
| 37 |
+
"exclusion_reasons": {
|
| 38 |
+
"board_dhash": 30
|
| 39 |
+
},
|
| 40 |
+
"construction": {
|
| 41 |
+
"unchanged": 4970,
|
| 42 |
+
"added_v3": 30
|
| 43 |
+
},
|
| 44 |
+
"distractor_generators": {},
|
| 45 |
+
"option_count_histogram": {
|
| 46 |
+
"4": 5000
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"chartqa": {
|
| 50 |
+
"items": 2985,
|
| 51 |
+
"holdout": 94,
|
| 52 |
+
"train": 2891,
|
| 53 |
+
"added_v3": 0,
|
| 54 |
+
"excluded_vs_2026_10": 1015,
|
| 55 |
+
"exclusion_reasons": {
|
| 56 |
+
"dev_dhash": 1012,
|
| 57 |
+
"board_dhash": 3
|
| 58 |
+
},
|
| 59 |
+
"construction": {
|
| 60 |
+
"regenerated_options": 2985
|
| 61 |
+
},
|
| 62 |
+
"distractor_generators": {
|
| 63 |
+
"perturb_gold": 3908,
|
| 64 |
+
"other_image_gold": 4935,
|
| 65 |
+
"original": 1603
|
| 66 |
+
},
|
| 67 |
+
"option_count_histogram": {
|
| 68 |
+
"3": 747,
|
| 69 |
+
"4": 746,
|
| 70 |
+
"5": 746,
|
| 71 |
+
"6": 746
|
| 72 |
+
},
|
| 73 |
+
"regenerated_items_using_original_scheme": 897,
|
| 74 |
+
"regenerated_items": 2985
|
| 75 |
+
},
|
| 76 |
+
"cord_train": {
|
| 77 |
+
"items": 2879,
|
| 78 |
+
"holdout": 120,
|
| 79 |
+
"train": 2759,
|
| 80 |
+
"added_v3": 0,
|
| 81 |
+
"excluded_vs_2026_10": 7,
|
| 82 |
+
"exclusion_reasons": {
|
| 83 |
+
"board_dhash": 4,
|
| 84 |
+
"dev_dhash": 3
|
| 85 |
+
},
|
| 86 |
+
"construction": {
|
| 87 |
+
"regenerated_options": 1428,
|
| 88 |
+
"presence_ocr_v3": 707,
|
| 89 |
+
"unchanged": 744
|
| 90 |
+
},
|
| 91 |
+
"distractor_generators": {
|
| 92 |
+
"other_image_gold": 1442,
|
| 93 |
+
"perturb_gold": 1436,
|
| 94 |
+
"same_image_annotation": 3228,
|
| 95 |
+
"original": 658,
|
| 96 |
+
"opposite_boolean": 707
|
| 97 |
+
},
|
| 98 |
+
"option_count_histogram": {
|
| 99 |
+
"2": 744,
|
| 100 |
+
"3": 534,
|
| 101 |
+
"4": 534,
|
| 102 |
+
"5": 534,
|
| 103 |
+
"6": 533
|
| 104 |
+
},
|
| 105 |
+
"regenerated_items_using_original_scheme": 429,
|
| 106 |
+
"regenerated_items": 1428
|
| 107 |
+
},
|
| 108 |
+
"docvqa": {
|
| 109 |
+
"items": 4924,
|
| 110 |
+
"holdout": 119,
|
| 111 |
+
"train": 4805,
|
| 112 |
+
"added_v3": 0,
|
| 113 |
+
"excluded_vs_2026_10": 60,
|
| 114 |
+
"exclusion_reasons": {
|
| 115 |
+
"dev_dhash": 55,
|
| 116 |
+
"board_dhash": 5
|
| 117 |
+
},
|
| 118 |
+
"construction": {
|
| 119 |
+
"regenerated_options": 4924
|
| 120 |
+
},
|
| 121 |
+
"distractor_generators": {
|
| 122 |
+
"other_image_gold": 5289,
|
| 123 |
+
"same_image_annotation": 5108,
|
| 124 |
+
"perturb_gold": 4534,
|
| 125 |
+
"original": 2303
|
| 126 |
+
},
|
| 127 |
+
"option_count_histogram": {
|
| 128 |
+
"3": 1231,
|
| 129 |
+
"4": 1231,
|
| 130 |
+
"5": 1231,
|
| 131 |
+
"6": 1231
|
| 132 |
+
},
|
| 133 |
+
"regenerated_items_using_original_scheme": 1479,
|
| 134 |
+
"regenerated_items": 4924
|
| 135 |
+
},
|
| 136 |
+
"funsd_train": {
|
| 137 |
+
"items": 1496,
|
| 138 |
+
"holdout": 74,
|
| 139 |
+
"train": 1422,
|
| 140 |
+
"added_v3": 0,
|
| 141 |
+
"excluded_vs_2026_10": 0,
|
| 142 |
+
"exclusion_reasons": {},
|
| 143 |
+
"construction": {
|
| 144 |
+
"regenerated_options": 996,
|
| 145 |
+
"unchanged": 500
|
| 146 |
+
},
|
| 147 |
+
"distractor_generators": {
|
| 148 |
+
"same_image_annotation": 1135,
|
| 149 |
+
"other_image_gold": 1054,
|
| 150 |
+
"perturb_gold": 810,
|
| 151 |
+
"original": 487
|
| 152 |
+
},
|
| 153 |
+
"option_count_histogram": {
|
| 154 |
+
"2": 500,
|
| 155 |
+
"3": 249,
|
| 156 |
+
"4": 249,
|
| 157 |
+
"5": 249,
|
| 158 |
+
"6": 249
|
| 159 |
+
},
|
| 160 |
+
"regenerated_items_using_original_scheme": 300,
|
| 161 |
+
"regenerated_items": 996
|
| 162 |
+
},
|
| 163 |
+
"hateful_memes": {
|
| 164 |
+
"items": 1592,
|
| 165 |
+
"holdout": 73,
|
| 166 |
+
"train": 1519,
|
| 167 |
+
"added_v3": 127,
|
| 168 |
+
"excluded_vs_2026_10": 127,
|
| 169 |
+
"exclusion_reasons": {
|
| 170 |
+
"board_dhash": 127
|
| 171 |
+
},
|
| 172 |
+
"construction": {
|
| 173 |
+
"unchanged": 1465,
|
| 174 |
+
"added_v3": 127
|
| 175 |
+
},
|
| 176 |
+
"distractor_generators": {},
|
| 177 |
+
"option_count_histogram": {
|
| 178 |
+
"2": 1592
|
| 179 |
+
}
|
| 180 |
+
},
|
| 181 |
+
"iconqa": {
|
| 182 |
+
"items": 1936,
|
| 183 |
+
"holdout": 94,
|
| 184 |
+
"train": 1842,
|
| 185 |
+
"added_v3": 0,
|
| 186 |
+
"excluded_vs_2026_10": 16,
|
| 187 |
+
"exclusion_reasons": {
|
| 188 |
+
"board_dhash": 16
|
| 189 |
+
},
|
| 190 |
+
"construction": {
|
| 191 |
+
"unchanged": 1936
|
| 192 |
+
},
|
| 193 |
+
"distractor_generators": {},
|
| 194 |
+
"option_count_histogram": {
|
| 195 |
+
"2": 685,
|
| 196 |
+
"3": 513,
|
| 197 |
+
"4": 269,
|
| 198 |
+
"5": 469
|
| 199 |
+
}
|
| 200 |
+
},
|
| 201 |
+
"infographic_vqa": {
|
| 202 |
+
"items": 1875,
|
| 203 |
+
"holdout": 93,
|
| 204 |
+
"train": 1782,
|
| 205 |
+
"added_v3": 0,
|
| 206 |
+
"excluded_vs_2026_10": 0,
|
| 207 |
+
"exclusion_reasons": {},
|
| 208 |
+
"construction": {
|
| 209 |
+
"regenerated_options": 1875
|
| 210 |
+
},
|
| 211 |
+
"distractor_generators": {
|
| 212 |
+
"perturb_gold": 1672,
|
| 213 |
+
"other_image_gold": 1971,
|
| 214 |
+
"same_image_annotation": 2037,
|
| 215 |
+
"original": 881
|
| 216 |
+
},
|
| 217 |
+
"option_count_histogram": {
|
| 218 |
+
"3": 469,
|
| 219 |
+
"4": 469,
|
| 220 |
+
"5": 469,
|
| 221 |
+
"6": 468
|
| 222 |
+
},
|
| 223 |
+
"regenerated_items_using_original_scheme": 564,
|
| 224 |
+
"regenerated_items": 1875
|
| 225 |
+
},
|
| 226 |
+
"mind2web": {
|
| 227 |
+
"items": 4914,
|
| 228 |
+
"holdout": 120,
|
| 229 |
+
"train": 4794,
|
| 230 |
+
"added_v3": 0,
|
| 231 |
+
"excluded_vs_2026_10": 86,
|
| 232 |
+
"exclusion_reasons": {
|
| 233 |
+
"board_dhash": 55,
|
| 234 |
+
"dev_dhash": 31
|
| 235 |
+
},
|
| 236 |
+
"construction": {
|
| 237 |
+
"unchanged": 1966,
|
| 238 |
+
"web_rerender": 2948
|
| 239 |
+
},
|
| 240 |
+
"distractor_generators": {},
|
| 241 |
+
"option_count_histogram": {
|
| 242 |
+
"3": 493,
|
| 243 |
+
"4": 3440,
|
| 244 |
+
"5": 493,
|
| 245 |
+
"6": 488
|
| 246 |
+
},
|
| 247 |
+
"rerendered_fraction": 0.5999
|
| 248 |
+
},
|
| 249 |
+
"mind2web_k": {
|
| 250 |
+
"items": 2226,
|
| 251 |
+
"holdout": 113,
|
| 252 |
+
"train": 2113,
|
| 253 |
+
"added_v3": 0,
|
| 254 |
+
"excluded_vs_2026_10": 35,
|
| 255 |
+
"exclusion_reasons": {
|
| 256 |
+
"board_dhash": 23,
|
| 257 |
+
"dev_dhash": 12
|
| 258 |
+
},
|
| 259 |
+
"construction": {
|
| 260 |
+
"unchanged": 891,
|
| 261 |
+
"web_rerender": 1335
|
| 262 |
+
},
|
| 263 |
+
"distractor_generators": {},
|
| 264 |
+
"option_count_histogram": {
|
| 265 |
+
"2": 114,
|
| 266 |
+
"3": 385,
|
| 267 |
+
"4": 735,
|
| 268 |
+
"5": 377,
|
| 269 |
+
"6": 370,
|
| 270 |
+
"7": 122,
|
| 271 |
+
"8": 123
|
| 272 |
+
},
|
| 273 |
+
"rerendered_fraction": 0.5997
|
| 274 |
+
},
|
| 275 |
+
"options_in_image": {
|
| 276 |
+
"items": 2004,
|
| 277 |
+
"holdout": 100,
|
| 278 |
+
"train": 1904,
|
| 279 |
+
"added_v3": 0,
|
| 280 |
+
"excluded_vs_2026_10": 10,
|
| 281 |
+
"exclusion_reasons": {
|
| 282 |
+
"board_dhash": 10
|
| 283 |
+
},
|
| 284 |
+
"construction": {
|
| 285 |
+
"unchanged": 2004
|
| 286 |
+
},
|
| 287 |
+
"distractor_generators": {},
|
| 288 |
+
"option_count_histogram": {
|
| 289 |
+
"2": 311,
|
| 290 |
+
"3": 309,
|
| 291 |
+
"4": 1363,
|
| 292 |
+
"5": 21
|
| 293 |
+
}
|
| 294 |
+
},
|
| 295 |
+
"scienceqa": {
|
| 296 |
+
"items": 3917,
|
| 297 |
+
"holdout": 117,
|
| 298 |
+
"train": 3800,
|
| 299 |
+
"added_v3": 0,
|
| 300 |
+
"excluded_vs_2026_10": 83,
|
| 301 |
+
"exclusion_reasons": {
|
| 302 |
+
"board_dhash": 81,
|
| 303 |
+
"dev_dhash": 2
|
| 304 |
+
},
|
| 305 |
+
"construction": {
|
| 306 |
+
"unchanged": 3917
|
| 307 |
+
},
|
| 308 |
+
"distractor_generators": {},
|
| 309 |
+
"option_count_histogram": {
|
| 310 |
+
"2": 1257,
|
| 311 |
+
"3": 1166,
|
| 312 |
+
"4": 1420,
|
| 313 |
+
"5": 74
|
| 314 |
+
}
|
| 315 |
+
},
|
| 316 |
+
"screen2words": {
|
| 317 |
+
"items": 1992,
|
| 318 |
+
"holdout": 90,
|
| 319 |
+
"train": 1902,
|
| 320 |
+
"added_v3": 0,
|
| 321 |
+
"excluded_vs_2026_10": 1,
|
| 322 |
+
"exclusion_reasons": {
|
| 323 |
+
"board_dhash": 1
|
| 324 |
+
},
|
| 325 |
+
"construction": {
|
| 326 |
+
"regenerated_options": 1992
|
| 327 |
+
},
|
| 328 |
+
"distractor_generators": {
|
| 329 |
+
"other_image_gold": 5713,
|
| 330 |
+
"original": 1259
|
| 331 |
+
},
|
| 332 |
+
"option_count_histogram": {
|
| 333 |
+
"3": 498,
|
| 334 |
+
"4": 498,
|
| 335 |
+
"5": 498,
|
| 336 |
+
"6": 498
|
| 337 |
+
},
|
| 338 |
+
"regenerated_items_using_original_scheme": 599,
|
| 339 |
+
"regenerated_items": 1992
|
| 340 |
+
},
|
| 341 |
+
"synthetic": {
|
| 342 |
+
"items": 5414,
|
| 343 |
+
"holdout": 115,
|
| 344 |
+
"train": 5299,
|
| 345 |
+
"added_v3": 0,
|
| 346 |
+
"excluded_vs_2026_10": 586,
|
| 347 |
+
"exclusion_reasons": {
|
| 348 |
+
"board_dhash": 586
|
| 349 |
+
},
|
| 350 |
+
"construction": {
|
| 351 |
+
"unchanged": 5414
|
| 352 |
+
},
|
| 353 |
+
"distractor_generators": {},
|
| 354 |
+
"option_count_histogram": {
|
| 355 |
+
"2": 2662,
|
| 356 |
+
"3": 418,
|
| 357 |
+
"4": 1581,
|
| 358 |
+
"5": 377,
|
| 359 |
+
"6": 376
|
| 360 |
+
}
|
| 361 |
+
},
|
| 362 |
+
"tallyqa": {
|
| 363 |
+
"items": 1998,
|
| 364 |
+
"holdout": 91,
|
| 365 |
+
"train": 1907,
|
| 366 |
+
"added_v3": 0,
|
| 367 |
+
"excluded_vs_2026_10": 1,
|
| 368 |
+
"exclusion_reasons": {
|
| 369 |
+
"board_dhash": 1
|
| 370 |
+
},
|
| 371 |
+
"construction": {
|
| 372 |
+
"unchanged": 1998
|
| 373 |
+
},
|
| 374 |
+
"distractor_generators": {},
|
| 375 |
+
"option_count_histogram": {
|
| 376 |
+
"4": 973,
|
| 377 |
+
"5": 558,
|
| 378 |
+
"6": 467
|
| 379 |
+
}
|
| 380 |
+
},
|
| 381 |
+
"visual7w": {
|
| 382 |
+
"items": 1999,
|
| 383 |
+
"holdout": 100,
|
| 384 |
+
"train": 1899,
|
| 385 |
+
"added_v3": 0,
|
| 386 |
+
"excluded_vs_2026_10": 1,
|
| 387 |
+
"exclusion_reasons": {
|
| 388 |
+
"board_dhash": 1
|
| 389 |
+
},
|
| 390 |
+
"construction": {
|
| 391 |
+
"unchanged": 1999
|
| 392 |
+
},
|
| 393 |
+
"distractor_generators": {},
|
| 394 |
+
"option_count_histogram": {
|
| 395 |
+
"4": 1999
|
| 396 |
+
}
|
| 397 |
+
},
|
| 398 |
+
"vsr": {
|
| 399 |
+
"items": 1945,
|
| 400 |
+
"holdout": 89,
|
| 401 |
+
"train": 1856,
|
| 402 |
+
"added_v3": 0,
|
| 403 |
+
"excluded_vs_2026_10": 0,
|
| 404 |
+
"exclusion_reasons": {},
|
| 405 |
+
"construction": {
|
| 406 |
+
"unchanged": 1945
|
| 407 |
+
},
|
| 408 |
+
"distractor_generators": {},
|
| 409 |
+
"option_count_histogram": {
|
| 410 |
+
"2": 1945
|
| 411 |
+
}
|
| 412 |
+
}
|
| 413 |
+
},
|
| 414 |
+
"total": {
|
| 415 |
+
"items": 51091,
|
| 416 |
+
"holdout": 1816,
|
| 417 |
+
"train": 49275,
|
| 418 |
+
"added_v3": 157,
|
| 419 |
+
"excluded": 2063
|
| 420 |
+
},
|
| 421 |
+
"option_count_histogram": {
|
| 422 |
+
"2": 9810,
|
| 423 |
+
"3": 7511,
|
| 424 |
+
"4": 21006,
|
| 425 |
+
"5": 6595,
|
| 426 |
+
"6": 5924,
|
| 427 |
+
"7": 122,
|
| 428 |
+
"8": 123
|
| 429 |
+
},
|
| 430 |
+
"distractor_generators": {
|
| 431 |
+
"original": 8143,
|
| 432 |
+
"same_image_annotation": 13932,
|
| 433 |
+
"other_image_gold": 22956,
|
| 434 |
+
"perturb_gold": 13413,
|
| 435 |
+
"opposite_boolean": 707
|
| 436 |
+
},
|
| 437 |
+
"original_scheme_share": {
|
| 438 |
+
"items_in_regenerated_sources": 18146,
|
| 439 |
+
"items_with_any_original_distractor": 4867,
|
| 440 |
+
"item_share": 0.2682,
|
| 441 |
+
"distractor_share_in_regenerated_items": 0.1437
|
| 442 |
+
},
|
| 443 |
+
"nlvr2": "unchanged; see vision-mix-2026-10/nlvr2 (identical ids, labels and teacher probabilities)",
|
| 444 |
+
"replay": {
|
| 445 |
+
"items": 4658,
|
| 446 |
+
"released": false
|
| 447 |
+
}
|
| 448 |
+
}
|
vision-mix-2026-10-v3/excluded.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/ai2d.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/aokvqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/chartqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/cord_train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/docvqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/funsd_train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/hateful_memes.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/iconqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/infographic_vqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/mind2web.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/mind2web_k.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/options_in_image.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/scienceqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/screen2words.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/synthetic.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/tallyqa.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/visual7w.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/manifests/vsr.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision-mix-2026-10-v3/scripts/build_mix_v2.py
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""CPU-only diversified training mix. Inputs under qev-data and bench are read-only."""
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import random
|
| 6 |
+
import re
|
| 7 |
+
import sys
|
| 8 |
+
import zipfile
|
| 9 |
+
import zlib
|
| 10 |
+
from collections import Counter, defaultdict
|
| 11 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 12 |
+
from decimal import Decimal, InvalidOperation
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
sys.dont_write_bytecode = True
|
| 16 |
+
import build_shift_dev as S
|
| 17 |
+
from PIL import Image, ImageDraw
|
| 18 |
+
|
| 19 |
+
ROOT, HOME, D, M = S.ROOT, S.HOME, S.D, S.M
|
| 20 |
+
OUT = ROOT / 'train-v2'
|
| 21 |
+
SEED = 20261022
|
| 22 |
+
REBUILD = {'infographic_vqa', 'docvqa', 'chartqa', 'cord_train', 'funsd_train', 'screen2words', 'ai2d'}
|
| 23 |
+
WEB = {'mind2web', 'mind2web_k'}
|
| 24 |
+
L = S.LETTERS
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def dump(path, value):
|
| 28 |
+
path.write_text(json.dumps(value, ensure_ascii=False, indent=2) + '\n')
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def gold(it):
|
| 32 |
+
return it['options'][L.index(it['gold'])]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def rowkey(it):
|
| 36 |
+
return Path(it['images'][0]).stem
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def fingerprint(path):
|
| 40 |
+
p = Path(path)
|
| 41 |
+
return dict(sha256=S.digest(p.read_bytes()), dhash=D.dhash_path(p), size=p.stat().st_size,
|
| 42 |
+
mtime=p.stat().st_mtime_ns)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def contexts(source, items):
|
| 46 |
+
"""Only upstream training answers / OCR; never read DEV answers."""
|
| 47 |
+
wanted = {rowkey(it) for it in items}
|
| 48 |
+
ctx = defaultdict(list)
|
| 49 |
+
if source in {'docvqa', 'infographic_vqa', 'screen2words', 'ai2d'}:
|
| 50 |
+
files = 1 if source == 'screen2words' else None
|
| 51 |
+
for ri, row in enumerate(D.caul_rows(source, files=files, cols=('texts',))):
|
| 52 |
+
if str(ri) not in wanted:
|
| 53 |
+
continue
|
| 54 |
+
for t in row['texts']:
|
| 55 |
+
if source == 'ai2d':
|
| 56 |
+
parsed = D.parse_mc(t['user'], t['assistant'])
|
| 57 |
+
if parsed:
|
| 58 |
+
ctx[str(ri)].extend(parsed[1])
|
| 59 |
+
else:
|
| 60 |
+
ctx[str(ri)].append(D.strip_a(t['assistant']))
|
| 61 |
+
elif source == 'cord_train':
|
| 62 |
+
for fi, f in enumerate(sorted((D.RAW / 'cord/data').glob('train-*.parquet'))):
|
| 63 |
+
for i, row in enumerate(S.pq.read_table(f, columns=['ground_truth']).to_pylist()):
|
| 64 |
+
key = f'train-{fi}-{i}'
|
| 65 |
+
if key in wanted:
|
| 66 |
+
ctx[key].extend(S.annotation_strings(json.loads(row['ground_truth'])))
|
| 67 |
+
elif source == 'funsd_train':
|
| 68 |
+
with zipfile.ZipFile(D.RAW / 'funsd/dataset.zip') as z:
|
| 69 |
+
for key in sorted(wanted):
|
| 70 |
+
ctx[key] = [e['text'] for e in json.loads(z.read(f'dataset/training_data/annotations/{key}.json'))['form']]
|
| 71 |
+
# ChartQA train parquet has query/label, not OCR or chart table annotations.
|
| 72 |
+
return ctx
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def number(s):
|
| 76 |
+
s = s.strip().casefold().replace(',', '').replace(' ', '').rstrip('.')
|
| 77 |
+
s = re.sub(r'^(?:usd|eur|[$€£])', '', s)
|
| 78 |
+
s = re.sub(r'(?:usd|eur)$', '', s)
|
| 79 |
+
if re.fullmatch(r'[-+]?(?:\d+(?:\.\d*)?|\.\d+)%?', s):
|
| 80 |
+
try:
|
| 81 |
+
return Decimal(s.rstrip('%')) / (100 if s.endswith('%') else 1)
|
| 82 |
+
except InvalidOperation:
|
| 83 |
+
pass
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def equivalent(a, b):
|
| 87 |
+
x, y = number(a), number(b)
|
| 88 |
+
return S.equivalent(a, b) or (x is not None and y is not None and x == y)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def answer_type(s):
|
| 92 |
+
if number(s) is not None:
|
| 93 |
+
return 'number'
|
| 94 |
+
return D.funsd_type(s)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def regenerate(it, pool, ctx, k, original, identity):
|
| 98 |
+
rng = random.Random(f'{SEED}:options:{it["id"]}')
|
| 99 |
+
g = gold(it)
|
| 100 |
+
same = ctx.get(rowkey(it), [])
|
| 101 |
+
generators = {
|
| 102 |
+
'original': [x for x in it['options'] if not equivalent(x, g)] if original else [],
|
| 103 |
+
'other_image_gold': [a for p, a in pool[answer_type(g)] if p != identity],
|
| 104 |
+
'perturb_gold': S.perturb(g, same),
|
| 105 |
+
'same_image_annotation': list(same),
|
| 106 |
+
}
|
| 107 |
+
# Caption word deletion/reordering can leave another correct summary. Binary
|
| 108 |
+
# presence tasks are left intact by the caller (only two semantic answers).
|
| 109 |
+
if it['source'] == 'screen2words':
|
| 110 |
+
generators['perturb_gold'] = []
|
| 111 |
+
generators['same_image_annotation'] = []
|
| 112 |
+
# All answers supplied for this exact question are accepted aliases, not negatives.
|
| 113 |
+
aliases = [g]
|
| 114 |
+
for values in generators.values():
|
| 115 |
+
rng.shuffle(values)
|
| 116 |
+
opts, kinds = [g], []
|
| 117 |
+
active = [key for key, values in generators.items() if values]
|
| 118 |
+
while len(opts) < k and active:
|
| 119 |
+
kind = 'original' if original and generators['original'] and not kinds else rng.choice(active)
|
| 120 |
+
values = generators[kind]
|
| 121 |
+
while values:
|
| 122 |
+
val = values.pop().strip()
|
| 123 |
+
if not val or len(val) > 200 or any(equivalent(val, x) for x in opts + aliases):
|
| 124 |
+
continue
|
| 125 |
+
if it['source'] == 'ai2d' and re.search(r'(?i)\b(above|both|all of|none of|neither)\b|\b[A-F]\s*(and|&|,)\s*[A-F]\b', val):
|
| 126 |
+
continue
|
| 127 |
+
# Do not treat truncations of the gold as wrong answers.
|
| 128 |
+
gn, vn = D.norm(g), D.norm(val)
|
| 129 |
+
if number(g) is None and len(gn) > 3 and len(vn) > 3 and (vn in gn or gn in vn):
|
| 130 |
+
continue
|
| 131 |
+
opts.append(val); kinds.append(kind)
|
| 132 |
+
break
|
| 133 |
+
if not values:
|
| 134 |
+
active.remove(kind)
|
| 135 |
+
if len(opts) != k:
|
| 136 |
+
raise RuntimeError(f'Insufficient safe distractors: {it["id"]}, k={k}')
|
| 137 |
+
order = list(range(k)); rng.shuffle(order)
|
| 138 |
+
new = dict(it, options=[opts[i] for i in order], gold=L[order.index(0)])
|
| 139 |
+
return new, dict(generators=kinds, option_count=k,
|
| 140 |
+
distractors=[dict(text=v, generator=kind) for v, kind in zip(opts[1:], kinds)])
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def render_web(it, row, k, palette, path):
|
| 144 |
+
"""Same annotated target, mixed nearby/random true negatives, two mark styles."""
|
| 145 |
+
rng = random.Random(f'{SEED}:web:{it["id"]}')
|
| 146 |
+
g = S.m2w_box(row['pos_candidates'][0])
|
| 147 |
+
im = M.pil(row['screenshot']).convert('RGB')
|
| 148 |
+
vh = min(im.height, S.VH)
|
| 149 |
+
top = int(max(0, min(im.height-vh, (g[1]+g[3])/2-vh/2)))
|
| 150 |
+
row['_posboxes'] = [b for b in map(S.m2w_box, row['pos_candidates']) if b]
|
| 151 |
+
row['_negboxes'] = [b for b in map(S.m2w_box, row['neg_candidates']) if b]
|
| 152 |
+
# Reuse DEV's geometry/filtering helper for spatial negatives.
|
| 153 |
+
geometry = S.shifted_geometry(im, row, g, dict(top=top, boxes=[g]), k, rng)
|
| 154 |
+
if geometry is None:
|
| 155 |
+
return None
|
| 156 |
+
close = [b for b in geometry['boxes'] if b != g]
|
| 157 |
+
candidates = list(row['_negboxes']); rng.shuffle(candidates)
|
| 158 |
+
chosen, modes = [], []
|
| 159 |
+
for slot in range(k-1):
|
| 160 |
+
mode = 'spatial' if slot % 2 == 0 else 'random'
|
| 161 |
+
preferred = close + candidates if mode == 'spatial' else candidates + close
|
| 162 |
+
for b in preferred:
|
| 163 |
+
if not (0 <= b[0] < b[2] <= im.width and top <= b[1] < b[3] <= top+vh):
|
| 164 |
+
continue
|
| 165 |
+
if b[2]-b[0] < 8 or b[3]-b[1] < 8 or b[2]-b[0] > .6*im.width or b[3]-b[1] > .4*vh:
|
| 166 |
+
continue
|
| 167 |
+
if any(S.overlaps(b, p) for p in row['_posboxes'] + chosen):
|
| 168 |
+
continue
|
| 169 |
+
chosen.append(b); modes.append(mode); break
|
| 170 |
+
else:
|
| 171 |
+
return None
|
| 172 |
+
target_label = gold(it).split()[-1]
|
| 173 |
+
if palette == 'kit':
|
| 174 |
+
if target_label not in 'ABCD':
|
| 175 |
+
raise ValueError('Kit A-D needs a target label in A-D')
|
| 176 |
+
labels = list('ABCD')
|
| 177 |
+
boxes = list(chosen)
|
| 178 |
+
boxes.insert(labels.index(target_label), g)
|
| 179 |
+
geometry = dict(top=top, boxes=boxes, gold_slot=labels.index(target_label))
|
| 180 |
+
S.render_m2w(im, geometry, path, numbered=False)
|
| 181 |
+
return dict(it, images=[str(path)], options=[f'box {x}' for x in labels], gold=target_label), dict(
|
| 182 |
+
generators=['web_rerender'], option_count=4, palette='kit', labels=labels,
|
| 183 |
+
negative_modes=modes, boxes=boxes, positive_boxes=row['_posboxes'], top=top, gold_box=g, gold_slot=labels.index(target_label))
|
| 184 |
+
labels = [target_label] + [x for x in L if x != target_label][:k-1]
|
| 185 |
+
boxes = [g] + chosen
|
| 186 |
+
order = list(range(k)); rng.shuffle(order)
|
| 187 |
+
boxes = [boxes[i] for i in order]; labels = [labels[i] for i in order]
|
| 188 |
+
slot = order.index(0)
|
| 189 |
+
# Keep the gold answer string even for old variable-k labels G/H.
|
| 190 |
+
crop = im.crop((0, top, im.width, top+vh))
|
| 191 |
+
draw = ImageDraw.Draw(crop)
|
| 192 |
+
font = M.font(max(16, min(crop.size)//38))
|
| 193 |
+
fs, width = max(16, min(crop.size)//38), max(3, min(crop.size)//180)
|
| 194 |
+
colors = ['#e6194b', '#3cb44b', '#4363d8', '#f58231'] if palette == 'letter' else ['#007c91', '#9c4f00', '#6844aa']
|
| 195 |
+
for i, b in enumerate(boxes):
|
| 196 |
+
b = [b[0], b[1]-top, b[2], b[3]-top]
|
| 197 |
+
color = colors[i % len(colors)]
|
| 198 |
+
draw.rectangle(b, outline=color, width=width)
|
| 199 |
+
label = labels[i] if palette == 'letter' else f'[{labels[i]}]'
|
| 200 |
+
tw = draw.textbbox((0, 0), label, font=font)[2] + 8
|
| 201 |
+
x, y = min(b[0], crop.width-tw), max(0, b[1]-fs-7)
|
| 202 |
+
draw.rectangle((x, y, x+tw, y+fs+6), fill=color)
|
| 203 |
+
draw.text((x+3, y), label, fill='white', font=font)
|
| 204 |
+
crop.save(path, quality=92)
|
| 205 |
+
return dict(it, images=[str(path)], options=[f'box {x}' for x in labels], gold=L[slot]), dict(
|
| 206 |
+
generators=['web_rerender'], option_count=k, palette=palette, labels=labels,
|
| 207 |
+
negative_modes=modes, boxes=boxes, positive_boxes=row['_posboxes'], top=top, gold_box=g, gold_slot=slot)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def build():
|
| 211 |
+
OUT.mkdir(exist_ok=True)
|
| 212 |
+
sources = {p.parent.name: S.read_items(p) for p in sorted((HOME/'qev-data/train').glob('*/items.jsonl'))}
|
| 213 |
+
devpaths = {p for f in (ROOT/'dev').rglob('items.jsonl') for it in S.read_items(f) for p in it['images']}
|
| 214 |
+
# Include orphaned images under dev as well as every referenced image.
|
| 215 |
+
devpaths.update(str(p) for p in (ROOT/'dev').rglob('*') if p.suffix.lower() in {'.jpg', '.jpeg', '.png', '.webp', '.bmp'})
|
| 216 |
+
paths = sorted(devpaths | {p for its in sources.values() for it in its for p in it['images']})
|
| 217 |
+
cachepath = OUT/'fingerprints.json'
|
| 218 |
+
cache = json.loads(cachepath.read_text()) if cachepath.exists() else {}
|
| 219 |
+
missing = [p for p in paths if p not in cache or cache[p]['mtime'] != Path(p).stat().st_mtime_ns or cache[p]['size'] != Path(p).stat().st_size]
|
| 220 |
+
with ThreadPoolExecutor(4) as ex:
|
| 221 |
+
for i, (p, fp) in enumerate(zip(missing, ex.map(fingerprint, missing)), 1):
|
| 222 |
+
if fp['dhash'] is None:
|
| 223 |
+
raise RuntimeError(f'Cannot fingerprint {p}')
|
| 224 |
+
cache[p] = fp
|
| 225 |
+
if i % 1000 == 0:
|
| 226 |
+
print(f'fingerprinted {i}/{len(missing)}', flush=True)
|
| 227 |
+
dump(cachepath, cache)
|
| 228 |
+
dump(cachepath, cache)
|
| 229 |
+
devsha = {cache[p]['sha256'] for p in devpaths}
|
| 230 |
+
devhash = S.np.array(sorted({cache[p]['dhash'] for p in devpaths}), dtype=S.np.uint64)
|
| 231 |
+
# Read an existing board hash cache; never let eval_hashes write to qev-data.
|
| 232 |
+
if not D.EVAL_CACHE.exists():
|
| 233 |
+
D.EVAL_CACHE = ROOT/'dev/eval_dhash.npy'
|
| 234 |
+
if not D.EVAL_CACHE.exists():
|
| 235 |
+
raise FileNotFoundError('Board dHash cache missing; refusing unchecked build')
|
| 236 |
+
ev = D.eval_hashes()
|
| 237 |
+
assert len(ev) and len(devhash)
|
| 238 |
+
bad = {}
|
| 239 |
+
for i, p in enumerate(paths):
|
| 240 |
+
if p in devpaths:
|
| 241 |
+
continue
|
| 242 |
+
fp = cache[p]
|
| 243 |
+
reason = ('dev_sha256' if fp['sha256'] in devsha else 'dev_dhash' if D.near_eval(fp['dhash'], devhash)
|
| 244 |
+
else 'board_dhash' if D.near_eval(fp['dhash'], ev) else None)
|
| 245 |
+
if reason:
|
| 246 |
+
bad[p] = reason
|
| 247 |
+
dump(OUT/'excluded-images.json', bad)
|
| 248 |
+
print(f'image audit: {len(paths)} paths, {len(bad)} excluded training images', flush=True)
|
| 249 |
+
counts, examples, provenance = {}, {}, {}
|
| 250 |
+
totals = Counter(); allhist = Counter(); changed_gold = 0
|
| 251 |
+
# Keep original order: crc32 capped DEV selection must not depend on rendering order.
|
| 252 |
+
for source, original in sources.items():
|
| 253 |
+
items = [it for it in original if not any(p in bad for p in it['images'])]
|
| 254 |
+
excluded = Counter(bad[p] for it in original for p in it['images'] if p in bad)
|
| 255 |
+
newitems, metadata = {}, {}
|
| 256 |
+
failures = Counter(); attempted = 0
|
| 257 |
+
if source in REBUILD:
|
| 258 |
+
ctx = contexts(source, items)
|
| 259 |
+
pool = defaultdict(list)
|
| 260 |
+
for it in items:
|
| 261 |
+
pool[answer_type(gold(it))].append((tuple(cache[p]['sha256'] for p in it['images']), gold(it)))
|
| 262 |
+
eligible = [it for it in items if it.get('subtask') != 'field_present']
|
| 263 |
+
schedule = sorted(eligible, key=lambda it: hashlib.sha256(f'{SEED}:schedule:{it["id"]}'.encode()).digest())
|
| 264 |
+
for i, it in enumerate(schedule):
|
| 265 |
+
k = 3 + i % 4
|
| 266 |
+
# Only 30% of eligible items may use original distractors, so both
|
| 267 |
+
# the item-level and distractor-level original fractions stay <=35%.
|
| 268 |
+
newitems[it['id']], metadata[it['id']] = regenerate(it, pool, ctx, k, i % 10 < 3, tuple(cache[p]['sha256'] for p in it['images']))
|
| 269 |
+
elif source in WEB:
|
| 270 |
+
# Exact 40% retention on surviving safe items; no render fallback to originals.
|
| 271 |
+
schedule = sorted(items, key=lambda it: hashlib.sha256(f'{SEED}:web-plan:{it["id"]}'.encode()).digest())
|
| 272 |
+
n_keep = (2*len(schedule)+4)//5
|
| 273 |
+
targets = {}
|
| 274 |
+
# Render a 10% reserve too, so near-DEV render attempts can be
|
| 275 |
+
# rejected without changing the final 40/60 retention ratio.
|
| 276 |
+
trial_start = max(0, n_keep - (len(schedule)+9)//10)
|
| 277 |
+
for i, it in enumerate(schedule[trial_start:]):
|
| 278 |
+
kit = i % 3 == 0 and gold(it).split()[-1] in 'ABCD'
|
| 279 |
+
targets[it['action_uid']] = (it, 4 if kit else 3+i % 4, 'kit' if kit else 'bracket')
|
| 280 |
+
attempted = len(targets)
|
| 281 |
+
imgdir = OUT/'img'/source; imgdir.mkdir(parents=True, exist_ok=True)
|
| 282 |
+
for f in sorted((D.RAW/'mind2web/data').glob('train-*.parquet')):
|
| 283 |
+
pf = S.pq.ParquetFile(f)
|
| 284 |
+
for rg in range(pf.num_row_groups):
|
| 285 |
+
# Read UID first to avoid decoding unused screenshot batches.
|
| 286 |
+
ids = pf.read_row_group(rg, columns=['action_uid']).column(0).to_pylist()
|
| 287 |
+
if not any(uid in targets for uid in ids):
|
| 288 |
+
continue
|
| 289 |
+
for row in pf.read_row_group(rg, columns=M.M2W_COLS).to_pylist():
|
| 290 |
+
if row['action_uid'] not in targets:
|
| 291 |
+
continue
|
| 292 |
+
it, k, palette = targets.pop(row['action_uid'])
|
| 293 |
+
path = imgdir/f'{row["action_uid"]}.jpg'
|
| 294 |
+
result = render_web(it, row, k, palette, path)
|
| 295 |
+
if result is None and palette != 'kit':
|
| 296 |
+
# Reduce k only when too few safe negatives fit this viewport.
|
| 297 |
+
for kk in range(k-1, 2, -1):
|
| 298 |
+
result = render_web(it, row, kk, palette, path)
|
| 299 |
+
if result:
|
| 300 |
+
break
|
| 301 |
+
if result is None:
|
| 302 |
+
metadata[it['id']] = dict(failed_rerender='insufficient_geometry')
|
| 303 |
+
continue
|
| 304 |
+
fp = fingerprint(path); cache[str(path)] = fp
|
| 305 |
+
if fp['sha256'] in devsha or D.near_eval(fp['dhash'], devhash) or D.near_eval(fp['dhash'], ev):
|
| 306 |
+
path.unlink()
|
| 307 |
+
metadata[it['id']] = dict(failed_rerender='rerender_near_dev_or_board')
|
| 308 |
+
continue
|
| 309 |
+
newitems[it['id']], metadata[it['id']] = result
|
| 310 |
+
print(f'{source}: scanned {f.name}, {len(targets)} remaining', flush=True)
|
| 311 |
+
if targets:
|
| 312 |
+
raise RuntimeError(f'Missing upstream web actions: {len(targets)}')
|
| 313 |
+
needed = len(schedule)-n_keep
|
| 314 |
+
successful = [it['id'] for it in schedule[trial_start:] if it['id'] in newitems]
|
| 315 |
+
if len(successful) < needed:
|
| 316 |
+
raise RuntimeError(f'{source}: only {len(successful)} safe rerenders for {needed} slots')
|
| 317 |
+
selected = set(successful[:needed])
|
| 318 |
+
failures = Counter(md['failed_rerender'] for md in metadata.values() if 'failed_rerender' in md)
|
| 319 |
+
for uid in list(newitems):
|
| 320 |
+
if uid not in selected:
|
| 321 |
+
Path(newitems.pop(uid)['images'][0]).unlink()
|
| 322 |
+
metadata = {uid: md for uid, md in metadata.items() if uid in selected}
|
| 323 |
+
keep_paths = {p for it in newitems.values() for p in it['images']}
|
| 324 |
+
for path in imgdir.glob('*.jpg'):
|
| 325 |
+
if str(path) not in keep_paths:
|
| 326 |
+
path.unlink()
|
| 327 |
+
# Every unselected item retains its exact, previously audited original.
|
| 328 |
+
print(source, 'rejected reserve attempts', dict(failures), flush=True)
|
| 329 |
+
result = []
|
| 330 |
+
mix = Counter(); hist = Counter(); kept_exact = 0; samples = []
|
| 331 |
+
for old in items:
|
| 332 |
+
md = metadata.get(old['id'], {})
|
| 333 |
+
if md.get('excluded'):
|
| 334 |
+
continue
|
| 335 |
+
new = newitems.get(old['id'], old)
|
| 336 |
+
assert new['id'] == old['id'] and new['question'] == old['question']
|
| 337 |
+
changed_gold += int(gold(new) != gold(old))
|
| 338 |
+
assert gold(new) == gold(old), old['id']
|
| 339 |
+
if new != old:
|
| 340 |
+
assert 3 <= len(new['options']) <= 6
|
| 341 |
+
for i, a in enumerate(new['options']):
|
| 342 |
+
assert all(not equivalent(a, b) for b in new['options'][i+1:]), new['id']
|
| 343 |
+
if len(samples) < 3:
|
| 344 |
+
samples.append(dict(id=old['id'], question=old['question'], gold=gold(old),
|
| 345 |
+
old_options=old['options'], new_options=new['options'], metadata=md))
|
| 346 |
+
else:
|
| 347 |
+
kept_exact += 1
|
| 348 |
+
result.append(new); hist[len(new['options'])] += 1
|
| 349 |
+
if md:
|
| 350 |
+
mix.update(md['generators'])
|
| 351 |
+
else:
|
| 352 |
+
mix['unchanged_binary' if source in REBUILD else 'web_exact' if source in WEB else 'unchanged_source'] += 1
|
| 353 |
+
folder = OUT/source; folder.mkdir(exist_ok=True)
|
| 354 |
+
(folder/'items.jsonl').write_text(''.join(json.dumps(it, ensure_ascii=False)+'\n' for it in result))
|
| 355 |
+
if metadata:
|
| 356 |
+
dump(folder/'generators.json', metadata)
|
| 357 |
+
counts[source] = dict(input=len(original), count=len(result), exact_items=kept_exact, changed_items=len(result)-kept_exact,
|
| 358 |
+
exclusions=dict(excluded), rerender_attempts=attempted, rejected_render_attempts=dict(failures),
|
| 359 |
+
generator_mix=dict(mix), option_count_histogram=dict(sorted(hist.items())))
|
| 360 |
+
examples[source] = samples
|
| 361 |
+
totals.update(mix); allhist.update(hist)
|
| 362 |
+
print(source, json.dumps(counts[source]), flush=True)
|
| 363 |
+
assert changed_gold == 0
|
| 364 |
+
dump(OUT/'examples.json', examples)
|
| 365 |
+
dump(cachepath, cache)
|
| 366 |
+
summary = dict(seed=SEED, sources=counts, per_source_counts={k:v['count'] for k,v in counts.items()},
|
| 367 |
+
generator_mix=dict(totals), option_count_histogram=dict(sorted(allhist.items())), gold_changed=changed_gold,
|
| 368 |
+
image_audit=dict(dev_images=len(devpaths), board_hashes=len(ev), training_excluded_images=len(bad), threshold=4),
|
| 369 |
+
split_policy='qev_mix_v2 reconstructs original crc32/cap membership before joining surviving IDs')
|
| 370 |
+
dump(OUT/'counts.json', summary)
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
if __name__ == '__main__':
|
| 374 |
+
build()
|
vision-mix-2026-10-v3/scripts/build_mix_v3.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Small CPU-only v3 overlay on the audited v2 mix; no public row input.
|
| 3 |
+
|
| 4 |
+
Reuse build_mix_v2's fingerprints, equivalence checks and upstream OCR reader.
|
| 5 |
+
Existing v2 image assets remain shared, read-only inputs. Only new A-OKVQA
|
| 6 |
+
images are encoded here. New rows are explicitly training-only.
|
| 7 |
+
"""
|
| 8 |
+
import hashlib
|
| 9 |
+
import json
|
| 10 |
+
import random
|
| 11 |
+
import shutil
|
| 12 |
+
import sys
|
| 13 |
+
import zlib
|
| 14 |
+
from collections import Counter
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
sys.dont_write_bytecode = True
|
| 18 |
+
import build_mix_v2 as V
|
| 19 |
+
|
| 20 |
+
R, H, S, D, M = V.ROOT, V.HOME, V.S, V.D, V.M
|
| 21 |
+
OUT = R / 'train-v3'
|
| 22 |
+
SEED = 20261023
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def original_dev_ids(source):
|
| 26 |
+
rows = S.read_items(H/'qev-data/train'/source/'items.jsonl')
|
| 27 |
+
limit = min(120, len(rows)//20)
|
| 28 |
+
selected = set()
|
| 29 |
+
for row in rows:
|
| 30 |
+
if len(selected) < limit and zlib.crc32(row['id'].encode()) % 20 == 0:
|
| 31 |
+
selected.add(row['id'])
|
| 32 |
+
return selected
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def presence(it, annotation, k):
|
| 36 |
+
"""Both semantic answers plus OCR decoys; OCR is never a valid yes/no answer."""
|
| 37 |
+
rng = random.Random(f'{SEED}:presence:{it["id"]}')
|
| 38 |
+
g = V.gold(it)
|
| 39 |
+
assert g in {'Yes', 'No'}
|
| 40 |
+
values = sorted(set(x.strip() for x in annotation if x.strip() and len(x.strip()) <= 200))
|
| 41 |
+
rng.shuffle(values)
|
| 42 |
+
opts = [g, 'No' if g == 'Yes' else 'Yes']
|
| 43 |
+
kinds = ['opposite_boolean']
|
| 44 |
+
for val in values:
|
| 45 |
+
if any(V.equivalent(val, x) for x in opts):
|
| 46 |
+
continue
|
| 47 |
+
opts.append(val); kinds.append('same_image_annotation')
|
| 48 |
+
if len(opts) == k:
|
| 49 |
+
break
|
| 50 |
+
if len(opts) != k:
|
| 51 |
+
raise ValueError(f'Insufficient OCR options for {it["id"]}: k={k}')
|
| 52 |
+
order = list(range(k)); rng.shuffle(order)
|
| 53 |
+
new = dict(it, options=[opts[i] for i in order], gold=V.L[order.index(0)])
|
| 54 |
+
return new, dict(generators=kinds, option_count=k, v3_presence=True,
|
| 55 |
+
distractors=[dict(text=x, generator=kind) for x, kind in zip(opts[1:], kinds)])
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def build():
|
| 59 |
+
OUT.mkdir(exist_ok=True)
|
| 60 |
+
base = R/'train-v2'
|
| 61 |
+
assert json.loads((base/'validation.json').read_text())['passed']
|
| 62 |
+
counts = json.loads((base/'counts.json').read_text())
|
| 63 |
+
cache = json.loads((base/'fingerprints.json').read_text())
|
| 64 |
+
rows = {}
|
| 65 |
+
provenance = {}
|
| 66 |
+
for f in sorted(base.glob('*/items.jsonl')):
|
| 67 |
+
source = f.parent.name
|
| 68 |
+
rows[source] = S.read_items(f)
|
| 69 |
+
p = f.parent/'generators.json'
|
| 70 |
+
provenance[source] = json.loads(p.read_text()) if p.exists() else {}
|
| 71 |
+
devpaths = {p for f in (R/'dev').rglob('items.jsonl') for it in S.read_items(f) for p in it['images']}
|
| 72 |
+
devpaths.update(str(p) for p in (R/'dev').rglob('*') if p.suffix.lower() in {'.jpg','.jpeg','.png','.webp','.bmp'})
|
| 73 |
+
devsha = {cache[p]['sha256'] for p in devpaths}
|
| 74 |
+
devhash = S.np.array(sorted({cache[p]['dhash'] for p in devpaths}), dtype=S.np.uint64)
|
| 75 |
+
if not D.EVAL_CACHE.exists():
|
| 76 |
+
D.EVAL_CACHE = R/'dev/eval_dhash.npy'
|
| 77 |
+
if not D.EVAL_CACHE.exists():
|
| 78 |
+
raise FileNotFoundError('Board hash cache required; never rebuild it outside this workspace')
|
| 79 |
+
boardhash = D.eval_hashes()
|
| 80 |
+
assert len(boardhash) and len(devhash)
|
| 81 |
+
screening = Counter()
|
| 82 |
+
|
| 83 |
+
def screen(path, priorhash):
|
| 84 |
+
fp = V.fingerprint(path)
|
| 85 |
+
if fp['dhash'] is None:
|
| 86 |
+
reason = 'unreadable'
|
| 87 |
+
elif fp['sha256'] in devsha:
|
| 88 |
+
reason = 'dev_sha256'
|
| 89 |
+
elif D.near_eval(fp['dhash'], devhash):
|
| 90 |
+
reason = 'dev_dhash'
|
| 91 |
+
elif D.near_eval(fp['dhash'], boardhash):
|
| 92 |
+
reason = 'board_dhash'
|
| 93 |
+
elif D.near_eval(fp['dhash'], S.np.array(priorhash, dtype=S.np.uint64)):
|
| 94 |
+
reason = 'same_source_near_duplicate'
|
| 95 |
+
else:
|
| 96 |
+
cache[str(path)] = fp
|
| 97 |
+
priorhash.append(fp['dhash'])
|
| 98 |
+
return True
|
| 99 |
+
screening[reason] += 1
|
| 100 |
+
return False
|
| 101 |
+
|
| 102 |
+
additions = {'hateful_memes': [], 'aokvqa': []}
|
| 103 |
+
upstream = {}
|
| 104 |
+
# Restore each removed class count using only upstream TRAIN labels, never
|
| 105 |
+
# public predictions, gold labels, texts or identifiers.
|
| 106 |
+
source = 'hateful_memes'
|
| 107 |
+
original = S.read_items(H/'qev-data/train'/source/'items.jsonl')
|
| 108 |
+
oldids = {it['id'] for it in original}
|
| 109 |
+
need = Counter(V.gold(it) for it in original)
|
| 110 |
+
need.subtract(Counter(V.gold(it) for it in rows[source]))
|
| 111 |
+
initial_need = dict(need)
|
| 112 |
+
prior = [cache[it['images'][0]]['dhash'] for it in original]
|
| 113 |
+
rawpath = D.RAW/source/'train.jsonl'
|
| 114 |
+
candidates = S.read_items(rawpath)
|
| 115 |
+
candidates.sort(key=lambda r: hashlib.sha256(f'{SEED}:new-hm:{r["id"]}'.encode()).digest())
|
| 116 |
+
for row in candidates:
|
| 117 |
+
uid = f'{source}:{row["id"]}'
|
| 118 |
+
label = 'Yes' if row['label'] == 1 else 'No'
|
| 119 |
+
if uid in oldids or need[label] <= 0:
|
| 120 |
+
continue
|
| 121 |
+
# Explicit train-only policy also agrees with the un-capped CRC rule.
|
| 122 |
+
if zlib.crc32(uid.encode()) % 20 == 0:
|
| 123 |
+
screening['candidate_crc_holdout'] += 1
|
| 124 |
+
continue
|
| 125 |
+
path = D.RAW/source/row['img']
|
| 126 |
+
if not path.exists():
|
| 127 |
+
screening['missing_file'] += 1
|
| 128 |
+
continue
|
| 129 |
+
if not screen(path, prior):
|
| 130 |
+
continue
|
| 131 |
+
item = dict(id=uid, source=source, images=[str(path)], question='Is this meme hateful?',
|
| 132 |
+
options=['Yes','No'], gold='A' if row['label'] == 1 else 'B', vision_only=False, subtask='binary')
|
| 133 |
+
rows[source].append(item); additions[source].append(uid); need[label] -= 1
|
| 134 |
+
upstream[uid] = dict(split='train', file=str(rawpath), upstream_id=row['id'], label=row['label'])
|
| 135 |
+
if not any(need.values()):
|
| 136 |
+
break
|
| 137 |
+
assert not any(need.values()), need
|
| 138 |
+
source = 'aokvqa'
|
| 139 |
+
original = S.read_items(H/'qev-data/train'/source/'items.jsonl')
|
| 140 |
+
oldids = {it['id'] for it in original}
|
| 141 |
+
prior = [cache[it['images'][0]]['dhash'] for it in original]
|
| 142 |
+
need_aok = len(original)-len(rows[source])
|
| 143 |
+
imgdir = OUT/'img'/source; imgdir.mkdir(parents=True, exist_ok=True)
|
| 144 |
+
for i, row in enumerate(M.rows('aokvqa/data/train-*.parquet')):
|
| 145 |
+
uid = f'aokvqa:{i}'
|
| 146 |
+
if uid in oldids or zlib.crc32(uid.encode()) % 20 == 0:
|
| 147 |
+
continue
|
| 148 |
+
options = [str(x).strip() for x in row['choices']]
|
| 149 |
+
if (not 2 <= len(options) <= 16 or not all(options)
|
| 150 |
+
or any(V.equivalent(a,b) for j,a in enumerate(options) for b in options[j+1:])):
|
| 151 |
+
screening['invalid_or_equivalent_upstream_options'] += 1
|
| 152 |
+
continue
|
| 153 |
+
path = imgdir/f'aok{i}.jpg'
|
| 154 |
+
with M.pil(row['image']) as im:
|
| 155 |
+
path.write_bytes(S.jpeg(im, docs=False))
|
| 156 |
+
if not screen(path, prior):
|
| 157 |
+
path.unlink(); continue
|
| 158 |
+
order = list(range(len(row['choices'])))
|
| 159 |
+
random.Random(f'{SEED}:new-aok:{i}').shuffle(order)
|
| 160 |
+
item = dict(id=uid, source=source, images=[str(path)], question=row['question'],
|
| 161 |
+
options=[options[j] for j in order],
|
| 162 |
+
gold=V.L[order.index(row['correct_choice_idx'])], vision_only=False, subtask='commonsense')
|
| 163 |
+
rows[source].append(item); additions[source].append(uid)
|
| 164 |
+
upstream[uid] = dict(split='train', pattern='aokvqa/data/train-*.parquet', upstream_row=i,
|
| 165 |
+
gold_answer=str(row['choices'][row['correct_choice_idx']]).strip())
|
| 166 |
+
if len(additions[source]) == need_aok:
|
| 167 |
+
break
|
| 168 |
+
assert len(additions[source]) == need_aok
|
| 169 |
+
referenced = {it['images'][0] for it in rows[source]}
|
| 170 |
+
for path in imgdir.glob('*.jpg'):
|
| 171 |
+
if str(path) not in referenced:
|
| 172 |
+
path.unlink()
|
| 173 |
+
|
| 174 |
+
source = 'cord_train'
|
| 175 |
+
holdout = original_dev_ids(source)
|
| 176 |
+
eligible = [it for it in rows[source] if it['subtask']=='field_present' and it['id'] not in holdout]
|
| 177 |
+
# Fixed half of training presence rows gets the missing boolean+OCR task;
|
| 178 |
+
# preserve half binary and preserve all existing selection items byte-for-byte.
|
| 179 |
+
eligible.sort(key=lambda it: hashlib.sha256(f'{SEED}:cord-plan:{it["id"]}'.encode()).digest())
|
| 180 |
+
chosen = eligible[:len(eligible)//2]
|
| 181 |
+
context = V.contexts(source, chosen)
|
| 182 |
+
changed = {}
|
| 183 |
+
for i,it in enumerate(chosen):
|
| 184 |
+
changed[it['id']], provenance[source][it['id']] = presence(it, context[V.rowkey(it)], 3+i%4)
|
| 185 |
+
rows[source] = [changed.get(it['id'], it) for it in rows[source]]
|
| 186 |
+
|
| 187 |
+
summary = dict(counts, version=3, seed_v3=SEED, base_mix=str(base),
|
| 188 |
+
train_only_additions=additions, additions_count=sum(map(len, additions.values())),
|
| 189 |
+
restored_hateful_class_counts=initial_need, candidate_screening=dict(screening),
|
| 190 |
+
cord_presence_changed=len(changed), cord_presence_training_eligible=len(eligible),
|
| 191 |
+
split_policy='Original crc32/capped membership unchanged; additions explicitly TRAIN only with V3_TRAIN_ADDITIONS=1',
|
| 192 |
+
gold_changed=0)
|
| 193 |
+
hist = Counter(); gen = Counter()
|
| 194 |
+
for source, items in rows.items():
|
| 195 |
+
folder = OUT/source; folder.mkdir(exist_ok=True)
|
| 196 |
+
(folder/'items.jsonl').write_text(''.join(json.dumps(it,ensure_ascii=False)+'\n' for it in items))
|
| 197 |
+
if provenance[source]:
|
| 198 |
+
V.dump(folder/'generators.json',provenance[source])
|
| 199 |
+
old = {it['id']:it for it in S.read_items(H/'qev-data/train'/source/'items.jsonl')}
|
| 200 |
+
exact = sum(it==old.get(it['id']) for it in items)
|
| 201 |
+
mix = Counter()
|
| 202 |
+
for it in items:
|
| 203 |
+
if it['id'] in old:
|
| 204 |
+
assert V.gold(it)==V.gold(old[it['id']]) and it['question']==old[it['id']]['question']
|
| 205 |
+
mix.update(provenance[source][it['id']]['generators'] if it['id'] in provenance[source]
|
| 206 |
+
else ['unchanged_binary' if source in V.REBUILD else 'web_exact' if source in V.WEB else 'unchanged_source'])
|
| 207 |
+
shist = Counter(len(it['options']) for it in items)
|
| 208 |
+
summary['sources'][source] = dict(summary['sources'][source], count=len(items), exact_items=exact,
|
| 209 |
+
changed_items=sum(it['id'] in old and it!=old[it['id']] for it in items),
|
| 210 |
+
added_items=len(additions.get(source,[])),
|
| 211 |
+
generator_mix=dict(mix),option_count_histogram=dict(sorted(shist.items())))
|
| 212 |
+
hist.update(shist);gen.update(mix)
|
| 213 |
+
summary['per_source_counts']={s:len(items) for s,items in rows.items()}
|
| 214 |
+
summary['option_count_histogram']=dict(sorted(hist.items()));summary['generator_mix']=dict(gen)
|
| 215 |
+
V.dump(OUT/'counts.json',summary)
|
| 216 |
+
V.dump(OUT/'train-only-additions.json',additions)
|
| 217 |
+
V.dump(OUT/'upstream-additions.json',upstream)
|
| 218 |
+
V.dump(OUT/'fingerprints.json',cache)
|
| 219 |
+
shutil.copyfile(base/'excluded-images.json',OUT/'excluded-images.json')
|
| 220 |
+
print(json.dumps({k:summary[k] for k in ['per_source_counts','additions_count','restored_hateful_class_counts','candidate_screening','cord_presence_changed']},indent=2))
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
if __name__=='__main__':
|
| 224 |
+
build()
|
vision-mix-2026-10-v3/scripts/build_shift_dev.py
ADDED
|
@@ -0,0 +1,861 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Paired distractor-shift DEV, using only upstream training annotations.
|
| 3 |
+
Run with python3 build_shift_dev.py; set QEV_HOME to override the home directory. Never writes to input trees.
|
| 4 |
+
"""
|
| 5 |
+
import argparse
|
| 6 |
+
import hashlib
|
| 7 |
+
import io
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
import random
|
| 11 |
+
import re
|
| 12 |
+
import shutil
|
| 13 |
+
import sys
|
| 14 |
+
from collections import Counter, defaultdict
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
sys.dont_write_bytecode = True
|
| 18 |
+
|
| 19 |
+
import numpy as np
|
| 20 |
+
import pyarrow.parquet as pq
|
| 21 |
+
from PIL import Image, ImageDraw
|
| 22 |
+
|
| 23 |
+
ROOT = Path(__file__).resolve().parent
|
| 24 |
+
HOME = Path(os.environ.get('QEV_HOME', Path.home()))
|
| 25 |
+
sys.path[:0] = [str(HOME / 'qev-data/scripts'), str(HOME / 'bench/decision-index')]
|
| 26 |
+
import build_docs as D
|
| 27 |
+
import build_mix as M
|
| 28 |
+
from decision_index.vision.convert import overlaps
|
| 29 |
+
from decision_index.vision.build import m2w_box, VH
|
| 30 |
+
|
| 31 |
+
SEED = 20261022
|
| 32 |
+
SOURCES = ['infographic_vqa', 'docvqa', 'chartqa', 'cord_train', 'funsd_train', 'mind2web']
|
| 33 |
+
LETTERS = M.L
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def read_items(path):
|
| 37 |
+
if not path.exists():
|
| 38 |
+
raise FileNotFoundError(path)
|
| 39 |
+
return [json.loads(line) for line in path.read_text().splitlines() if line.strip()]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def digest(data):
|
| 43 |
+
return hashlib.sha256(data).hexdigest()
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def jpeg(im, docs=True):
|
| 47 |
+
"""Exactly the original Src.img / Sink.img image transformation."""
|
| 48 |
+
im = im.copy()
|
| 49 |
+
if docs:
|
| 50 |
+
if max(im.size) > D.MAX_SIDE:
|
| 51 |
+
s = D.MAX_SIDE / max(im.size)
|
| 52 |
+
im = im.resize(tuple(max(1, round(x * s)) for x in im.size), Image.Resampling.LANCZOS)
|
| 53 |
+
if im.mode in ('RGBA', 'LA', 'P') and (im.mode != 'P' or 'transparency' in im.info):
|
| 54 |
+
bg = Image.new('RGB', im.size, 'white')
|
| 55 |
+
im = im.convert('RGBA')
|
| 56 |
+
bg.paste(im, mask=im.getchannel('A'))
|
| 57 |
+
im = bg
|
| 58 |
+
else:
|
| 59 |
+
im = im.convert('RGB')
|
| 60 |
+
if im.width * im.height > M.MAXPX:
|
| 61 |
+
s = (M.MAXPX / (im.width * im.height)) ** .5
|
| 62 |
+
im = im.resize((int(im.width * s), int(im.height * s)), Image.Resampling.LANCZOS)
|
| 63 |
+
out = io.BytesIO()
|
| 64 |
+
im.convert('RGB').save(out, format='JPEG', quality=92 if docs else 90)
|
| 65 |
+
return out.getvalue()
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def annotation_strings(x):
|
| 69 |
+
if isinstance(x, str):
|
| 70 |
+
yield x
|
| 71 |
+
elif isinstance(x, dict):
|
| 72 |
+
for v in x.values():
|
| 73 |
+
yield from annotation_strings(v)
|
| 74 |
+
elif isinstance(x, list):
|
| 75 |
+
for v in x:
|
| 76 |
+
yield from annotation_strings(v)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class Collector(D.Src):
|
| 80 |
+
"""Reuse Src.add unchanged; replace IO and selection, never construct a real Src/Sink."""
|
| 81 |
+
def __init__(self, name, target, ev):
|
| 82 |
+
self.name, self.target, self.ev = name, target, ev
|
| 83 |
+
self.dir = ROOT / 'dev/img' / name
|
| 84 |
+
self.dir.mkdir(parents=True, exist_ok=True)
|
| 85 |
+
self.items, self.hash, self.context, self.row_of = [], {}, {}, {}
|
| 86 |
+
self.answers = []
|
| 87 |
+
self.fingerprints = {}
|
| 88 |
+
self.letters = {}
|
| 89 |
+
self.rng = random.Random(f'{D.SEED}:{name}:shuffle')
|
| 90 |
+
self.train = read_items(HOME / f'qev-data/train/{name}/items.jsonl')
|
| 91 |
+
if name == 'mind2web':
|
| 92 |
+
self.train += read_items(HOME / 'qev-data/train/mind2web_k/items.jsonl')
|
| 93 |
+
self.used = {x['id'].split(':')[1] for x in self.train}
|
| 94 |
+
self.used.update(Path(p).stem for x in self.train for p in x['images'])
|
| 95 |
+
self.train_jpegs = {digest(Path(p).read_bytes()) for x in self.train for p in x['images']}
|
| 96 |
+
self.kept_rows, self.selected_jpegs = set(), set()
|
| 97 |
+
self.stats = Counter()
|
| 98 |
+
self.stats['training_items'] = len(self.train)
|
| 99 |
+
self.stats['training_row_keys'] = len({x['id'].split(':')[1] for x in self.train})
|
| 100 |
+
self.stats['training_unique_rendered_images'] = len(self.train_jpegs)
|
| 101 |
+
|
| 102 |
+
def img(self, data, stem):
|
| 103 |
+
if stem in self.hash:
|
| 104 |
+
return self.hash[stem]
|
| 105 |
+
self.stats['candidate_rows'] += 1
|
| 106 |
+
self.hash[stem] = None
|
| 107 |
+
if self.name != 'chartqa' and stem in self.used:
|
| 108 |
+
self.stats['excluded_training_rows'] += 1
|
| 109 |
+
return None
|
| 110 |
+
im = Image.open(io.BytesIO(data)) if isinstance(data, (bytes, bytearray)) else data
|
| 111 |
+
im.load()
|
| 112 |
+
encoded = jpeg(im, docs=self.name not in ('chartqa', 'mind2web'))
|
| 113 |
+
h = digest(encoded)
|
| 114 |
+
self.fingerprints[stem] = h
|
| 115 |
+
if h in self.train_jpegs:
|
| 116 |
+
self.stats['excluded_training_image_aliases'] += 1
|
| 117 |
+
return None
|
| 118 |
+
if self.ev is not None and (D.near_eval(D.dhash_im(im), self.ev) or
|
| 119 |
+
D.near_eval(D.dhash_im(Image.open(io.BytesIO(encoded))), self.ev)):
|
| 120 |
+
self.stats['excluded_eval_near_images'] += 1
|
| 121 |
+
return None
|
| 122 |
+
if h in self.selected_jpegs:
|
| 123 |
+
self.stats['excluded_duplicate_dev_images'] += 1
|
| 124 |
+
return None
|
| 125 |
+
if len(self.kept_rows) >= self.target:
|
| 126 |
+
self.stats['over_target_rows'] += 1
|
| 127 |
+
return None
|
| 128 |
+
p = self.dir / f'{stem}.jpg'
|
| 129 |
+
p.write_bytes(encoded)
|
| 130 |
+
self.hash[stem] = str(p)
|
| 131 |
+
self.selected_jpegs.add(h)
|
| 132 |
+
self.kept_rows.add(stem)
|
| 133 |
+
return str(p)
|
| 134 |
+
|
| 135 |
+
def add(self, sid, images, question, gold, distractors, subtask, keep_order=None):
|
| 136 |
+
answer = keep_order[0][keep_order[1]] if keep_order is not None else gold
|
| 137 |
+
self.answers.append((sid.split(':')[0], str(answer)))
|
| 138 |
+
before = len(self.items)
|
| 139 |
+
ok = super().add(sid, images, question, gold, distractors, subtask, keep_order)
|
| 140 |
+
if ok:
|
| 141 |
+
self.row_of[self.items[-1]['id']] = sid.split(':')[0]
|
| 142 |
+
assert len(self.items) - before == int(bool(ok))
|
| 143 |
+
return ok
|
| 144 |
+
|
| 145 |
+
def close(self):
|
| 146 |
+
return self
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def collect_docs(c):
|
| 150 |
+
"""Run the original builders at an uncapped candidate budget; cap upstream images in img()."""
|
| 151 |
+
old = D.Src
|
| 152 |
+
D.Src = lambda name: c
|
| 153 |
+
try:
|
| 154 |
+
if c.name in ('docvqa', 'infographic_vqa'):
|
| 155 |
+
# Same original eligibility, question cleanup, pools, distractors and Src.add ordering.
|
| 156 |
+
D.docqa(c.name, c.name, 10**9, max_per_img=2)
|
| 157 |
+
for ri, r in enumerate(D.caul_rows(c.name, cols=('texts',))):
|
| 158 |
+
c.context[str(ri)] = [D.strip_a(t['assistant']) for t in r['texts']]
|
| 159 |
+
elif c.name == 'cord_train':
|
| 160 |
+
D.cord_train(cap=10**9)
|
| 161 |
+
for fi, f in enumerate(sorted((D.RAW / 'cord/data').glob('train-*.parquet'))):
|
| 162 |
+
for i, r in enumerate(pq.read_table(f, columns=['ground_truth']).to_pylist()):
|
| 163 |
+
gt = json.loads(r['ground_truth'])
|
| 164 |
+
c.context[f'train-{fi}-{i}'] = list(annotation_strings(gt.get('gt_parse', {})))
|
| 165 |
+
else:
|
| 166 |
+
D.funsd_train(cap=10**9)
|
| 167 |
+
import zipfile
|
| 168 |
+
with zipfile.ZipFile(D.RAW / 'funsd/dataset.zip') as z:
|
| 169 |
+
for n in sorted(z.namelist()):
|
| 170 |
+
if n.startswith('dataset/training_data/annotations/') and n.endswith('.json'):
|
| 171 |
+
c.context[Path(n).stem] = [e['text'] for e in json.loads(z.read(n))['form']]
|
| 172 |
+
finally:
|
| 173 |
+
D.Src = old
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def collect_chart(c):
|
| 177 |
+
"""Reuse chartqa and Sink.add. Match rendered training images, not shuffled numeric IDs."""
|
| 178 |
+
class ChartSink:
|
| 179 |
+
def __init__(self, name):
|
| 180 |
+
self.name, self.n = name, 0
|
| 181 |
+
self.f = io.StringIO()
|
| 182 |
+
def img(self, im, stem):
|
| 183 |
+
return c.img(im, stem)
|
| 184 |
+
def close(self):
|
| 185 |
+
pass
|
| 186 |
+
original = M.Sink
|
| 187 |
+
original_add = original.add
|
| 188 |
+
def add(self, sid, images, *args, **kwargs):
|
| 189 |
+
c.answers.append((f'cq{sid}', str(args[1][args[2]])))
|
| 190 |
+
if any(p is None for p in images):
|
| 191 |
+
return False
|
| 192 |
+
result = original_add(self, sid, images, *args, **kwargs)
|
| 193 |
+
if result:
|
| 194 |
+
item = json.loads(self.f.getvalue().splitlines()[-1])
|
| 195 |
+
c.items.append(item)
|
| 196 |
+
c.row_of[item['id']] = f'cq{sid}'
|
| 197 |
+
c.context[f'cq{sid}'] = []
|
| 198 |
+
return result
|
| 199 |
+
ChartSink.add = add
|
| 200 |
+
M.Sink = ChartSink
|
| 201 |
+
try:
|
| 202 |
+
M.chartqa(c.target, random.Random(20261017))
|
| 203 |
+
finally:
|
| 204 |
+
M.Sink = original
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def perturb(gold, same):
|
| 208 |
+
out = []
|
| 209 |
+
matches = list(re.finditer(r'\d+(?:\.\d+)?', gold))
|
| 210 |
+
for m in matches:
|
| 211 |
+
val = float(m[0])
|
| 212 |
+
dec = len(m[0].split('.')[1]) if '.' in m[0] else 0
|
| 213 |
+
for v in [val + d * 10**(-dec) for d in (-3, -2, -1, 1, 2, 3)] + [val * 10, val / 10]:
|
| 214 |
+
# Keep scaling decimals rather than rounding the change away.
|
| 215 |
+
text = f'{v:.{dec}f}' if v == round(v, dec) else f'{v:g}'
|
| 216 |
+
out.append(gold[:m.start()] + text + gold[m.end():])
|
| 217 |
+
if matches:
|
| 218 |
+
out.append(gold.replace('%', '') if '%' in gold else gold + '%')
|
| 219 |
+
for a, b in [('kg', 'g'), ('km', 'm'), ('USD', 'EUR'), ('$', '€'), ('cm', 'mm')]:
|
| 220 |
+
if a in gold:
|
| 221 |
+
out.append(gold.replace(a, b))
|
| 222 |
+
else:
|
| 223 |
+
words = gold.split()
|
| 224 |
+
if len(words) > 1:
|
| 225 |
+
out.extend(' '.join(words[:i] + words[i+1:]) for i in range(len(words)))
|
| 226 |
+
out.append(' '.join([words[1], words[0]] + words[2:]))
|
| 227 |
+
# Near-miss strings must actually be supplied by this image's annotations.
|
| 228 |
+
from difflib import SequenceMatcher
|
| 229 |
+
out.extend(s for s in same if .45 <= SequenceMatcher(None, gold.lower(), s.lower()).ratio() < 1)
|
| 230 |
+
return out
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def equivalent(a, b):
|
| 234 |
+
"""Avoid exact/formatting aliases and numerically equivalent answer options."""
|
| 235 |
+
if D.norm(a) == D.norm(b):
|
| 236 |
+
return True
|
| 237 |
+
def number(s):
|
| 238 |
+
s = s.strip().replace(',', '').replace(' ', '')
|
| 239 |
+
if re.fullmatch(r'[-+]?\d+(?:\.\d+)?%?', s):
|
| 240 |
+
return float(s.rstrip('%')) / (100 if s.endswith('%') else 1)
|
| 241 |
+
x, y = number(a), number(b)
|
| 242 |
+
return x is not None and y is not None and abs(x-y) < 1e-10
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def shifted(c, fixed_k=None, kinds_allowed=None):
|
| 246 |
+
pool = defaultdict(list)
|
| 247 |
+
# Only gold answers of real upstream questions enter generator 1. Annotation
|
| 248 |
+
# strings (including labels and OCR tokens) belong to generator 3 instead.
|
| 249 |
+
for row, answer in c.answers:
|
| 250 |
+
pool[D.isnum(answer)].append((row, answer))
|
| 251 |
+
result, provenance = [], {}
|
| 252 |
+
for it in c.items:
|
| 253 |
+
rng = random.Random(f'{SEED}:B:{it["id"]}')
|
| 254 |
+
row = c.row_of[it['id']]
|
| 255 |
+
gold = it['options'][LETTERS.index(it['gold'])]
|
| 256 |
+
same = c.context.get(row, [])
|
| 257 |
+
generators = {
|
| 258 |
+
'other_image_gold': [v for r, v in pool[D.isnum(gold)]
|
| 259 |
+
if r != row and c.fingerprints.get(r, r) != c.fingerprints.get(row, row)],
|
| 260 |
+
'perturb_gold': perturb(gold, same),
|
| 261 |
+
'same_image_annotation': list(same),
|
| 262 |
+
}
|
| 263 |
+
if kinds_allowed is not None:
|
| 264 |
+
generators = {key: value for key, value in generators.items() if key in kinds_allowed}
|
| 265 |
+
# Presence tasks have only two semantic answers. Additional choices are text strings;
|
| 266 |
+
# report them separately so their difficulty shift cannot be mistaken for value reading.
|
| 267 |
+
for values in generators.values():
|
| 268 |
+
rng.shuffle(values)
|
| 269 |
+
k = fixed_k if fixed_k is not None else rng.randint(3, 6)
|
| 270 |
+
opts, kinds = [gold], []
|
| 271 |
+
active = list(generators)
|
| 272 |
+
while len(opts) < k and active:
|
| 273 |
+
kind = rng.choice(active)
|
| 274 |
+
values = generators[kind]
|
| 275 |
+
while values and (not values[-1].strip() or len(values[-1]) > 200 or any(equivalent(values[-1], x) for x in opts)):
|
| 276 |
+
values.pop()
|
| 277 |
+
if not values:
|
| 278 |
+
active.remove(kind)
|
| 279 |
+
continue
|
| 280 |
+
opts.append(values.pop().strip())
|
| 281 |
+
kinds.append(kind)
|
| 282 |
+
if len(opts) != k:
|
| 283 |
+
c.stats['insufficient_shift_distractors'] += 1
|
| 284 |
+
continue
|
| 285 |
+
order = list(range(k)); rng.shuffle(order)
|
| 286 |
+
result.append(dict(it, options=[opts[i] for i in order], gold=LETTERS[order.index(0)]))
|
| 287 |
+
provenance[it['id']] = dict(generators=kinds, option_count=k, row=row,
|
| 288 |
+
distractors=[dict(text=v, generator=g) for v, g in zip(opts[1:], kinds)])
|
| 289 |
+
return result, provenance
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def m2w_shift(im, row, g, rng, k, path):
|
| 293 |
+
"""Centered viewport, spatially close negatives, cyan/orange thick numbered boxes."""
|
| 294 |
+
W, H = im.size
|
| 295 |
+
vh = min(H, VH)
|
| 296 |
+
top = int(max(0, min(H-vh, (g[1]+g[3])/2-vh/2)))
|
| 297 |
+
if not (0 <= g[0] < g[2] <= W and top <= g[1] < g[3] <= top+vh):
|
| 298 |
+
return None
|
| 299 |
+
candidates = list(row['_negboxes']); rng.shuffle(candidates)
|
| 300 |
+
candidates.sort(key=lambda b: abs((b[0]+b[2]-g[0]-g[2])/2) + abs((b[1]+b[3]-g[1]-g[3])/2))
|
| 301 |
+
negs = []
|
| 302 |
+
for b in candidates:
|
| 303 |
+
if not (0 <= b[0] < b[2] <= W and top <= b[1] < b[3] <= top+vh):
|
| 304 |
+
continue
|
| 305 |
+
if b[2]-b[0] < 8 or b[3]-b[1] < 8 or b[2]-b[0] > .6*W or b[3]-b[1] > .4*vh:
|
| 306 |
+
continue
|
| 307 |
+
# Exclude every annotated positive, not just the first.
|
| 308 |
+
if any(overlaps(b, p) for p in row['_posboxes']) or any(overlaps(b, p) for p in negs):
|
| 309 |
+
continue
|
| 310 |
+
negs.append(b)
|
| 311 |
+
if len(negs) < k-1:
|
| 312 |
+
return None
|
| 313 |
+
# Choose from the nearest 2*k distinct boxes instead of m2w_variant's uniform pool.
|
| 314 |
+
chosen = rng.sample(negs[:2*k], k-1)
|
| 315 |
+
slot = rng.randrange(k)
|
| 316 |
+
boxes = chosen[:slot] + [g] + chosen[slot:]
|
| 317 |
+
crop = im.crop((0, top, W, top+vh))
|
| 318 |
+
draw = ImageDraw.Draw(crop)
|
| 319 |
+
fs = max(16, min(crop.size)//38)
|
| 320 |
+
font = M.font(fs)
|
| 321 |
+
width = max(4, min(crop.size)//180)
|
| 322 |
+
for i, b in enumerate(boxes):
|
| 323 |
+
b = [b[0], b[1]-top, b[2], b[3]-top]
|
| 324 |
+
color = rng.choice(['#007c91', '#9c4f00', '#6844aa'])
|
| 325 |
+
draw.rectangle(b, outline=color, width=width)
|
| 326 |
+
label = f'[{i+1}]'
|
| 327 |
+
tw = draw.textbbox((0, 0), label, font=font)[2] + 8
|
| 328 |
+
x, y = min(b[0], W-tw), max(0, b[1]-fs-7)
|
| 329 |
+
draw.rectangle((x, y, x+tw, y+fs+6), fill=color)
|
| 330 |
+
draw.text((x+3, y), label, fill='white', font=font)
|
| 331 |
+
crop.save(path, quality=92)
|
| 332 |
+
return [f'box [{i+1}]' for i in range(k)], LETTERS[slot], {'boxes': boxes, 'top': top, 'gold_slot': slot, 'line_width': width}
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def collect_m2w(c):
|
| 336 |
+
shards = sorted((D.RAW / 'mind2web/data').glob('train-*.parquet'))
|
| 337 |
+
used_raw = set()
|
| 338 |
+
# Raw screenshot identity catches aliases across both training variants.
|
| 339 |
+
for f in shards:
|
| 340 |
+
for r in pq.read_table(f, columns=['action_uid', 'screenshot']).to_pylist():
|
| 341 |
+
if r['action_uid'] in c.used:
|
| 342 |
+
used_raw.add(digest(D.img_bytes(r['screenshot'])))
|
| 343 |
+
c.stats['raw_training_screenshots'] = len(used_raw)
|
| 344 |
+
B, provenance = [], {}
|
| 345 |
+
selected_screenshots = set()
|
| 346 |
+
for f in shards:
|
| 347 |
+
rows = pq.read_table(f, columns=M.M2W_COLS + ['website']).to_pylist()
|
| 348 |
+
random.Random(f'{SEED}:{f.name}').shuffle(rows)
|
| 349 |
+
for row in rows:
|
| 350 |
+
uid = row['action_uid']
|
| 351 |
+
c.stats['upstream_rows_scanned'] += 1
|
| 352 |
+
if uid in c.used:
|
| 353 |
+
c.stats['excluded_training_rows'] += 1
|
| 354 |
+
continue
|
| 355 |
+
screenshot_hash = digest(D.img_bytes(row['screenshot']))
|
| 356 |
+
if screenshot_hash in used_raw:
|
| 357 |
+
c.stats['excluded_training_image_aliases'] += 1
|
| 358 |
+
continue
|
| 359 |
+
if screenshot_hash in selected_screenshots:
|
| 360 |
+
c.stats['excluded_duplicate_dev_images'] += 1
|
| 361 |
+
continue
|
| 362 |
+
if len(c.items) >= c.target:
|
| 363 |
+
continue
|
| 364 |
+
if not row['pos_candidates']:
|
| 365 |
+
c.stats['missing_positive_annotation'] += 1
|
| 366 |
+
continue
|
| 367 |
+
g = m2w_box(row['pos_candidates'][0])
|
| 368 |
+
if not g or g[2]-g[0] < 4 or g[3]-g[1] < 4:
|
| 369 |
+
c.stats['invalid_gold_box'] += 1
|
| 370 |
+
continue
|
| 371 |
+
row['_negboxes'] = [b for b in map(m2w_box, row['neg_candidates']) if b]
|
| 372 |
+
row['_posboxes'] = [b for b in map(m2w_box, row['pos_candidates']) if b]
|
| 373 |
+
# The original A generator excludes the first gold only. Filter additional
|
| 374 |
+
# positive aliases here so both variants have exactly one valid candidate.
|
| 375 |
+
row['_negboxes'] = [b for b in row['_negboxes'] if not any(overlaps(b, p) for p in row['_posboxes'][1:])]
|
| 376 |
+
im = M.pil(row['screenshot']).convert('RGB')
|
| 377 |
+
if c.ev is not None and D.near_eval(D.dhash_im(im), c.ev):
|
| 378 |
+
c.stats['excluded_eval_near_images'] += 1
|
| 379 |
+
continue
|
| 380 |
+
pa, pb = c.dir / f'{uid}-A.jpg', c.dir / f'{uid}-B.jpg'
|
| 381 |
+
# Same shuffled four-slot blocks as build_mix.m2w_plan; apply the
|
| 382 |
+
# policy to this holdout's attempted actions, not training ranks.
|
| 383 |
+
attempt = c.stats['A_variants_attempted']
|
| 384 |
+
slots = list(range(4))
|
| 385 |
+
random.Random(f'slots:{attempt // 4}').shuffle(slots)
|
| 386 |
+
c.stats['A_variants_attempted'] += 1
|
| 387 |
+
a = M.m2w_variant(im, row, g, random.Random(f'train:mind2web:{uid}'), 4,
|
| 388 |
+
slots[attempt % 4], pa)
|
| 389 |
+
if not a:
|
| 390 |
+
c.stats['invalid_A_geometry'] += 1
|
| 391 |
+
continue
|
| 392 |
+
k = random.Random(f'{SEED}:k:{uid}').randint(3, 8)
|
| 393 |
+
b = m2w_shift(im, row, g, random.Random(f'{SEED}:B:{uid}'), k, pb)
|
| 394 |
+
if not b:
|
| 395 |
+
pa.unlink(missing_ok=True)
|
| 396 |
+
c.stats['invalid_B_geometry'] += 1
|
| 397 |
+
continue
|
| 398 |
+
if c.ev is not None and any(D.near_eval(D.dhash_path(p), c.ev) for p in [pa, pb]):
|
| 399 |
+
pa.unlink(); pb.unlink()
|
| 400 |
+
c.stats['excluded_eval_near_renderings'] += 1
|
| 401 |
+
continue
|
| 402 |
+
q, opts, gold, _ = a
|
| 403 |
+
it = dict(id=f'mind2web:{uid}', source='mind2web', images=[str(pa)], question=q,
|
| 404 |
+
options=opts, gold=gold, vision_only=False, subtask=row['domain'],
|
| 405 |
+
website=row['website'], annotation_id=row['annotation_id'], action_uid=uid)
|
| 406 |
+
c.items.append(it)
|
| 407 |
+
B.append(dict(it, images=[str(pb)], options=b[0], gold=b[1]))
|
| 408 |
+
c.kept_rows.add(uid)
|
| 409 |
+
selected_screenshots.add(screenshot_hash)
|
| 410 |
+
provenance[it['id']] = dict(generator='nearest_spatial_negatives_numbered_marks', option_count=k,
|
| 411 |
+
gold_box=g, B=b[2])
|
| 412 |
+
print(f'mind2web: {len(c.items)} pairs after {f.name}', flush=True)
|
| 413 |
+
return B, provenance
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
def main():
|
| 417 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 418 |
+
p.add_argument('--rows', type=int, default=400)
|
| 419 |
+
p.add_argument('--task02', action='store_true', help='Extend DEV without rebuilding Task 01 items')
|
| 420 |
+
p.add_argument('--sources', nargs='+', choices=SOURCES, default=SOURCES)
|
| 421 |
+
args = p.parse_args()
|
| 422 |
+
if args.rows < 1:
|
| 423 |
+
p.error('--rows must be positive')
|
| 424 |
+
if args.task02:
|
| 425 |
+
expand_task02(args.rows)
|
| 426 |
+
return
|
| 427 |
+
# Reuse eval_hashes without permitting its cache miss to write into qev-data.
|
| 428 |
+
original_cache = D.EVAL_CACHE
|
| 429 |
+
if not original_cache.exists():
|
| 430 |
+
D.EVAL_CACHE = ROOT / 'dev/eval_dhash.npy'
|
| 431 |
+
D.EVAL_CACHE.parent.mkdir(parents=True, exist_ok=True)
|
| 432 |
+
if original_cache.exists() or any(D.EVAL_IMG.glob('*/img/*')):
|
| 433 |
+
ev = D.eval_hashes()
|
| 434 |
+
if not len(ev):
|
| 435 |
+
raise RuntimeError('Evaluation hash cache is empty')
|
| 436 |
+
eval_status = {'enabled': True, 'hashes': len(ev), 'cache': str(D.EVAL_CACHE), 'hamming_max': 4}
|
| 437 |
+
else:
|
| 438 |
+
ev = None
|
| 439 |
+
eval_status = {'enabled': False, 'reason': 'Neither evaluation cache nor evaluation images reachable'}
|
| 440 |
+
manifest_path = ROOT / 'dev/manifest.json'
|
| 441 |
+
manifest = json.loads(manifest_path.read_text()) if manifest_path.exists() else {'sources': {}}
|
| 442 |
+
manifest.update(seed=SEED, target_upstream_rows=args.rows, eval_dhash=eval_status,
|
| 443 |
+
original_builder_seed=D.SEED,
|
| 444 |
+
A_policy='Original builder functions; uncapped candidate enumeration; original Src.add/Sink.add; ChartQA isolated RNG seed 20261017',
|
| 445 |
+
B_policy='Uniform requested option count 3..6; per-distractor random available generator; Mind2Web requested k 3..8, spatial negatives, numbered marks')
|
| 446 |
+
for source in args.sources:
|
| 447 |
+
for variant in ['A', 'B']:
|
| 448 |
+
(ROOT / 'dev' / variant / source).mkdir(parents=True, exist_ok=True)
|
| 449 |
+
imgdir = ROOT / 'dev/img' / source
|
| 450 |
+
if imgdir.exists():
|
| 451 |
+
shutil.rmtree(imgdir)
|
| 452 |
+
c = Collector(source, args.rows, ev)
|
| 453 |
+
if source in ('docvqa', 'infographic_vqa'):
|
| 454 |
+
total = sum(pq.ParquetFile(f).metadata.num_rows for f in (D.CAUL / source).glob('*.parquet'))
|
| 455 |
+
elif source in ('chartqa', 'mind2web', 'cord_train'):
|
| 456 |
+
raw_source = 'cord' if source == 'cord_train' else source
|
| 457 |
+
total = sum(pq.ParquetFile(f).metadata.num_rows for f in (D.RAW / raw_source / 'data').glob('train-*.parquet'))
|
| 458 |
+
else:
|
| 459 |
+
import zipfile
|
| 460 |
+
with zipfile.ZipFile(D.RAW / 'funsd/dataset.zip') as z:
|
| 461 |
+
total = sum(n.startswith('dataset/training_data/annotations/') and n.endswith('.json') for n in z.namelist())
|
| 462 |
+
c.stats['total_upstream_rows'] = total
|
| 463 |
+
c.stats['unused_row_upper_bound'] = total-c.stats['training_row_keys']
|
| 464 |
+
if source == 'mind2web':
|
| 465 |
+
b, provenance = collect_m2w(c)
|
| 466 |
+
else:
|
| 467 |
+
collect_chart(c) if source == 'chartqa' else collect_docs(c)
|
| 468 |
+
b, provenance = shifted(c)
|
| 469 |
+
ids = {it['id'] for it in b}
|
| 470 |
+
a = [it for it in c.items if it['id'] in ids]
|
| 471 |
+
referenced = {p for it in a+b for p in it['images']}
|
| 472 |
+
for path in c.dir.iterdir():
|
| 473 |
+
if str(path) not in referenced:
|
| 474 |
+
path.unlink()
|
| 475 |
+
for variant, items in [('A', a), ('B', b)]:
|
| 476 |
+
(ROOT / 'dev' / variant / source / 'items.jsonl').write_text(''.join(json.dumps(it, ensure_ascii=False)+'\n' for it in items))
|
| 477 |
+
(ROOT / 'dev' / 'B' / source / 'generators.json').write_text(json.dumps(provenance, indent=2, ensure_ascii=False))
|
| 478 |
+
counts = Counter(g for md in provenance.values() for g in md.get('generators', [md.get('generator')]))
|
| 479 |
+
summary = dict(c.stats, A_items=len(a), B_items=len(b),
|
| 480 |
+
upstream_rows=len({c.row_of[it['id']] for it in a}) if source != 'mind2web' else len(a),
|
| 481 |
+
A_options=dict(Counter(len(it['options']) for it in a)),
|
| 482 |
+
B_options=dict(Counter(len(it['options']) for it in b)),
|
| 483 |
+
B_generator_mix=dict(counts), subtasks=dict(Counter(it['subtask'] for it in a)))
|
| 484 |
+
if source in ('infographic_vqa', 'docvqa', 'cord_train', 'funsd_train'):
|
| 485 |
+
summary['generator_ineligible_rows'] = total-c.stats['candidate_rows']
|
| 486 |
+
if source == 'chartqa':
|
| 487 |
+
summary['exclusion_method'] = 'SHA256 of exact Sink.img JPEG encoding versus every training image (IDs are shuffled positions)'
|
| 488 |
+
summary['shortfall'] = max(0, args.rows-summary['upstream_rows'])
|
| 489 |
+
manifest['sources'][source] = summary
|
| 490 |
+
manifest_path.write_text(json.dumps(manifest, indent=2, ensure_ascii=False)+'\n')
|
| 491 |
+
print(source, json.dumps(summary), flush=True)
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
# ---------------------------------------------------------------- Task 02
|
| 495 |
+
|
| 496 |
+
def write_variant(variant, source, items, provenance=None):
|
| 497 |
+
directory = ROOT / 'dev' / variant / source
|
| 498 |
+
directory.mkdir(parents=True, exist_ok=True)
|
| 499 |
+
(directory / 'items.jsonl').write_text(''.join(json.dumps(it, ensure_ascii=False)+'\n' for it in items))
|
| 500 |
+
if provenance is not None:
|
| 501 |
+
(directory / 'generators.json').write_text(json.dumps(provenance, indent=2, ensure_ascii=False)+'\n')
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def doc_a_eligible(qa):
|
| 505 |
+
"""Image-level eligibility, exactly matching docqa's same-image pool test."""
|
| 506 |
+
for i, (_, gold) in enumerate(qa):
|
| 507 |
+
gn = D.norm(gold)
|
| 508 |
+
pool = {}
|
| 509 |
+
for j, (_, other) in enumerate(qa):
|
| 510 |
+
on = D.norm(other)
|
| 511 |
+
if j == i or not on or D.isnum(other.lower()) != D.isnum(gold.lower()) or on == gn or on in gn or gn in on:
|
| 512 |
+
continue
|
| 513 |
+
pool.setdefault(other.lower(), other)
|
| 514 |
+
if len(pool) >= 3:
|
| 515 |
+
return True
|
| 516 |
+
return False
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
def collect_bonly_docs(source, target, ev):
|
| 520 |
+
c = Collector(source, target, ev)
|
| 521 |
+
qa_by_row, eligible = {}, set()
|
| 522 |
+
for ri, row in enumerate(D.caul_rows(source, cols=('texts',))):
|
| 523 |
+
qa = [(D.strip_q(t['user']), D.strip_a(t['assistant'])) for t in row['texts']]
|
| 524 |
+
qa = [(q, a) for q, a in qa if q and a and len(a) <= 80]
|
| 525 |
+
key = str(ri)
|
| 526 |
+
qa_by_row[key] = qa
|
| 527 |
+
c.answers.extend((key, a) for _, a in qa)
|
| 528 |
+
c.context[key] = [a for _, a in qa]
|
| 529 |
+
if doc_a_eligible(qa):
|
| 530 |
+
eligible.add(key)
|
| 531 |
+
c.stats['total_upstream_rows'] = len(qa_by_row)
|
| 532 |
+
c.stats['original_A_eligible_rows'] = len(eligible)
|
| 533 |
+
rows = list(qa_by_row)
|
| 534 |
+
random.Random(f'{SEED}:Bonly:{source}').shuffle(rows)
|
| 535 |
+
wanted = {}
|
| 536 |
+
for key in rows:
|
| 537 |
+
if key in c.used:
|
| 538 |
+
c.stats['excluded_training_rows_preselection'] += 1
|
| 539 |
+
elif key in eligible:
|
| 540 |
+
c.stats['excluded_A_eligible_rows'] += 1
|
| 541 |
+
elif not qa_by_row[key]:
|
| 542 |
+
c.stats['no_valid_question'] += 1
|
| 543 |
+
else:
|
| 544 |
+
indices = list(range(len(qa_by_row[key])))
|
| 545 |
+
random.Random(f'{SEED}:question:{source}:{key}').shuffle(indices)
|
| 546 |
+
wanted[int(key)] = indices[0]
|
| 547 |
+
# Compute exact transformed identities for pool rows too, to exclude aliases
|
| 548 |
+
# of the current image from the "other image gold" pool.
|
| 549 |
+
image_rows = {}
|
| 550 |
+
for ri, row in enumerate(D.caul_rows(source, cols=('images',))):
|
| 551 |
+
key = str(ri)
|
| 552 |
+
data = D.img_bytes(row['images'][0])
|
| 553 |
+
if ri in wanted:
|
| 554 |
+
image_rows[ri] = data
|
| 555 |
+
c.fingerprints[key] = digest(jpeg(Image.open(io.BytesIO(data))))
|
| 556 |
+
if (ri+1) % 1000 == 0:
|
| 557 |
+
print(f'{source}: fingerprinted {ri+1} upstream images', flush=True)
|
| 558 |
+
for key in rows:
|
| 559 |
+
ri = int(key)
|
| 560 |
+
if ri not in wanted or len(c.items) >= target:
|
| 561 |
+
continue
|
| 562 |
+
p = c.img(image_rows[ri], key)
|
| 563 |
+
if p is None:
|
| 564 |
+
continue
|
| 565 |
+
qi = wanted[ri]
|
| 566 |
+
q, gold = qa_by_row[key][qi]
|
| 567 |
+
it = dict(id=f'{source}:{key}:{qi}', source=source, images=[p], question=q,
|
| 568 |
+
options=[gold], gold='A', vision_only=False,
|
| 569 |
+
subtask='numeric' if D.isnum(gold) else 'text')
|
| 570 |
+
c.items.append(it); c.row_of[it['id']] = key
|
| 571 |
+
b, provenance = shifted(c, kinds_allowed=('other_image_gold', 'perturb_gold'))
|
| 572 |
+
keep = {p for it in b for p in it['images']}
|
| 573 |
+
for p in c.dir.glob('*.jpg'):
|
| 574 |
+
if str(p) not in keep:
|
| 575 |
+
p.unlink()
|
| 576 |
+
write_variant('B', source, b, provenance)
|
| 577 |
+
return b, provenance, dict(c.stats, upstream_rows=len(b), A_items=0, B_items=len(b),
|
| 578 |
+
A_variant=False, A_variant_reason='Original A rule rejects these images',
|
| 579 |
+
B_options=dict(Counter(len(it['options']) for it in b)),
|
| 580 |
+
B_generator_mix=dict(Counter(g for md in provenance.values() for g in md['generators'])),
|
| 581 |
+
subtasks=dict(Counter(it['subtask'] for it in b)),
|
| 582 |
+
shortfall=max(0, target-len(b)))
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
def render_m2w(im, geometry, path, numbered):
|
| 586 |
+
"""Render one geometry with either original kit marks or shifted marks."""
|
| 587 |
+
from decision_index.vision.convert import draw_marks
|
| 588 |
+
top, boxes = geometry['top'], geometry['boxes']
|
| 589 |
+
crop = im.crop((0, top, im.width, top+min(im.height, VH)))
|
| 590 |
+
px = [[b[0], b[1]-top, b[2], b[3]-top] for b in boxes]
|
| 591 |
+
if not numbered:
|
| 592 |
+
draw_marks(crop, px, None).save(path, quality=92)
|
| 593 |
+
return
|
| 594 |
+
draw = ImageDraw.Draw(crop)
|
| 595 |
+
fs = max(16, min(crop.size)//38)
|
| 596 |
+
font = M.font(fs)
|
| 597 |
+
width = max(4, min(crop.size)//180)
|
| 598 |
+
colors = ['#007c91', '#9c4f00', '#6844aa']
|
| 599 |
+
for i, b in enumerate(px):
|
| 600 |
+
color = colors[i % len(colors)]
|
| 601 |
+
draw.rectangle(b, outline=color, width=width)
|
| 602 |
+
label = f'[{i+1}]'
|
| 603 |
+
tw = draw.textbbox((0, 0), label, font=font)[2] + 8
|
| 604 |
+
x, y = min(b[0], crop.width-tw), max(0, b[1]-fs-7)
|
| 605 |
+
draw.rectangle((x, y, x+tw, y+fs+6), fill=color)
|
| 606 |
+
draw.text((x+3, y), label, fill='white', font=font)
|
| 607 |
+
crop.save(path, quality=92)
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
def shifted_geometry(im, row, g, a, k, rng):
|
| 611 |
+
"""Different spatial negatives; fixed A viewport for a controlled ablation."""
|
| 612 |
+
top = a['top']; vh = min(im.height, VH)
|
| 613 |
+
candidates = list(row['_negboxes']); rng.shuffle(candidates)
|
| 614 |
+
candidates.sort(key=lambda b: abs(b[0]+b[2]-g[0]-g[2])+abs(b[1]+b[3]-g[1]-g[3]))
|
| 615 |
+
negs = []
|
| 616 |
+
for b in candidates:
|
| 617 |
+
if not (0 <= b[0] < b[2] <= im.width and top <= b[1] < b[3] <= top+vh):
|
| 618 |
+
continue
|
| 619 |
+
if b[2]-b[0] < 8 or b[3]-b[1] < 8 or b[2]-b[0] > .6*im.width or b[3]-b[1] > .4*vh:
|
| 620 |
+
continue
|
| 621 |
+
if any(overlaps(b, p) for p in row['_posboxes']) or any(overlaps(b, p) for p in negs):
|
| 622 |
+
continue
|
| 623 |
+
negs.append(b)
|
| 624 |
+
if len(negs) < k-1:
|
| 625 |
+
return None
|
| 626 |
+
original = {tuple(b) for b in a['boxes'] if b != g}
|
| 627 |
+
chosen = None
|
| 628 |
+
for _ in range(20):
|
| 629 |
+
trial = rng.sample(negs[:max(2*k, k-1)], k-1)
|
| 630 |
+
if set(map(tuple, trial)) != original:
|
| 631 |
+
chosen = trial; break
|
| 632 |
+
if chosen is None:
|
| 633 |
+
return None
|
| 634 |
+
slot = rng.randrange(k)
|
| 635 |
+
return dict(top=top, boxes=chosen[:slot]+[g]+chosen[slot:], gold_slot=slot)
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
def collect_m2w_all(target, ev):
|
| 639 |
+
from decision_index.vision import convert
|
| 640 |
+
c = Collector('mind2web', target, ev)
|
| 641 |
+
c.dir = ROOT / 'dev/img/mind2web_all'; c.dir.mkdir(parents=True, exist_ok=True)
|
| 642 |
+
shards = sorted((D.RAW / 'mind2web/data').glob('train-*.parquet'))
|
| 643 |
+
used_raw = set(); census = defaultdict(Counter)
|
| 644 |
+
for f in shards:
|
| 645 |
+
for row in pq.read_table(f, columns=['action_uid', 'screenshot', 'domain', 'pos_candidates']).to_pylist():
|
| 646 |
+
domain = census[row['domain']]; domain['raw_actions'] += 1
|
| 647 |
+
if row['action_uid'] in c.used:
|
| 648 |
+
used_raw.add(digest(D.img_bytes(row['screenshot']))); domain['training_actions'] += 1
|
| 649 |
+
else:
|
| 650 |
+
domain['unused_actions'] += 1
|
| 651 |
+
domain['unused_with_positive'] += int(bool(row['pos_candidates']))
|
| 652 |
+
variants = {v: [] for v in ['A', 'B', 'Bstyle', 'Bk']}
|
| 653 |
+
provenance = {}; selected = set()
|
| 654 |
+
for f in shards:
|
| 655 |
+
rows = pq.read_table(f, columns=M.M2W_COLS+['website']).to_pylist()
|
| 656 |
+
random.Random(f'{SEED}:{f.name}').shuffle(rows)
|
| 657 |
+
for row in rows:
|
| 658 |
+
uid = row['action_uid']; domain = census[row['domain']]
|
| 659 |
+
c.stats['upstream_rows_scanned'] += 1
|
| 660 |
+
if uid in c.used:
|
| 661 |
+
c.stats['excluded_training_rows'] += 1; continue
|
| 662 |
+
raw_hash = digest(D.img_bytes(row['screenshot']))
|
| 663 |
+
reason = None
|
| 664 |
+
if raw_hash in used_raw: reason = 'training_screenshot_alias'
|
| 665 |
+
elif raw_hash in selected: reason = 'duplicate_screenshot'
|
| 666 |
+
elif not row['pos_candidates']: reason = 'missing_positive'
|
| 667 |
+
if reason:
|
| 668 |
+
domain[reason] += 1; c.stats[reason] += 1; continue
|
| 669 |
+
if len(variants['A']) >= target:
|
| 670 |
+
continue
|
| 671 |
+
g = m2w_box(row['pos_candidates'][0])
|
| 672 |
+
if not g or g[2]-g[0] < 4 or g[3]-g[1] < 4:
|
| 673 |
+
domain['invalid_gold'] += 1; continue
|
| 674 |
+
row['_posboxes'] = [b for b in map(m2w_box, row['pos_candidates']) if b]
|
| 675 |
+
row['_negboxes'] = [b for b in map(m2w_box, row['neg_candidates']) if b
|
| 676 |
+
and b[0] >= 0 and b[1] >= 0
|
| 677 |
+
and not any(overlaps(b, p) for p in row['_posboxes'][1:])]
|
| 678 |
+
im = M.pil(row['screenshot']).convert('RGB')
|
| 679 |
+
if ev is not None and D.near_eval(D.dhash_im(im), ev):
|
| 680 |
+
domain['eval_near_raw'] += 1; continue
|
| 681 |
+
paths = {v: c.dir/f'{uid}-{v}.jpg' for v in variants}
|
| 682 |
+
attempt = c.stats['A_variants_attempted']
|
| 683 |
+
slots = list(range(4)); random.Random(f'slots:{attempt//4}').shuffle(slots)
|
| 684 |
+
c.stats['A_variants_attempted'] += 1
|
| 685 |
+
recorded = []
|
| 686 |
+
original_draw = convert.draw_marks
|
| 687 |
+
def capture(crop, boxes, font):
|
| 688 |
+
recorded.extend([list(b) for b in boxes])
|
| 689 |
+
return original_draw(crop, boxes, font)
|
| 690 |
+
convert.draw_marks = capture
|
| 691 |
+
try:
|
| 692 |
+
a = M.m2w_variant(im, row, g, random.Random(f'train:mind2web:{uid}'), 4,
|
| 693 |
+
slots[attempt % 4], paths['A'])
|
| 694 |
+
finally:
|
| 695 |
+
convert.draw_marks = original_draw
|
| 696 |
+
if not a:
|
| 697 |
+
domain['invalid_A_geometry'] += 1; continue
|
| 698 |
+
q, opts, gold, key = a
|
| 699 |
+
top = key[0]
|
| 700 |
+
geom_a = dict(top=top, boxes=[[b[0], b[1]+top, b[2], b[3]+top] for b in recorded],
|
| 701 |
+
gold_slot=LETTERS.index(gold))
|
| 702 |
+
if not (0 <= g[0] < g[2] <= im.width):
|
| 703 |
+
domain['invalid_gold'] += 1; paths['A'].unlink(); continue
|
| 704 |
+
k = random.Random(f'{SEED}:k:{uid}').randint(3, 8)
|
| 705 |
+
geom_b = shifted_geometry(im, row, g, geom_a, k, random.Random(f'{SEED}:B:{uid}'))
|
| 706 |
+
if geom_b is None:
|
| 707 |
+
domain['invalid_shift_geometry'] += 1; paths['A'].unlink(); continue
|
| 708 |
+
render_m2w(im, geom_a, paths['Bstyle'], True)
|
| 709 |
+
render_m2w(im, geom_b, paths['Bk'], False)
|
| 710 |
+
render_m2w(im, geom_b, paths['B'], True)
|
| 711 |
+
if ev is not None and any(D.near_eval(D.dhash_path(p), ev) for p in paths.values()):
|
| 712 |
+
for p in paths.values(): p.unlink()
|
| 713 |
+
domain['eval_near_rendering'] += 1; continue
|
| 714 |
+
it = dict(id=f'mind2web_all:{uid}', source='mind2web_all', question=q, vision_only=False,
|
| 715 |
+
subtask=row['domain'], website=row['website'], annotation_id=row['annotation_id'], action_uid=uid)
|
| 716 |
+
for v in variants:
|
| 717 |
+
geom = geom_a if v in ['A', 'Bstyle'] else geom_b
|
| 718 |
+
n = len(geom['boxes']); numbered = v in ['B', 'Bstyle']
|
| 719 |
+
options = [f'box [{i+1}]' if numbered else f'box {LETTERS[i]}' for i in range(n)]
|
| 720 |
+
variants[v].append(dict(it, images=[str(paths[v])], options=options, gold=LETTERS[geom['gold_slot']]))
|
| 721 |
+
provenance[it['id']] = dict(gold_box=g, positives=row['_posboxes'], A=geom_a, Bstyle=geom_a,
|
| 722 |
+
B=geom_b, Bk=geom_b, raw_sha256=raw_hash, screenshot_size=list(im.size))
|
| 723 |
+
selected.add(raw_hash); domain['kept'] += 1
|
| 724 |
+
print('mind2web_all',len(variants['A']),'after',f.name,flush=True)
|
| 725 |
+
referenced = {p for items in variants.values() for it in items for p in it['images']}
|
| 726 |
+
for path in c.dir.glob('*.jpg'):
|
| 727 |
+
if str(path) not in referenced: path.unlink()
|
| 728 |
+
for v, items in variants.items(): write_variant(v, 'mind2web_all', items, provenance)
|
| 729 |
+
return dict(c.stats, upstream_rows=len(variants['A']), counts={v:len(a) for v,a in variants.items()},
|
| 730 |
+
domains={d:dict(counts) for d,counts in census.items()},
|
| 731 |
+
options={v:dict(Counter(len(it['options']) for it in a)) for v,a in variants.items()},
|
| 732 |
+
shortfall=max(0,target-len(variants['A'])),
|
| 733 |
+
policy='A calls original m2w_variant; A/Bstyle share geometry; B/Bk share shifted geometry; all share viewport; uniform requested k=3..8')
|
| 734 |
+
|
| 735 |
+
|
| 736 |
+
def chart_count_control():
|
| 737 |
+
a = read_items(ROOT / 'dev/A/chartqa/items.jsonl')
|
| 738 |
+
b = read_items(ROOT / 'dev/B/chartqa/items.jsonl')
|
| 739 |
+
provenance = json.loads((ROOT / 'dev/B/chartqa/generators.json').read_text())
|
| 740 |
+
c = type('ChartPool', (), {})()
|
| 741 |
+
c.answers = [(it['id'], it['options'][LETTERS.index(it['gold'])]) for it in a]
|
| 742 |
+
c.context = {}; c.stats = Counter(); c.fingerprints = {}
|
| 743 |
+
c.row_of = {it['id']:it['id'] for it in a}
|
| 744 |
+
out, metadata = [], {}
|
| 745 |
+
for it in b:
|
| 746 |
+
gold = it['options'][LETTERS.index(it['gold'])]
|
| 747 |
+
distractors = list(provenance[it['id']]['distractors'])
|
| 748 |
+
rng = random.Random(f'{SEED}:Bn:{it["id"]}')
|
| 749 |
+
if len(distractors) < 3:
|
| 750 |
+
c.items = [it]
|
| 751 |
+
extra, md = shifted(c, fixed_k=4)
|
| 752 |
+
available = md[it['id']]['distractors']
|
| 753 |
+
for d in available:
|
| 754 |
+
if not any(equivalent(d['text'], v['text']) for v in distractors) and not equivalent(d['text'], gold):
|
| 755 |
+
distractors.append(d)
|
| 756 |
+
if len(distractors) == 3: break
|
| 757 |
+
else:
|
| 758 |
+
rng.shuffle(distractors); distractors = distractors[:3]
|
| 759 |
+
assert len(distractors) == 3
|
| 760 |
+
opts = [gold]+[d['text'] for d in distractors]; rng.shuffle(opts)
|
| 761 |
+
out.append(dict(it, options=opts, gold=LETTERS[opts.index(gold)]))
|
| 762 |
+
metadata[it['id']] = dict(distractors=distractors, option_count=4,
|
| 763 |
+
original_B_option_count=len(it['options']))
|
| 764 |
+
write_variant('Bn','chartqa',out,metadata)
|
| 765 |
+
return dict(items=len(out), upstream_rows=len(out), option_count=4,
|
| 766 |
+
policy='Retain/subsample original B distractors; top up 3-option B items with same B generators')
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
def collect_value_bonly(source, target, ev):
|
| 770 |
+
"""A relaxed candidate pool, with original annotation semantics and question templates."""
|
| 771 |
+
import zipfile
|
| 772 |
+
base_source = 'cord_train' if source == 'cord_value' else 'funsd_train'
|
| 773 |
+
c = Collector(base_source, target, ev)
|
| 774 |
+
c.dir = ROOT/'dev/img'/source; c.dir.mkdir(parents=True, exist_ok=True)
|
| 775 |
+
records = []
|
| 776 |
+
if source == 'cord_value':
|
| 777 |
+
for fi, f in enumerate(sorted((D.RAW/'cord/data').glob('train-*.parquet'))):
|
| 778 |
+
for i, row in enumerate(pq.read_table(f, columns=['image','ground_truth']).to_pylist()):
|
| 779 |
+
key = f'train-{fi}-{i}'
|
| 780 |
+
fields, amounts, _ = D.cord_fields(json.loads(row['ground_truth'])['gt_parse'])
|
| 781 |
+
c.context[key] = [D.fmt_dec(a) if a != int(a) else D.fmt_int(a) for a,_ in amounts]
|
| 782 |
+
# One unambiguous total per receipt, exactly the builder's parser/template.
|
| 783 |
+
gold = D.parse_amount(fields.get('total_price'))
|
| 784 |
+
if gold is None:
|
| 785 |
+
c.stats['no_clean_total'] += int(key not in c.used); continue
|
| 786 |
+
answer = D.fmt_dec(gold) if gold != int(gold) else D.fmt_int(gold)
|
| 787 |
+
c.answers.append((key,answer))
|
| 788 |
+
records.append((key, 'total_price', D.CORD_VALUE_Q['total_price'], answer, D.img_bytes(row['image'])))
|
| 789 |
+
else:
|
| 790 |
+
with zipfile.ZipFile(D.RAW/'funsd/dataset.zip') as z:
|
| 791 |
+
for n in sorted(z.namelist()):
|
| 792 |
+
if not n.startswith('dataset/training_data/annotations/') or not n.endswith('.json'): continue
|
| 793 |
+
key = Path(n).stem; ents = json.loads(z.read(n))['form']; byid={e['id']:e for e in ents}
|
| 794 |
+
counts = Counter(e['text'].strip().lower() for e in ents if e['label']=='question')
|
| 795 |
+
c.context[key] = [e['text'].strip() for e in ents if e['label']=='answer']
|
| 796 |
+
candidates=[]
|
| 797 |
+
for e in ents:
|
| 798 |
+
qt=e['text'].strip()
|
| 799 |
+
if e['label']!='question' or counts[qt.lower()]!=1 or not re.search(r'[A-Za-z]{2}',qt) or len(qt)>50: continue
|
| 800 |
+
linked={b for a,b in e['linking'] if a==e['id'] and b in byid and byid[b]['label']=='answer' and byid[b]['text'].strip()}
|
| 801 |
+
if len(linked)!=1: continue
|
| 802 |
+
gold=byid[next(iter(linked))]['text'].strip()
|
| 803 |
+
if not 1<=len(gold)<=60: continue
|
| 804 |
+
name=qt.strip(' :"\'').strip()
|
| 805 |
+
c.answers.append((key,gold))
|
| 806 |
+
candidates.append((key,str(e['id']),f'On this form, what is filled in for the field "{name}"?',gold))
|
| 807 |
+
random.Random(f'{SEED}:value:{key}').shuffle(candidates)
|
| 808 |
+
if candidates:
|
| 809 |
+
image = z.read(f'dataset/training_data/images/{key}.png')
|
| 810 |
+
records.extend((*candidate, image) for candidate in candidates)
|
| 811 |
+
elif key not in c.used: c.stats['no_clean_single_link']+=1
|
| 812 |
+
random.Random(f'{SEED}:{source}').shuffle(records)
|
| 813 |
+
for key, sid, q, gold, data in records:
|
| 814 |
+
if len(c.items)>=target: break
|
| 815 |
+
p=c.img(data,key)
|
| 816 |
+
if p is None: continue
|
| 817 |
+
it=dict(id=f'{source}:{key}:{sid}', source=source, images=[p], question=q,options=[gold],gold='A',vision_only=False,subtask='field_value')
|
| 818 |
+
c.items.append(it);c.row_of[it['id']]=key
|
| 819 |
+
b, provenance=shifted(c)
|
| 820 |
+
keep={p for it in b for p in it['images']}
|
| 821 |
+
for p in c.dir.glob('*.jpg'):
|
| 822 |
+
if str(p) not in keep:p.unlink()
|
| 823 |
+
write_variant('B',source,b,provenance)
|
| 824 |
+
return dict(c.stats, upstream_rows=len({c.row_of[it['id']] for it in b}), A_variant=False, B_items=len(b),
|
| 825 |
+
B_options=dict(Counter(len(it['options']) for it in b)),
|
| 826 |
+
B_generator_mix=dict(Counter(g for md in provenance.values() for g in md['generators'])),
|
| 827 |
+
policy='B only; original total parser or unique question/single answer link; no same-image distractor minimum')
|
| 828 |
+
|
| 829 |
+
|
| 830 |
+
def expand_task02(target):
|
| 831 |
+
if not D.EVAL_CACHE.exists():
|
| 832 |
+
D.EVAL_CACHE = ROOT/'dev/eval_dhash.npy'
|
| 833 |
+
ev = D.eval_hashes()
|
| 834 |
+
assert len(ev)
|
| 835 |
+
manifest_path=ROOT/'dev/manifest.json'
|
| 836 |
+
manifest=json.loads(manifest_path.read_text())
|
| 837 |
+
manifest.setdefault('task01_sources',json.loads(json.dumps(manifest['sources'])))
|
| 838 |
+
expansion=dict(seed=SEED,target_rows=target,eval_dhash=dict(enabled=True,hashes=len(ev),hamming_max=4),sources={})
|
| 839 |
+
kit_path=ROOT/'kit-mind2web-02.json'
|
| 840 |
+
if kit_path.exists(): expansion['kit_mind2web']=json.loads(kit_path.read_text())
|
| 841 |
+
for source in ['infographic_vqa','docvqa']:
|
| 842 |
+
_,_,summary=collect_bonly_docs(source,target,ev)
|
| 843 |
+
manifest['sources'][source]=summary; expansion['sources'][source]=summary
|
| 844 |
+
print(source,json.dumps(summary),flush=True)
|
| 845 |
+
expansion['sources']['mind2web_all']=collect_m2w_all(target,ev)
|
| 846 |
+
expansion['sources']['chartqa_Bn']=chart_count_control()
|
| 847 |
+
for source in ['cord_value','funsd_value']:
|
| 848 |
+
expansion['sources'][source]=collect_value_bonly(source,target,ev)
|
| 849 |
+
print(source,json.dumps(expansion['sources'][source]),flush=True)
|
| 850 |
+
for source in ['mind2web_all','cord_value','funsd_value']:
|
| 851 |
+
manifest['sources'][source]=expansion['sources'][source]
|
| 852 |
+
manifest['task02']=expansion
|
| 853 |
+
manifest['sources']['chartqa']['Bn_items']=expansion['sources']['chartqa_Bn']['items']
|
| 854 |
+
manifest['sources']['chartqa']['Bn_options']={'4': expansion['sources']['chartqa_Bn']['items']}
|
| 855 |
+
manifest_path.write_text(json.dumps(manifest,indent=2,ensure_ascii=False)+'\n')
|
| 856 |
+
print(json.dumps(expansion,indent=2),flush=True)
|
| 857 |
+
|
| 858 |
+
|
| 859 |
+
if __name__ == '__main__':
|
| 860 |
+
main()
|
| 861 |
+
|
vision-mix-2026-10-v3/scripts/validate_mix_v3.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Independent v3 data audit, including fresh hashes of every referenced image."""
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import sys
|
| 6 |
+
import zlib
|
| 7 |
+
from collections import Counter
|
| 8 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 9 |
+
|
| 10 |
+
sys.dont_write_bytecode=True
|
| 11 |
+
import build_mix_v2 as V
|
| 12 |
+
|
| 13 |
+
R,H,S,D,M=V.ROOT,V.HOME,V.S,V.D,V.M
|
| 14 |
+
OUT=R/'train-v3'
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def main():
|
| 18 |
+
summary=json.loads((OUT/'counts.json').read_text())
|
| 19 |
+
additions=json.loads((OUT/'train-only-additions.json').read_text())
|
| 20 |
+
upstream=json.loads((OUT/'upstream-additions.json').read_text())
|
| 21 |
+
excluded=json.loads((OUT/'excluded-images.json').read_text())
|
| 22 |
+
assert excluded==json.loads((R/'train-v2/excluded-images.json').read_text())
|
| 23 |
+
rawhm={str(r['id']):r for r in S.read_items(D.RAW/'hateful_memes/train.jsonl')}
|
| 24 |
+
raw_aok={}
|
| 25 |
+
wanted={int(uid.split(':')[1]) for uid in additions['aokvqa']}
|
| 26 |
+
offset=0
|
| 27 |
+
for path in sorted((D.RAW/'aokvqa/data').glob('train-*.parquet')):
|
| 28 |
+
pf=S.pq.ParquetFile(path)
|
| 29 |
+
for rg in range(pf.num_row_groups):
|
| 30 |
+
for row in pf.read_row_group(rg, columns=['question','choices','correct_choice_idx']).to_pylist():
|
| 31 |
+
if offset in wanted:
|
| 32 |
+
raw_aok[offset]=row
|
| 33 |
+
offset+=1
|
| 34 |
+
stats={}; allpaths=set(); gold_changes=0; holdouts=0; nchanged=0
|
| 35 |
+
for f in sorted(OUT.glob('*/items.jsonl')):
|
| 36 |
+
source=f.parent.name
|
| 37 |
+
original=S.read_items(H/'qev-data/train'/source/'items.jsonl')
|
| 38 |
+
old={it['id']:it for it in original}
|
| 39 |
+
v2={it['id']:it for it in S.read_items(R/'train-v2'/source/'items.jsonl')}
|
| 40 |
+
rows=S.read_items(f);current={it['id']:it for it in rows}
|
| 41 |
+
assert len(rows)==len(current)==summary['per_source_counts'][source]
|
| 42 |
+
extra=set(additions.get(source,[]))
|
| 43 |
+
assert set(current)==set(v2)|extra and not set(v2)&extra and not set(old)&extra
|
| 44 |
+
assert set(v2)=={uid for uid,it in old.items() if not any(p in excluded for p in it['images'])}
|
| 45 |
+
nd=min(120,len(original)//20);held=[]
|
| 46 |
+
for it in original:
|
| 47 |
+
if len(held)<nd and zlib.crc32(it['id'].encode())%20==0:
|
| 48 |
+
held.append(it['id'])
|
| 49 |
+
held=set(held)
|
| 50 |
+
for uid in set(v2)&held:
|
| 51 |
+
assert current[uid]==v2[uid], f'Selection row changed: {uid}'
|
| 52 |
+
holdouts+=1
|
| 53 |
+
context=V.contexts(source,rows) if source=='cord_train' else {}
|
| 54 |
+
md=json.loads((f.parent/'generators.json').read_text()) if (f.parent/'generators.json').exists() else {}
|
| 55 |
+
presence_hist=Counter(); changes=0
|
| 56 |
+
for it in rows:
|
| 57 |
+
uid=it['id'];allpaths.update(it['images'])
|
| 58 |
+
assert all(p not in excluded for p in it['images'])
|
| 59 |
+
assert it['gold'] in V.L[:len(it['options'])] and 2<=len(it['options'])<=16
|
| 60 |
+
if uid in old:
|
| 61 |
+
gold_changes+=int(V.gold(it)!=V.gold(old[uid]))
|
| 62 |
+
assert it['question']==old[uid]['question'] and V.gold(it)==V.gold(old[uid])
|
| 63 |
+
if uid in extra:
|
| 64 |
+
assert zlib.crc32(uid.encode())%20!=0 and upstream[uid]['split']=='train'
|
| 65 |
+
if source=='hateful_memes':
|
| 66 |
+
raw=rawhm[uid.split(':')[1]]
|
| 67 |
+
assert it['images']==[str(D.RAW/source/raw['img'])]
|
| 68 |
+
assert V.gold(it)==('Yes' if raw['label']==1 else 'No')
|
| 69 |
+
assert it['question']=='Is this meme hateful?' and it['options']==['Yes','No']
|
| 70 |
+
elif source=='aokvqa':
|
| 71 |
+
raw=raw_aok[int(uid.split(':')[1])]
|
| 72 |
+
assert it['question']==raw['question']
|
| 73 |
+
assert sorted(it['options'])==sorted(str(x).strip() for x in raw['choices'])
|
| 74 |
+
assert V.gold(it)==str(raw['choices'][raw['correct_choice_idx']]).strip()
|
| 75 |
+
else:
|
| 76 |
+
raise AssertionError(source)
|
| 77 |
+
assert all(not V.equivalent(a,b) for i,a in enumerate(it['options']) for b in it['options'][i+1:])
|
| 78 |
+
elif it!=v2[uid]:
|
| 79 |
+
assert source=='cord_train' and it['subtask']=='field_present' and uid not in held
|
| 80 |
+
assert it['images']==v2[uid]['images']
|
| 81 |
+
assert {'Yes','No'}<=set(it['options']) and 3<=len(it['options'])<=6
|
| 82 |
+
assert all(not V.equivalent(a,b) for i,a in enumerate(it['options']) for b in it['options'][i+1:])
|
| 83 |
+
decoys=[x for x in it['options'] if x not in {'Yes','No'}]
|
| 84 |
+
assert all(x in context[V.rowkey(it)] for x in decoys)
|
| 85 |
+
assert md[uid]['v3_presence'] and md[uid]['option_count']==len(it['options'])
|
| 86 |
+
assert Counter(d['text'] for d in md[uid]['distractors'])==Counter(x for x in it['options'] if x!=V.gold(it))
|
| 87 |
+
changes+=1;presence_hist[len(it['options'])]+=1
|
| 88 |
+
stats[source]=dict(total=len(rows),train=len(rows)-len(set(v2)&held),holdout=len(set(v2)&held),
|
| 89 |
+
additions=len(extra),changed_from_v2=changes,presence_changed_histogram=dict(presence_hist))
|
| 90 |
+
nchanged+=changes
|
| 91 |
+
assert gold_changes==0 and nchanged==summary['cord_presence_changed']==707
|
| 92 |
+
assert {str(p) for p in (OUT/'img').rglob('*') if p.is_file()} <= allpaths, 'Unreferenced v3 image file'
|
| 93 |
+
assert set(upstream)=={uid for ids in additions.values() for uid in ids}
|
| 94 |
+
assert holdouts==1816
|
| 95 |
+
devpaths={p for f in (R/'dev').rglob('items.jsonl') for it in S.read_items(f) for p in it['images']}
|
| 96 |
+
devpaths.update(str(p) for p in (R/'dev').rglob('*') if p.suffix.lower() in {'.jpg','.jpeg','.png','.webp','.bmp'})
|
| 97 |
+
print(f'Fresh image audit: {len(allpaths)} training paths and {len(devpaths)} DEV paths',flush=True)
|
| 98 |
+
with ThreadPoolExecutor(4) as ex:
|
| 99 |
+
devfp=list(ex.map(V.fingerprint,sorted(devpaths)))
|
| 100 |
+
devsha={fp['sha256'] for fp in devfp};devhash=S.np.array([fp['dhash'] for fp in devfp],dtype=S.np.uint64)
|
| 101 |
+
if not D.EVAL_CACHE.exists():D.EVAL_CACHE=R/'dev/eval_dhash.npy'
|
| 102 |
+
board=D.eval_hashes();cache=json.loads((OUT/'fingerprints.json').read_text())
|
| 103 |
+
manifest=hashlib.sha256();audited={}
|
| 104 |
+
with ThreadPoolExecutor(4) as ex:
|
| 105 |
+
for i,(path,fp) in enumerate(zip(sorted(allpaths),ex.map(V.fingerprint,sorted(allpaths))),1):
|
| 106 |
+
assert fp['dhash'] is not None and fp==cache[path],path
|
| 107 |
+
assert fp['sha256'] not in devsha,path
|
| 108 |
+
assert not D.near_eval(fp['dhash'],devhash),path
|
| 109 |
+
assert not D.near_eval(fp['dhash'],board),path
|
| 110 |
+
manifest.update(f'{path}:{fp["sha256"]}\n'.encode());audited[path]=fp
|
| 111 |
+
if i%2000==0:print('audited',i,flush=True)
|
| 112 |
+
# New rows must add image diversity within their source, too.
|
| 113 |
+
for source,ids in additions.items():
|
| 114 |
+
old=S.read_items(H/'qev-data/train'/source/'items.jsonl')
|
| 115 |
+
prior=[cache[it['images'][0]]['dhash'] for it in old]
|
| 116 |
+
new={it['id']:it for it in S.read_items(OUT/source/'items.jsonl')}
|
| 117 |
+
for uid in ids:
|
| 118 |
+
fp=audited[new[uid]['images'][0]]
|
| 119 |
+
assert not D.near_eval(fp['dhash'],S.np.array(prior,dtype=S.np.uint64)),uid
|
| 120 |
+
prior.append(fp['dhash'])
|
| 121 |
+
result=dict(passed=True,sources=stats,total=sum(s['total'] for s in stats.values()),
|
| 122 |
+
mix_train=sum(s['train'] for s in stats.values()),mix_dev=holdouts,
|
| 123 |
+
original_gold_changed=gold_changes,upstream_additions_gold_verified=sum(map(len,additions.values())),
|
| 124 |
+
additions_train_only=True,v2_holdout_items_unchanged=True,v2_exclusion_list_unchanged=True,
|
| 125 |
+
cord_presence_changed=nchanged,unique_training_images=len(allpaths),dev_images=len(devpaths),
|
| 126 |
+
board_hashes=len(board),image_overlap_sha256=0,image_overlap_dhash=0,board_near_images=0,
|
| 127 |
+
threshold=4,image_manifest_sha256=manifest.hexdigest())
|
| 128 |
+
V.dump(OUT/'validation.json',result)
|
| 129 |
+
print(json.dumps(result,indent=2))
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
if __name__=='__main__':main()
|