amirali1985 commited on
Commit
740f627
·
verified ·
1 Parent(s): 9d969b0

update dataset card: N=250 eval sets, Quirke arxiv link, subtraction enrichment, M6 note

Browse files
Files changed (1) hide show
  1. README.md +36 -13
README.md CHANGED
@@ -49,23 +49,40 @@ Small transformers trained on integer addition/subtraction, with
49
  [SoRL](https://github.com/fangyuan-ksgk/mod_gpt) to externalize carry/borrow circuits
50
  as explicit abstraction tokens.
51
 
52
- Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024)
 
53
 
54
  ## Dataset Structure
55
 
56
  | Subfolder | Operations | Train | Val | Eval (stratified) |
57
  |---|---|---|---|---|
58
- | `add_6digit` | addition only | 500K | 10K | ~550 (50 per S0-S6 + 200 random) |
59
- | `add_sub_6digit` | add + sub | 500K | 10K | ~1100 (50 per S0-S6 + M0-M6 + random) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  ## Columns
62
 
63
  | Column | Type | Description |
64
  |---|---|---|
65
- | `tokens` | list[int] | Full sequence (21 tokens for 6-digit) |
66
- | `labels` | list[str] | Per-answer-digit sub-task label |
67
  | `op` | str | `"add"` or `"sub"` |
68
- | `complexity` | str | Quirke complexity: `S0`-`S6` (add) or `M0`-`M6` (sub) |
69
  | `cascade_depth` | int | Max carry/borrow cascade length |
70
  | `x_digits` | list[int] | First operand (MSB first) |
71
  | `y_digits` | list[int] | Second operand (MSB first) |
@@ -73,9 +90,9 @@ Reference: Quirke et al., "Understanding Addition and Subtraction in Transformer
73
 
74
  The `eval_stratified` split has an additional `eval_category` column.
75
 
76
- ## Sub-task Labels (Quirke et al.)
77
 
78
- Each answer digit requires a specific arithmetic operation:
79
 
80
  ### Addition
81
  | Label | Name | Condition | Role |
@@ -95,7 +112,7 @@ Each answer digit requires a specific arithmetic operation:
95
  | UB | Use Borrow | borrow_in=1, `Dn != D'n` | Consumes incoming borrow |
96
  | UD | Use Equal | borrow_in=1, `Dn == D'n` | Cascade: hardest case |
97
 
98
- ## Complexity Classification (Quirke Table 8)
99
 
100
  Complexity = length of longest carry/borrow cascade chain.
101
 
@@ -114,8 +131,9 @@ S6: cascade of 6 <0.5%
114
 
115
  ## Data Enrichment
116
 
117
- Following Quirke: 60% of batches have 40% of digit positions forced to sum-to-9,
118
- increasing cascade frequency so the model sees enough S4-S6 cases.
 
119
 
120
  ## Usage
121
 
@@ -130,9 +148,14 @@ print(ds["train"][0])
130
  # Stratified eval
131
  eval_ds = load_dataset("thoughtworks/arithmetic-sorl-data",
132
  data_dir="add_6digit", data_files="eval_stratified.parquet")
 
 
 
