Datasets:
Add dataset card
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- arithmetic
|
| 9 |
+
- interpretability
|
| 10 |
+
- sorl
|
| 11 |
+
- mechanistic-interpretability
|
| 12 |
+
- addition
|
| 13 |
+
- subtraction
|
| 14 |
+
size_categories:
|
| 15 |
+
- 1M<n<10M
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Arithmetic SoRL Data
|
| 19 |
+
|
| 20 |
+
Training and evaluation data for the **SoRL Arithmetic Interpretability Study**.
|
| 21 |
+
|
| 22 |
+
We train small transformers on integer addition and subtraction, then use
|
| 23 |
+
[Self-Organizing Reinforcement Learning (SoRL)](https://github.com/fangyuan-ksgk/mod_gpt)
|
| 24 |
+
to externalize the model's carry/borrow circuits as explicit abstraction tokens.
|
| 25 |
+
|
| 26 |
+
Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024)
|
| 27 |
+
|
| 28 |
+
## Dataset Structure
|
| 29 |
+
|
| 30 |
+
Each subfolder contains `train.parquet`, `val.parquet`, and `config.json`.
|
| 31 |
+
|
| 32 |
+
| Subfolder | Digits | Operations | Train | Val | Sequence Length |
|
| 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 |
+
## Format
|
| 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 |
+
| BS | Base Sub | Simple subtraction, no borrow |
|
| 72 |
+
| MB1 | Make Borrow | x_i < y_i, needs borrow |
|
| 73 |
+
| MD9 | Make Diff 9 | x_i == y_i, propagates borrow if present |
|
| 74 |
+
| UB1 | Use Borrow | borrow_in=1, x_i != y_i |
|
| 75 |
+
| UD9 | Use Diff 9 | borrow_in=1, x_i == y_i (cascade, hardest) |
|
| 76 |
+
|
| 77 |
+
## Data Enrichment
|
| 78 |
+
|
| 79 |
+
Following Quirke et al.: 60% of batches have 40% of digit positions forced to sum-to-9,
|
| 80 |
+
increasing the frequency of US9 (carry cascade) examples from ~6% to ~8%.
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
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': [1, 2, 3, 4, 5, 6, 10, 6, 5, 4, 3, 2, 1, 11, 0, 7, 7, 7, 7, 7, 7],
|
| 90 |
+
# 'labels': ['BA', 'UC1', 'MS9', ...], 'op': 'add', ...}
|
| 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)
|