Buckets:
| import ast | |
| import io | |
| from pathlib import Path | |
| from PIL import Image | |
| import yaml | |
| from data.convert_thinkmorph import INTERLEAVED_THINK_SYSTEM_PROMPT, convert_row | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def _png(color): | |
| buffer = io.BytesIO() | |
| Image.new("RGB", (2, 2), color).save(buffer, format="PNG") | |
| return {"bytes": buffer.getvalue(), "path": None} | |
| def test_released_row_maps_to_exact_paper_interleaving(): | |
| row = { | |
| "pid": "sample-1", | |
| "question": "Where?", | |
| "answer": "A", | |
| "problem_image_0": _png("red"), | |
| "resoning_thought_0": "first", | |
| "reasoning_image_0": _png("blue"), | |
| "resoning_thought_1": "second", | |
| "task": "Jigsaw_Assembly", | |
| } | |
| converted = convert_row(row, Path("fixture.parquet")) | |
| assert converted["instruction_list"] == [ | |
| INTERLEAVED_THINK_SYSTEM_PROMPT + "Where?" | |
| ] | |
| assert converted["output_text_list"] == [ | |
| "<think>first</think><image_start>", | |
| "<image_end><think>second</think><answer>A</answer>", | |
| ] | |
| assert len(converted["image_list"]) == 2 | |
| assert set(converted) == { | |
| "image_list", | |
| "instruction_list", | |
| "output_text_list", | |
| } | |
| assert all( | |
| value.startswith(b"\x89PNG\r\n\x1a\n") | |
| for value in converted["image_list"] | |
| ) | |
| def test_converter_prompt_matches_official_inference_prompt(): | |
| tree = ast.parse((ROOT / "inferencer.py").read_text(encoding="utf-8")) | |
| assignment = next( | |
| node | |
| for node in tree.body | |
| if isinstance(node, ast.Assign) | |
| and any( | |
| isinstance(target, ast.Name) and target.id == "VLM_THINK_SYSTEM_PROMPT" | |
| for target in node.targets | |
| ) | |
| ) | |
| assert ast.literal_eval(assignment.value) == INTERLEAVED_THINK_SYSTEM_PROMPT | |
| def test_paper_dataset_config_selects_all_released_files_once(): | |
| config = yaml.safe_load( | |
| (ROOT / "data/configs/thinkmorph_paper.yaml").read_text(encoding="utf-8") | |
| )["unified_edit"] | |
| assert config["dataset_names"] == [ | |
| "thinkmorph_chart_refocus", | |
| "thinkmorph_jigsaw_assembly", | |
| "thinkmorph_spatial_navigation", | |
| "thinkmorph_visual_search", | |
| ] | |
| assert config["num_used_data"] == [60, 60, 60, 70] | |
| assert config["strict"] is True | |
Xet Storage Details
- Size:
- 2.29 kB
- Xet hash:
- 7cda0046bbf229a644be81a2f43f7465c1047d4d7faf7bf088befd6657f2f555
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.