Datasets:
seed_id int64 | depth int64 | num_operations int64 | result int64 | intermediate_max int64 | operator_counts dict | expression string | input string | output string |
|---|---|---|---|---|---|---|---|---|
0 | 2 | 2 | -4 | 8 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((4 * 1) - 8) | ((4 * 1) - 8) | -4 |
1 | 2 | 2 | -4 | 7 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((2 + 1) - 7) | ((2 + 1) - 7) | -4 |
2 | 2 | 2 | 19 | 37 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((17 + 20) - 18) | ((17 + 20) - 18) | 19 |
3 | 2 | 2 | 60 | 60 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((18 - 14) * 15) | ((18 - 14) * 15) | 60 |
4 | 2 | 2 | 14 | 14 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((11 - 9) * 7) | ((11 - 9) * 7) | 14 |
5 | 2 | 2 | 960 | 960 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((4 * 12) * 20) | ((4 * 12) * 20) | 960 |
6 | 2 | 2 | 30 | 30 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((2 + 15) + 13) | ((2 + 15) + 13) | 30 |
7 | 2 | 2 | 161 | 180 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((18 * 10) - 19) | ((18 * 10) - 19) | 161 |
8 | 2 | 2 | 11 | 11 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((3 - 2) + 10) | ((3 - 2) + 10) | 11 |
9 | 2 | 2 | 60 | 72 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((12 * 6) - 12) | ((12 * 6) - 12) | 60 |
10 | 2 | 2 | -12 | 18 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((9 - 3) - 18) | ((9 - 3) - 18) | -12 |
11 | 2 | 2 | 2 | 18 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((9 - 18) + 11) | ((9 - 18) + 11) | 2 |
12 | 2 | 2 | 208 | 208 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((8 * 2) * 13) | ((8 * 2) * 13) | 208 |
13 | 2 | 2 | 21 | 21 | {
"+": 0,
"-": 0,
"*": 1,
"/": 1
} | ((3 * 7) / 1) | ((3 * 7) / 1) | 21 |
14 | 2 | 2 | -11 | 15 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((13 - 15) - 9) | ((13 - 15) - 9) | -11 |
15 | 2 | 2 | 239 | 247 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((19 * 13) - 8) | ((19 * 13) - 8) | 239 |
16 | 2 | 2 | 35 | 35 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((17 + 16) + 2) | ((17 + 16) + 2) | 35 |
17 | 2 | 2 | 104 | 104 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((17 + 9) * 4) | ((17 + 9) * 4) | 104 |
18 | 2 | 2 | 30 | 44 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((11 * 4) - 14) | ((11 * 4) - 14) | 30 |
19 | 2 | 2 | -2 | 17 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((15 * 1) - 17) | ((15 * 1) - 17) | -2 |
20 | 2 | 2 | 51 | 68 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((17 * 4) - 17) | ((17 * 4) - 17) | 51 |
21 | 2 | 2 | 11 | 18 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((5 - 12) + 18) | ((5 - 12) + 18) | 11 |
22 | 2 | 2 | -6 | 10 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((1 * 4) - 10) | ((1 * 4) - 10) | -6 |
23 | 2 | 2 | 15 | 18 | {
"+": 0,
"-": 1,
"*": 0,
"/": 1
} | ((3 - 18) / -1) | ((3 - 18) / -1) | 15 |
24 | 2 | 2 | -12 | 12 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((4 - 8) * 3) | ((4 - 8) * 3) | -12 |
25 | 2 | 2 | -37 | 37 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((1 - 19) - 19) | ((1 - 19) - 19) | -37 |
26 | 2 | 2 | 12 | 12 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((1 + 3) + 8) | ((1 + 3) + 8) | 12 |
27 | 2 | 2 | -4 | 17 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((2 + 11) - 17) | ((2 + 11) - 17) | -4 |
28 | 2 | 2 | -25 | 25 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((9 - 16) - 18) | ((9 - 16) - 18) | -25 |
29 | 2 | 2 | 0 | 11 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((11 - 4) - 7) | ((11 - 4) - 7) | 0 |
30 | 2 | 2 | -11 | 18 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((18 - 15) - 14) | ((18 - 15) - 14) | -11 |
31 | 2 | 2 | 6 | 15 | {
"+": 0,
"-": 1,
"*": 0,
"/": 1
} | ((9 - 15) / -1) | ((9 - 15) / -1) | 6 |
32 | 2 | 2 | 40 | 40 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((18 + 4) + 18) | ((18 + 4) + 18) | 40 |
33 | 2 | 2 | 195 | 195 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((1 * 13) * 15) | ((1 * 13) * 15) | 195 |
34 | 2 | 2 | 42 | 42 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((5 * 7) + 7) | ((5 * 7) + 7) | 42 |
35 | 2 | 2 | 48 | 48 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((19 + 18) + 11) | ((19 + 18) + 11) | 48 |
36 | 2 | 2 | 2 | 17 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((17 - 17) + 2) | ((17 - 17) + 2) | 2 |
37 | 2 | 2 | 4 | 19 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((4 - 19) + 19) | ((4 - 19) + 19) | 4 |
38 | 2 | 2 | 352 | 361 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((19 * 19) - 9) | ((19 * 19) - 9) | 352 |
39 | 2 | 2 | 75 | 88 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((11 * 8) - 13) | ((11 * 8) - 13) | 75 |
40 | 2 | 2 | 153 | 153 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((10 * 15) + 3) | ((10 * 15) + 3) | 153 |
41 | 2 | 2 | 32 | 35 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((15 + 20) - 3) | ((15 + 20) - 3) | 32 |
42 | 2 | 2 | 20 | 20 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((17 - 9) + 12) | ((17 - 9) + 12) | 20 |
43 | 2 | 2 | 96 | 96 | {
"+": 0,
"-": 0,
"*": 1,
"/": 1
} | ((8 * 12) / 1) | ((8 * 12) / 1) | 96 |
44 | 2 | 2 | 504 | 504 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((18 + 10) * 18) | ((18 + 10) * 18) | 504 |
45 | 2 | 2 | 24 | 24 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((4 * 5) + 4) | ((4 * 5) + 4) | 24 |
46 | 2 | 2 | 80 | 90 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((18 * 5) - 10) | ((18 * 5) - 10) | 80 |
47 | 2 | 2 | 154 | 154 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((9 + 2) * 14) | ((9 + 2) * 14) | 154 |
48 | 2 | 2 | 10 | 10 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((2 * 1) * 5) | ((2 * 1) * 5) | 10 |
49 | 2 | 2 | 16 | 19 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((18 + 1) - 3) | ((18 + 1) - 3) | 16 |
50 | 2 | 2 | 17 | 36 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((18 * 2) - 19) | ((18 * 2) - 19) | 17 |
51 | 2 | 2 | 190 | 190 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((14 + 5) * 10) | ((14 + 5) * 10) | 190 |
52 | 2 | 2 | -2 | 12 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((2 - 12) + 8) | ((2 - 12) + 8) | -2 |
53 | 2 | 2 | 9 | 20 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((20 - 5) - 6) | ((20 - 5) - 6) | 9 |
54 | 2 | 2 | 14 | 16 | {
"+": 0,
"-": 1,
"*": 0,
"/": 1
} | ((2 - 16) / -1) | ((2 - 16) / -1) | 14 |
55 | 2 | 2 | 10 | 12 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((12 - 10) + 8) | ((12 - 10) + 8) | 10 |
56 | 2 | 2 | 100 | 100 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((7 * 13) + 9) | ((7 * 13) + 9) | 100 |
57 | 2 | 2 | 116 | 116 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((18 + 11) * 4) | ((18 + 11) * 4) | 116 |
58 | 2 | 2 | 116 | 116 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((6 * 19) + 2) | ((6 * 19) + 2) | 116 |
59 | 2 | 2 | 24 | 37 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((20 + 17) - 13) | ((20 + 17) - 13) | 24 |
60 | 2 | 2 | 132 | 132 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((3 * 11) * 4) | ((3 * 11) * 4) | 132 |
61 | 2 | 2 | 125 | 143 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((11 * 13) - 18) | ((11 * 13) - 18) | 125 |
62 | 2 | 2 | 133 | 133 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((6 * 20) + 13) | ((6 * 20) + 13) | 133 |
63 | 2 | 2 | 0 | 14 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((10 - 10) * 14) | ((10 - 10) * 14) | 0 |
64 | 2 | 2 | 306 | 306 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((6 * 3) * 17) | ((6 * 3) * 17) | 306 |
65 | 2 | 2 | 16 | 24 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((3 * 8) - 8) | ((3 * 8) - 8) | 16 |
66 | 2 | 2 | 6 | 13 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((13 - 8) + 1) | ((13 - 8) + 1) | 6 |
67 | 2 | 2 | 16 | 18 | {
"+": 0,
"-": 1,
"*": 0,
"/": 1
} | ((2 - 18) / -1) | ((2 - 18) / -1) | 16 |
68 | 2 | 2 | 75 | 75 | {
"+": 0,
"-": 0,
"*": 1,
"/": 1
} | ((5 * 15) / 1) | ((5 * 15) / 1) | 75 |
69 | 2 | 2 | -63 | 63 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((3 - 10) * 9) | ((3 - 10) * 9) | -63 |
70 | 2 | 2 | 24 | 29 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((11 + 18) - 5) | ((11 + 18) - 5) | 24 |
71 | 2 | 2 | 2 | 13 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((8 - 13) + 7) | ((8 - 13) + 7) | 2 |
72 | 2 | 2 | 35 | 35 | {
"+": 1,
"-": 0,
"*": 0,
"/": 1
} | ((19 / 1) + 16) | ((19 / 1) + 16) | 35 |
73 | 2 | 2 | -20 | 20 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((14 - 18) - 16) | ((14 - 18) - 16) | -20 |
74 | 2 | 2 | 0 | 13 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((1 * 13) - 13) | ((1 * 13) - 13) | 0 |
75 | 2 | 2 | 33 | 33 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((15 + 5) + 13) | ((15 + 5) + 13) | 33 |
76 | 2 | 2 | -26 | 26 | {
"+": 0,
"-": 2,
"*": 0,
"/": 0
} | ((3 - 14) - 15) | ((3 - 14) - 15) | -26 |
77 | 2 | 2 | 10 | 10 | {
"+": 1,
"-": 0,
"*": 0,
"/": 1
} | ((9 / 1) + 1) | ((9 / 1) + 1) | 10 |
78 | 2 | 2 | 22 | 22 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((12 + 8) + 2) | ((12 + 8) + 2) | 22 |
79 | 2 | 2 | -5 | 20 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((8 + 7) - 20) | ((8 + 7) - 20) | -5 |
80 | 2 | 2 | -225 | 225 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((4 - 19) * 15) | ((4 - 19) * 15) | -225 |
81 | 2 | 2 | 108 | 108 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((12 + 6) * 6) | ((12 + 6) * 6) | 108 |
82 | 2 | 2 | 1 | 20 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((13 + 7) - 19) | ((13 + 7) - 19) | 1 |
83 | 2 | 2 | 33 | 33 | {
"+": 2,
"-": 0,
"*": 0,
"/": 0
} | ((4 + 10) + 19) | ((4 + 10) + 19) | 33 |
84 | 2 | 2 | 36 | 36 | {
"+": 0,
"-": 0,
"*": 1,
"/": 1
} | ((12 * 3) / 1) | ((12 * 3) / 1) | 36 |
85 | 2 | 2 | -153 | 153 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((5 - 14) * 17) | ((5 - 14) * 17) | -153 |
86 | 2 | 2 | 199 | 210 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((15 * 14) - 11) | ((15 * 14) - 11) | 199 |
87 | 2 | 2 | 0 | 11 | {
"+": 0,
"-": 1,
"*": 0,
"/": 1
} | ((11 / 1) - 11) | ((11 / 1) - 11) | 0 |
88 | 2 | 2 | 1,008 | 1,008 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((16 * 7) * 9) | ((16 * 7) * 9) | 1008 |
89 | 2 | 2 | 198 | 198 | {
"+": 1,
"-": 0,
"*": 1,
"/": 0
} | ((9 * 20) + 18) | ((9 * 20) + 18) | 198 |
90 | 2 | 2 | 24 | 24 | {
"+": 1,
"-": 0,
"*": 0,
"/": 1
} | ((17 + 7) / 1) | ((17 + 7) / 1) | 24 |
91 | 2 | 2 | 6 | 16 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((15 + 1) - 10) | ((15 + 1) - 10) | 6 |
92 | 2 | 2 | 1,976 | 1,976 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((13 * 8) * 19) | ((13 * 8) * 19) | 1976 |
93 | 2 | 2 | 4,032 | 4,032 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((16 * 18) * 14) | ((16 * 18) * 14) | 4032 |
94 | 2 | 2 | 1,800 | 1,800 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((12 * 15) * 10) | ((12 * 15) * 10) | 1800 |
95 | 2 | 2 | 15 | 15 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((8 - 4) + 11) | ((8 - 4) + 11) | 15 |
96 | 2 | 2 | 167 | 171 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((9 * 19) - 4) | ((9 * 19) - 4) | 167 |
97 | 2 | 2 | 480 | 480 | {
"+": 0,
"-": 0,
"*": 2,
"/": 0
} | ((10 * 8) * 6) | ((10 * 8) * 6) | 480 |
98 | 2 | 2 | -8 | 18 | {
"+": 1,
"-": 1,
"*": 0,
"/": 0
} | ((1 - 18) + 9) | ((1 - 18) + 9) | -8 |
99 | 2 | 2 | 8 | 15 | {
"+": 0,
"-": 1,
"*": 1,
"/": 0
} | ((15 - 11) * 2) | ((15 - 11) * 2) | 8 |
Compositional Reasoning on Arithmetic: Datasets (v2)
These are synthetic arithmetic datasets for testing whether sequence-to-sequence models generalize to longer expressions (Study 1) and more deeply nested ones (Study 2). They were used in the paper Partial Competence and Limited Transfer: Comparing LSTM and Transformer Generalization on Arithmetic Expressions (arXiv ID pending).
Each example is a fully parenthesized integer expression paired with its value:
input: (((15 - 3) + 10) + (17 * 20))
output: 362
- Code and generator: https://github.com/bcode0127-debug/Compositional-Reasoning-Arithmetic (
data/generate_controlled.py) - Trained models: Ajay0728/Compositional-reasoning-arithmetic
Studies and splits
Study 1: length generalization. Models train on 2–3 operations and are tested on 4–7.
| Split | File | Size | Expressions |
|---|---|---|---|
| train | study1/train.json |
8,000 | 2 ops depth 2, 3 ops depth 2, 3 ops depth 3 chain (one third each) |
| validation | study1/val.json |
1,000 | same mix as train |
| test | study1/test.json |
1,000 | same mix as train |
| ood_ops4 | study1/ood_ops4.json |
1,000 | 4 ops, depth 3, balanced |
| ood_ops5 | study1/ood_ops5.json |
1,000 | 5 ops, depth 3, balanced |
| ood_ops6 | study1/ood_ops6.json |
1,000 | 6 ops, depth 3, balanced |
| ood_ops7 | study1/ood_ops7.json |
1,000 | 7 ops, depth 3, balanced |
Study 2: depth generalization. The number of operations stays at 3 while nesting depth goes from 2 to 3.
| Split | File | Size | Expressions |
|---|---|---|---|
| train | study2/train.json |
8,000 | 3 ops, depth 2, balanced |
| validation | study2/val.json |
1,000 | 3 ops, depth 2, balanced |
| test | study2/test.json |
1,000 | 3 ops, depth 2, balanced |
| ood | study2/ood.json |
1,000 | 3 ops, depth 3, chain |
Each split was generated with its own random seed. The test splits were generated after the models were trained, from generator commit f636492, so they were never used for model selection. Every other split comes from commit f504457.
Usage
from datasets import load_dataset
s1 = load_dataset("Ajay0728/Compositional-reasoning-arithmetic-datasets", "study1")
print(s1["train"][0]["input"], "->", s1["train"][0]["output"])
ood7 = load_dataset("Ajay0728/Compositional-reasoning-arithmetic-datasets", "study1", split="ood_ops7")
You can also download the raw JSON files directly. Each file is a JSON object with the examples under "data" and the generation metadata in the other top-level keys.
Fields
Each example has these fields:
| Field | Type | Description |
|---|---|---|
input |
string | Model input: the fully parenthesized expression, with spaces around operators |
output |
string | Target: the integer result as a string |
expression |
string | Same as input |
result |
int | Integer value of the expression |
num_operations |
int | Number of binary operators |
depth |
int | Depth of the expression tree |
intermediate_max |
int | Largest absolute intermediate value during evaluation |
operator_counts |
dict | Count of each of + - * / |
seed_id |
int | Index of the generator seed this example came from |
Each file also has these top-level metadata keys:
study,split,seed,generator_commit,timestampbuckets: the operation count, depth, tree shape and rejection rate for each group of expressionsoperator_distribution_actual: how often each operator actually appears
How the data was generated
Each expression is built as a random binary expression tree with a target operation count, depth, and shape. A shape is either balanced or chain, where a chain nests to one side only. Candidates are rejected unless:
- every division is exact (integer result, no remainder, no division by zero)
- the final result satisfies |result| ≤ 10,000
All inputs are at most 51 characters long. Outputs are at most 6 characters (e.g. -10000).
Operator balance: division is rare in every split, about 3–5% of operators, because the exact-division requirement rejects most division candidates. The other three operators make up roughly 28–35% each. Results broken down by operator, especially for division, should account for these small counts.
Integrity
CHECKSUMS.txt lists the SHA-256 hash of each file. Its paths start with datasets_v2/, so to verify, put the files in a folder named datasets_v2 and run shasum -a 256 -c CHECKSUMS.txt from that folder's parent.
Superseded version
An earlier version of these datasets, datasets/ in the GitHub repo, was used with an evaluation path that silently cut inputs to 20 characters. Results from that version are retired. This v2 release is the one used for every number reported in the paper.
Citation
@misc{jamanjyothi2026partial,
title = {Partial Competence and Limited Transfer: Comparing LSTM and Transformer
Generalization on Arithmetic Expressions},
author = {Jamanjyothi, Ajay},
year = {2026},
note = {arXiv preprint (ID pending)}
}
- Downloads last month
- -