CoolFace
Datasetpublic

thoughtworks/arithmetic-sorl-data

Arithmetic SoRL Data Training and evaluation data for the SoRL Arithmetic Interpretability Study. Small transformers trained on integer addition/subtraction, with SoRL to externalize carry/borrow circuits as explicit abstraction tokens. Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024). Paper: arXiv:2402.02619 — see Table 8 for complexity classification and Section 3 for sub-task definitions. Dataset Structure… See the full description on the dataset page: https://huggingface.co/datasets/thoughtworks/arithmetic-sorl-data.

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes116downloads
Dataset Card

Arithmetic SoRL Data

Training and evaluation data for the SoRL Arithmetic Interpretability Study.

Small transformers trained on integer addition/subtraction, with SoRL to externalize carry/borrow circuits as explicit abstraction tokens.

Reference: Quirke et al., "Understanding Addition and Subtraction in Transformers" (2024). Paper: arXiv:2402.02619 — see Table 8 for complexity classification and Section 3 for sub-task definitions.

Dataset Structure

SubfolderOperationsTrainValEval (stratified)
add_6digitaddition only500K10K~2950 (250 per S0-S6, C3-C6 + 200 random)
add_sub_6digitadd + sub500K10K~5400 (250 per split + 400 random)
add_handcraftedaddition only108
sub_handcraftedsubtraction only68

Eval Splits

All eval sets use seed=42 for reproducibility. Every model is evaluated on identical examples.

Split TypeSplitsExamples/splitDescription
Quirke cascades (add)S0-S6250Carry cascade depth 0-6
Hot carry chainsC3-C6250Carry cascades with varied answer digits (not just 0s)
Quirke cascades (sub)M0-M5250Borrow cascade depth 0-5 (M6 is impossible for 6-digit)
Hot borrow chainsB3-B5250Borrow cascades with varied answer digits (not just 9s)
Randomaddrandom, subrandom200Uniform random

Note: M6 (borrow cascade of length 6) is impossible for 6-digit subtraction — it would require 7 digit positions.

Columns

ColumnTypeDescription
tokenslist[int]Full sequence (21 tokens for 6-digit, Qwen3 tokenizer)
labelslist[str]Per-answer-digit sub-task label (SA, SC, SS, UC, US for add; MD, MB, ME, UB, UD for sub)
opstr"add" or "sub"
complexitystrQuirke complexity: S0-S6 (add) or M0-M5 (sub)
cascade_depthintMax carry/borrow cascade length
x_digitslist[int]First operand (MSB first)
y_digitslist[int]Second operand (MSB first)
z_digitslist[int]Answer (MSB first, n_digits+1)

The eval_stratified split has an additional eval_category column.

Sub-task Labels (Quirke et al. 2024)

Each answer digit requires a specific arithmetic operation. These labels follow Quirke et al. Section 3.

Addition

LabelNameConditionRole
SABase AddDn + D'n < 9, no carrySimplest case
SCMake CarryDn + D'n >= 10Generates carry
SSSum is 9Dn + D'n == 9Propagates carry if one arrives
UCUse Carrycarry_in=1, sum != 9Consumes incoming carry
USUse Sum-9carry_in=1, sum == 9Cascade: hardest case

Subtraction (x >= y)

LabelNameConditionRole
MDBase DiffDn > D'n, no borrowSimplest case
MBMake BorrowDn < D'nGenerates borrow
MEEqual digitsDn == D'nPropagates borrow if one arrives
UBUse Borrowborrow_in=1, Dn != D'nConsumes incoming borrow
UDUse Equalborrow_in=1, Dn == D'nCascade: hardest case

Complexity Classification (Quirke Table 8)

Complexity = length of longest carry/borrow cascade chain.

Example: 555555+444448=1000003 is S6 — the carry from D0 cascades through 5 consecutive sum-9 positions.

S0: no carries            ~10%
S1: isolated carries      ~50%
S2: cascade of 2          ~26%
S3: cascade of 3           ~9%
S4: cascade of 4           ~3%
S5: cascade of 5           ~1%
S6: cascade of 6          <0.5%

Data Enrichment

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.

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%.

Usage

python
from datasets import load_dataset

ds = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_6digit")
print(ds["train"][0])
# {'tokens': [...], 'labels': ['SA', 'UC', 'US', ...],
#  'complexity': 'S3', 'cascade_depth': 3, ...}

# Stratified eval
eval_ds = load_dataset("thoughtworks/arithmetic-sorl-data",
                       data_dir="add_6digit", data_files="eval_stratified.parquet")

# Addition + subtraction
ds_mixed = load_dataset("thoughtworks/arithmetic-sorl-data", data_dir="add_sub_6digit")

Related