Add comprehensive dataset card for MathSticks

#2
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +123 -0
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ task_categories:
3
+ - image-text-to-text
4
+ language:
5
+ - en
6
+ tags:
7
+ - visual-reasoning
8
+ - symbolic-reasoning
9
+ - math
10
+ - matchstick-puzzles
11
+ - benchmark
12
+ ---
13
+
14
+ # MathSticks: A Benchmark for Visual Symbolic Compositional Reasoning with Matchstick Puzzles
15
+
16
+ **Paper:** [MathSticks: A Benchmark for Visual Symbolic Compositional Reasoning with Matchstick Puzzles](https://huggingface.co/papers/2510.00483)
17
+ **Code:** [https://github.com/Yuheng2000/MathSticks](https://github.com/Yuheng2000/MathSticks)
18
+
19
+ ## Overview
20
+ MathSticks is a benchmark for Visual Symbolic Compositional Reasoning (VSCR) that unifies visual perception, symbolic manipulation, and arithmetic consistency. Each task presents an incorrect matchstick equation in a seven-segment style. The goal is to move exactly one or two sticks—under strict stick-conservation and digit-legibility constraints—to make the equation mathematically correct.
21
+
22
+ - Two evaluation regimes:
23
+ - Text-guided: the equation string is provided to the model.
24
+ - Pure-visual: only the rendered puzzle image is provided.
25
+ - Systematic coverage: digit scale (Levels 1–4), move complexity (1/2 sticks), solution multiplicity, and operator variation.
26
+ - Scale: 1.4M generated instances; a curated test set of 400 items is released.
27
+
28
+ <p align="center">
29
+ <img src="https://raw.githubusercontent.com/Yuheng2000/MathSticks/main/example.png" alt="MathSticks example predictions" width="300"/>
30
+ <br/>
31
+ <em>Example: input puzzle, reasoning trace, and move-format predictions.</em>
32
+ <br/>
33
+ </p>
34
+
35
+ Evaluations across 14 VLMs reveal substantial limitations: closed-source models succeed only on simple cases, open-source models fail in the pure-visual regime, while humans exceed 90% accuracy. These results establish MathSticks as a rigorous, diagnostic testbed for advancing compositional reasoning across vision and symbols.
36
+
37
+ ## Task Definition
38
+ - Input: a rendered image of an incorrect equation composed of matchsticks (seven-segment digits). Optionally, a text equation string (text-guided regime).
39
+ - Constraints: move one or two sticks only; no addition/removal; preserve digit legibility.
40
+ - Objective: reach a valid arithmetic equation (addition or subtraction). Operator flips may be required by the minimal-move constraint in some cases.
41
+ - Output format: a boxed sequence of Move operations, e.g. `\boxed{Move(A0, C3)}` or `\boxed{Move(A0, C3), Move(E1, F4)}`.
42
+
43
+ ## Data Format (Benchmark JSONL)
44
+ Each line is one sample with the following fields:
45
+ - `id` (string): unique sample identifier, e.g., `"00075585"`.
46
+ - `level` (int): difficulty level (1–4) indicating digit scale.
47
+ - `image` (string): image path relative to repo root, e.g., `level1/00075585_8-9=3.png`.
48
+ - `problem` (string): the displayed (incorrect) equation string, e.g., `8-9=3`.
49
+ - `solution_num` (list[int, int]): counts of solvable solutions by move budget `[one_move_count, two_move_count]`.
50
+ - `mode_1_solution` (list): list of one-move solutions. Empty when `solution_num[0] == 0`.
51
+ - `mode_2_solution` (list): list of two-move solutions. Each item has:
52
+ - `solution` (string): corrected equation (e.g., `"8 - 6 = 2"`).
53
+ - `moves` (list[string]): standardized move format strings, e.g., `["Move(B2, B5)", "Move(C3, C5)"]`.
54
+ - `option_answer` (object): order-invariant representation of moves, for robust parsing:
55
+ - `mode_1` (list): each one-move answer as `{ "pick": [from_label], "place": [to_label] }`.
56
+ - `mode_2` (list): each two-move answer as `{ "pick": [from_label_1, from_label_2], "place": [to_label_1, to_label_2] }`.
57
+
58
+ Example:
59
+ ```json
60
+ {
61
+ "id": "00075585",
62
+ "level": 1,
63
+ "problem": "8-9=3",
64
+ "image": "level1/00075585_8-9=3.png",
65
+ "solution_num": [0, 4],
66
+ "mode_1_solution": [],
67
+ "mode_2_solution": [
68
+ {"solution": "8 - 6 = 2", "moves": ["Move(B2, B5)", "Move(C3, C5)"]},
69
+ {"solution": "9 - 9 = 0", "moves": ["Move(A5, C5)", "Move(C0, C6)"]},
70
+ {"solution": "6 + 3 = 9", "moves": ["Move(A2, G0)", "Move(B6, C6)"]},
71
+ {"solution": "9 - 0 = 9", "moves": ["Move(A5, B5)", "Move(B0, C6)"]}
72
+ ],
73
+ "option_answer": {
74
+ "mode_1": [],
75
+ "mode_2": [
76
+ {"pick": ["B2", "C3"], "place": ["B5", "C5"]},
77
+ {"pick": ["A5", "C0"], "place": ["C5", "C6"]},
78
+ {"pick": ["A2", "B6"], "place": ["G0", "C6"]},
79
+ {"pick": ["A5", "B0"], "place": ["B5", "C6"]}
80
+ ]
81
+ }
82
+ }
83
+ ```
84
+
85
+ Notes:
86
+ - Pure-visual regime uses only `image` for model input; text-guided may also use `problem`.
87
+ - The string move format is strict for parsing; `option_answer` provides an order-invariant equivalent when needed.
88
+
89
+ ## Sample Usage
90
+
91
+ ### 1) Run evaluation
92
+ ```bash
93
+ python eval.py \
94
+ --input MathSticks_bench_400.jsonl \
95
+ --image-dir ./image \
96
+ --output predictions.jsonl
97
+ ```
98
+
99
+ ### 2) Score predictions
100
+ ```bash
101
+ python cal_score.py \
102
+ --pred predictions.jsonl \
103
+ --label MathSticks_bench_400.jsonl \
104
+ --output score.json
105
+ ```
106
+
107
+ ### 3) Generate data (research use only)
108
+ ```bash
109
+ python match_gen_flt.py
110
+ ```
111
+ This enumerates positional encodings and writes the discovered solvable cases to `match_gen.jsonl`. It is computationally intensive and may take a long time.
112
+
113
+ ## Citation
114
+ If you find MathSticks useful, please cite the paper:
115
+ ```bibtex
116
+ @article{mathsticks2025,
117
+ title = {MathSticks: A Benchmark for Visual Symbolic Compositional Reasoning with Matchstick Puzzles},
118
+ author = {Anonymous},
119
+ journal = {arXiv preprint arXiv:TODO},
120
+ year = {2025},
121
+ url = {https://huggingface.co/papers/2510.00483}
122
+ }
123
+ ```