Datasets:
Update dataset card with Quirke complexity labels
Browse files
README.md
CHANGED
|
@@ -11,6 +11,7 @@ tags:
|
|
| 11 |
- mechanistic-interpretability
|
| 12 |
- addition
|
| 13 |
- subtraction
|
|
|
|
| 14 |
size_categories:
|
| 15 |
- 1M<n<10M
|
| 16 |
---
|
|
@@ -19,65 +20,77 @@ size_categories:
|
|
| 19 |
|
| 20 |
Training and evaluation data for the **SoRL Arithmetic Interpretability Study**.
|
| 21 |
|
| 22 |
-
|
| 23 |
-
[
|
| 24 |
-
|
| 25 |
|
| 26 |
Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024)
|
| 27 |
|
| 28 |
## Dataset Structure
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|---|---|---|---|---|---|
|
| 34 |
-
| `add_6digit` | 6 | addition | 500K | 10K | 21 tokens |
|
| 35 |
-
| `add_sub_6digit` | 6 | add + sub | 500K | 10K | 21 tokens |
|
| 36 |
-
| `add_4digit` | 4 | addition | 500K | 10K | 15 tokens |
|
| 37 |
-
| `add_sub_4digit` | 4 | add + sub | 500K | 10K | 15 tokens |
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
Each row has:
|
| 42 |
-
- **tokens**: list of ints — the full input sequence (operands + operator + answer)
|
| 43 |
-
- **labels**: list of str — per-answer-digit sub-task label
|
| 44 |
-
- **op**: `"add"` or `"sub"`
|
| 45 |
-
- **x_digits**, **y_digits**, **z_digits**: the raw digit lists (MSB first)
|
| 46 |
-
|
| 47 |
-
### Token format
|
| 48 |
-
|
| 49 |
-
Addition: `XXXXXX+YYYYYY=ZZZZZZZ` (n_digits + operator + n_digits + equals + n_digits+1)
|
| 50 |
-
|
| 51 |
-
Subtraction: `XXXXXX-YYYYYY=ZZZZZZZ` (x >= y guaranteed, answer zero-padded)
|
| 52 |
-
|
| 53 |
-
Token IDs: 0-9 = digits, 10 = `+`, 11 = `=`, 12 = `-`
|
| 54 |
-
|
| 55 |
-
### Sub-task labels
|
| 56 |
-
|
| 57 |
-
Each answer digit is labeled with the arithmetic sub-task it requires:
|
| 58 |
-
|
| 59 |
-
**Addition:**
|
| 60 |
-
| Label | Name | Description |
|
| 61 |
-
|---|---|---|
|
| 62 |
-
| BA | Base Add | Simple addition, no carry |
|
| 63 |
-
| MC1 | Make Carry | digit_sum >= 10, generates carry |
|
| 64 |
-
| MS9 | Make Sum 9 | digit_sum == 9, propagates carry if present |
|
| 65 |
-
| UC1 | Use Carry | carry_in=1, digit_sum != 9 |
|
| 66 |
-
| US9 | Use Sum 9 | carry_in=1, digit_sum == 9 (cascade, hardest) |
|
| 67 |
-
|
| 68 |
-
**Subtraction:**
|
| 69 |
-
| Label | Name | Description |
|
| 70 |
|---|---|---|
|
| 71 |
-
|
|
| 72 |
-
|
|
| 73 |
-
|
|
| 74 |
-
|
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
## Data Enrichment
|
| 78 |
|
| 79 |
-
Following Quirke
|
| 80 |
-
increasing
|
| 81 |
|
| 82 |
## Usage
|
| 83 |
|
|
@@ -86,12 +99,15 @@ from datasets import load_dataset
|
|
| 86 |
|
| 87 |
ds = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_6digit")
|
| 88 |
print(ds["train"][0])
|
| 89 |
-
# {'tokens': [
|
| 90 |
-
# '
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
```
|
| 92 |
|
| 93 |
## Related
|
| 94 |
|
| 95 |
- Model checkpoints: [thoughtworks/arithmetic-sorl](https://huggingface.co/thoughtworks/arithmetic-sorl)
|
| 96 |
- Code: [mod_gpt/arithmetic/](https://github.com/fangyuan-ksgk/mod_gpt/tree/amir/arithmetic/arithmetic)
|
| 97 |
-
- SoRL paper: Yu & Abdullah, "Intention-Level Alignment with Weak Supervision" (2025)
|
|
|
|
| 11 |
- mechanistic-interpretability
|
| 12 |
- addition
|
| 13 |
- subtraction
|
| 14 |
+
- quirke
|
| 15 |
size_categories:
|
| 16 |
- 1M<n<10M
|
| 17 |
---
|
|
|
|
| 20 |
|
| 21 |
Training and evaluation data for the **SoRL Arithmetic Interpretability Study**.
|
| 22 |
|
| 23 |
+
Small transformers trained on integer addition/subtraction, with
|
| 24 |
+
[SoRL](https://github.com/fangyuan-ksgk/mod_gpt) to externalize carry/borrow circuits
|
| 25 |
+
as explicit abstraction tokens.
|
| 26 |
|
| 27 |
Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024)
|
| 28 |
|
| 29 |
## Dataset Structure
|
| 30 |
|
| 31 |
+
| Subfolder | Operations | Train | Val | Eval (stratified) |
|
| 32 |
+
|---|---|---|---|---|
|
| 33 |
+
| `add_6digit` | addition only | 500K | 10K | ~550 (50 per S0-S6 + 200 random) |
|
| 34 |
+
| `add_sub_6digit` | add + sub | 500K | 10K | ~1100 (50 per S0-S6 + M0-M6 + random) |
|
| 35 |
|
| 36 |
+
## Columns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
| Column | Type | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|---|---|---|
|
| 40 |
+
| `tokens` | list[int] | Full sequence (21 tokens for 6-digit) |
|
| 41 |
+
| `labels` | list[str] | Per-answer-digit sub-task label |
|
| 42 |
+
| `op` | str | `"add"` or `"sub"` |
|
| 43 |
+
| `complexity` | str | Quirke complexity: `S0`-`S6` (add) or `M0`-`M6` (sub) |
|
| 44 |
+
| `cascade_depth` | int | Max carry/borrow cascade length |
|
| 45 |
+
| `x_digits` | list[int] | First operand (MSB first) |
|
| 46 |
+
| `y_digits` | list[int] | Second operand (MSB first) |
|
| 47 |
+
| `z_digits` | list[int] | Answer (MSB first, n_digits+1) |
|
| 48 |
+
|
| 49 |
+
The `eval_stratified` split has an additional `eval_category` column.
|
| 50 |
+
|
| 51 |
+
## Sub-task Labels (Quirke et al.)
|
| 52 |
+
|
| 53 |
+
Each answer digit requires a specific arithmetic operation:
|
| 54 |
+
|
| 55 |
+
### Addition
|
| 56 |
+
| Label | Name | Condition | Role |
|
| 57 |
+
|---|---|---|---|
|
| 58 |
+
| SA | Base Add | `Dn + D'n < 9`, no carry | Simplest case |
|
| 59 |
+
| SC | Make Carry | `Dn + D'n >= 10` | Generates carry |
|
| 60 |
+
| SS | Sum is 9 | `Dn + D'n == 9` | Propagates carry if one arrives |
|
| 61 |
+
| UC | Use Carry | carry_in=1, sum != 9 | Consumes incoming carry |
|
| 62 |
+
| US | Use Sum-9 | carry_in=1, sum == 9 | Cascade: hardest case |
|
| 63 |
+
|
| 64 |
+
### Subtraction (x >= y)
|
| 65 |
+
| Label | Name | Condition | Role |
|
| 66 |
+
|---|---|---|---|
|
| 67 |
+
| MD | Base Diff | `Dn > D'n`, no borrow | Simplest case |
|
| 68 |
+
| MB | Make Borrow | `Dn < D'n` | Generates borrow |
|
| 69 |
+
| ME | Equal digits | `Dn == D'n` | Propagates borrow if one arrives |
|
| 70 |
+
| UB | Use Borrow | borrow_in=1, `Dn != D'n` | Consumes incoming borrow |
|
| 71 |
+
| UD | Use Equal | borrow_in=1, `Dn == D'n` | Cascade: hardest case |
|
| 72 |
+
|
| 73 |
+
## Complexity Classification (Quirke Table 8)
|
| 74 |
+
|
| 75 |
+
Complexity = length of longest carry/borrow cascade chain.
|
| 76 |
+
|
| 77 |
+
Example: `555555+444448=1000003` is **S6** — the carry from D0 cascades through
|
| 78 |
+
5 consecutive sum-9 positions.
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
S0: no carries ~10%
|
| 82 |
+
S1: isolated carries ~50%
|
| 83 |
+
S2: cascade of 2 ~26%
|
| 84 |
+
S3: cascade of 3 ~9%
|
| 85 |
+
S4: cascade of 4 ~3%
|
| 86 |
+
S5: cascade of 5 ~1%
|
| 87 |
+
S6: cascade of 6 <0.5%
|
| 88 |
+
```
|
| 89 |
|
| 90 |
## Data Enrichment
|
| 91 |
|
| 92 |
+
Following Quirke: 60% of batches have 40% of digit positions forced to sum-to-9,
|
| 93 |
+
increasing cascade frequency so the model sees enough S4-S6 cases.
|
| 94 |
|
| 95 |
## Usage
|
| 96 |
|
|
|
|
| 99 |
|
| 100 |
ds = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_6digit")
|
| 101 |
print(ds["train"][0])
|
| 102 |
+
# {'tokens': [...], 'labels': ['SA', 'UC', 'US', ...],
|
| 103 |
+
# 'complexity': 'S3', 'cascade_depth': 3, ...}
|
| 104 |
+
|
| 105 |
+
# Stratified eval
|
| 106 |
+
eval_ds = load_dataset("thoughtworks/arithmetic-sorl-data",
|
| 107 |
+
data_dir="add_6digit", data_files="eval_stratified.parquet")
|
| 108 |
```
|
| 109 |
|
| 110 |
## Related
|
| 111 |
|
| 112 |
- Model checkpoints: [thoughtworks/arithmetic-sorl](https://huggingface.co/thoughtworks/arithmetic-sorl)
|
| 113 |
- Code: [mod_gpt/arithmetic/](https://github.com/fangyuan-ksgk/mod_gpt/tree/amir/arithmetic/arithmetic)
|
|
|