amirali1985's picture
Add dataset card
43ce032 verified
|
raw
history blame
3.19 kB
---
license: apache-2.0
task_categories:
- text-generation
language:
- en
tags:
- arithmetic
- interpretability
- sorl
- mechanistic-interpretability
- addition
- subtraction
size_categories:
- 1M<n<10M
---
# Arithmetic SoRL Data
Training and evaluation data for the **SoRL Arithmetic Interpretability Study**.
We train small transformers on integer addition and subtraction, then use
[Self-Organizing Reinforcement Learning (SoRL)](https://github.com/fangyuan-ksgk/mod_gpt)
to externalize the model's carry/borrow circuits as explicit abstraction tokens.
Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024)
## Dataset Structure
Each subfolder contains `train.parquet`, `val.parquet`, and `config.json`.
| Subfolder | Digits | Operations | Train | Val | Sequence Length |
|---|---|---|---|---|---|
| `add_6digit` | 6 | addition | 500K | 10K | 21 tokens |
| `add_sub_6digit` | 6 | add + sub | 500K | 10K | 21 tokens |
| `add_4digit` | 4 | addition | 500K | 10K | 15 tokens |
| `add_sub_4digit` | 4 | add + sub | 500K | 10K | 15 tokens |
## Format
Each row has:
- **tokens**: list of ints — the full input sequence (operands + operator + answer)
- **labels**: list of str — per-answer-digit sub-task label
- **op**: `"add"` or `"sub"`
- **x_digits**, **y_digits**, **z_digits**: the raw digit lists (MSB first)
### Token format
Addition: `XXXXXX+YYYYYY=ZZZZZZZ` (n_digits + operator + n_digits + equals + n_digits+1)
Subtraction: `XXXXXX-YYYYYY=ZZZZZZZ` (x >= y guaranteed, answer zero-padded)
Token IDs: 0-9 = digits, 10 = `+`, 11 = `=`, 12 = `-`
### Sub-task labels
Each answer digit is labeled with the arithmetic sub-task it requires:
**Addition:**
| Label | Name | Description |
|---|---|---|
| BA | Base Add | Simple addition, no carry |
| MC1 | Make Carry | digit_sum >= 10, generates carry |
| MS9 | Make Sum 9 | digit_sum == 9, propagates carry if present |
| UC1 | Use Carry | carry_in=1, digit_sum != 9 |
| US9 | Use Sum 9 | carry_in=1, digit_sum == 9 (cascade, hardest) |
**Subtraction:**
| Label | Name | Description |
|---|---|---|
| BS | Base Sub | Simple subtraction, no borrow |
| MB1 | Make Borrow | x_i < y_i, needs borrow |
| MD9 | Make Diff 9 | x_i == y_i, propagates borrow if present |
| UB1 | Use Borrow | borrow_in=1, x_i != y_i |
| UD9 | Use Diff 9 | borrow_in=1, x_i == y_i (cascade, hardest) |
## Data Enrichment
Following Quirke et al.: 60% of batches have 40% of digit positions forced to sum-to-9,
increasing the frequency of US9 (carry cascade) examples from ~6% to ~8%.
## Usage
```python
from datasets import load_dataset
ds = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_6digit")
print(ds["train"][0])
# {'tokens': [1, 2, 3, 4, 5, 6, 10, 6, 5, 4, 3, 2, 1, 11, 0, 7, 7, 7, 7, 7, 7],
# 'labels': ['BA', 'UC1', 'MS9', ...], 'op': 'add', ...}
```
## Related
- Model checkpoints: [thoughtworks/arithmetic-sorl](https://huggingface.co/thoughtworks/arithmetic-sorl)
- Code: [mod_gpt/arithmetic/](https://github.com/fangyuan-ksgk/mod_gpt/tree/amir/arithmetic/arithmetic)
- SoRL paper: Yu & Abdullah, "Intention-Level Alignment with Weak Supervision" (2025)