133
  ```
134
 
135
  ## Related
136
 
137
- - Model checkpoints: [thoughtworks/arithmetic-sorl](https://huggingface.co/thoughtworks/arithmetic-sorl)
138
- - Code: [mod_gpt/arithmetic/](https://github.com/fangyuan-ksgk/mod_gpt/tree/amir/arithmetic/arithmetic)
 
 
 
49
  [SoRL](https://github.com/fangyuan-ksgk/mod_gpt) to externalize carry/borrow circuits
50
  as explicit abstraction tokens.
51
 
52
+ **Reference:** Quirke et al., ["Understanding Addition and Subtraction in Transformers"](https://arxiv.org/abs/2402.02619) (2024).
53
+ Paper: [arXiv:2402.02619](https://arxiv.org/abs/2402.02619) — see Table 8 for complexity classification and Section 3 for sub-task definitions.
54
 
55
  ## Dataset Structure
56
 
57
  | Subfolder | Operations | Train | Val | Eval (stratified) |
58
  |---|---|---|---|---|
59
+ | `add_6digit` | addition only | 500K | 10K | ~2950 (250 per S0-S6, C3-C6 + 200 random) |
60
+ | `add_sub_6digit` | add + sub | 500K | 10K | ~5400 (250 per split + 400 random) |
61
+ | `add_handcrafted` | addition only | — | — | 108 |
62
+ | `sub_handcrafted` | subtraction only | — | — | 68 |
63
+
64
+ ### Eval Splits
65
+
66
+ All eval sets use seed=42 for reproducibility. Every model is evaluated on identical examples.
67
+
68
+ | Split Type | Splits | Examples/split | Description |
69
+ |---|---|---|---|
70
+ | Quirke cascades (add) | S0-S6 | 250 | Carry cascade depth 0-6 |
71
+ | Hot carry chains | C3-C6 | 250 | Carry cascades with varied answer digits (not just 0s) |
72
+ | Quirke cascades (sub) | M0-M5 | 250 | Borrow cascade depth 0-5 (M6 is impossible for 6-digit) |
73
+ | Hot borrow chains | B3-B5 | 250 | Borrow cascades with varied answer digits (not just 9s) |
74
+ | Random | add_random, sub_random | 200 | Uniform random |
75
+
76
+ **Note:** M6 (borrow cascade of length 6) is impossible for 6-digit subtraction — it would require 7 digit positions.
77
 
78
  ## Columns
79
 
80
  | Column | Type | Description |
81
  |---|---|---|
82
+ | `tokens` | list[int] | Full sequence (21 tokens for 6-digit, Qwen3 tokenizer) |
83
+ | `labels` | list[str] | Per-answer-digit sub-task label (SA, SC, SS, UC, US for add; MD, MB, ME, UB, UD for sub) |
84
  | `op` | str | `"add"` or `"sub"` |
85
+ | `complexity` | str | Quirke complexity: `S0`-`S6` (add) or `M0`-`M5` (sub) |
86
  | `cascade_depth` | int | Max carry/borrow cascade length |
87
  | `x_digits` | list[int] | First operand (MSB first) |
88
  | `y_digits` | list[int] | Second operand (MSB first) |
 
90
 
91
  The `eval_stratified` split has an additional `eval_category` column.
92
 
93
+ ## Sub-task Labels ([Quirke et al. 2024](https://arxiv.org/abs/2402.02619))
94
 
95
+ Each answer digit requires a specific arithmetic operation. These labels follow Quirke et al. Section 3.
96
 
97
  ### Addition
98
  | Label | Name | Condition | Role |
 
112
  | UB | Use Borrow | borrow_in=1, `Dn != D'n` | Consumes incoming borrow |
113
  | UD | Use Equal | borrow_in=1, `Dn == D'n` | Cascade: hardest case |
114
 
115
+ ## Complexity Classification ([Quirke Table 8](https://arxiv.org/abs/2402.02619))
116
 
117
  Complexity = length of longest carry/borrow cascade chain.
118
 
 
131
 
132
  ## Data Enrichment
133
 
134
+ **Addition:** Following Quirke et al., 60% of batches have 40% of digit positions forced to sum-to-9, increasing carry cascade frequency so the model sees enough S4-S6 cases.
135
+
136
+ **Subtraction:** 40% of digit positions are forced equal (`Dn == D'n`), creating borrow propagation cascades (ME/UD). Without this, M3-M5 borrow cascades are extremely rare (M3=0.7%, M4=0.04% in unmodified data). With enrichment: M3=3.0%, M4=0.8%.
137
 
138
  ## Usage
139
 
 
148
  # Stratified eval
149
  eval_ds = load_dataset("thoughtworks/arithmetic-sorl-data",
150
  data_dir="add_6digit", data_files="eval_stratified.parquet")
151
+
152
+ # Addition + subtraction
153
+ ds_mixed = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_sub_6digit")
154
  ```
155
 
156
  ## Related
157
 
158
+ - **Reference paper:** Quirke et al., ["Understanding Addition and Subtraction in Transformers"](https://arxiv.org/abs/2402.02619) (2024)
159
+ - **Model checkpoints:** [thoughtworks/arithmetic-sorl](https://huggingface.co/thoughtworks/arithmetic-sorl)
160
+ - **Dashboard:** [thoughtworks/arithmetic-sorl-dashboard](https://huggingface.co/spaces/thoughtworks/arithmetic-sorl-dashboard)
161
+ - **Code:** [mod_gpt/arithmetic/](https://github.com/fangyuan-ksgk/mod_gpt/tree/amir/arithmetic/arithmetic)