Ajay0728's picture
Add dataset card
df2dcff verified
|
Raw History Blame Contribute Delete
6.11 kB
metadata
license: apache-2.0
task_categories:
  - text-generation
tags:
  - arithmetic
  - compositional-generalization
  - length-generalization
  - synthetic
size_categories:
  - 10K<n<100K
configs:
  - config_name: study1
    field: data
    data_files:
      - split: train
        path: study1/train.json
      - split: validation
        path: study1/val.json
      - split: test
        path: study1/test.json
      - split: ood_ops4
        path: study1/ood_ops4.json
      - split: ood_ops5
        path: study1/ood_ops5.json
      - split: ood_ops6
        path: study1/ood_ops6.json
      - split: ood_ops7
        path: study1/ood_ops7.json
  - config_name: study2
    field: data
    data_files:
      - split: train
        path: study2/train.json
      - split: validation
        path: study2/val.json
      - split: test
        path: study2/test.json
      - split: ood
        path: study2/ood.json

Compositional Reasoning on Arithmetic: Datasets (v2)

These are synthetic arithmetic datasets for testing whether sequence-to-sequence models generalize to longer expressions (Study 1) and more deeply nested ones (Study 2). They were used in the paper Partial Competence and Limited Transfer: Comparing LSTM and Transformer Generalization on Arithmetic Expressions (arXiv ID pending).

Each example is a fully parenthesized integer expression paired with its value:

input:  (((15 - 3) + 10) + (17 * 20))
output: 362

Studies and splits

Study 1: length generalization. Models train on 2–3 operations and are tested on 4–7.

Split File Size Expressions
train study1/train.json 8,000 2 ops depth 2, 3 ops depth 2, 3 ops depth 3 chain (one third each)
validation study1/val.json 1,000 same mix as train
test study1/test.json 1,000 same mix as train
ood_ops4 study1/ood_ops4.json 1,000 4 ops, depth 3, balanced
ood_ops5 study1/ood_ops5.json 1,000 5 ops, depth 3, balanced
ood_ops6 study1/ood_ops6.json 1,000 6 ops, depth 3, balanced
ood_ops7 study1/ood_ops7.json 1,000 7 ops, depth 3, balanced

Study 2: depth generalization. The number of operations stays at 3 while nesting depth goes from 2 to 3.

Split File Size Expressions
train study2/train.json 8,000 3 ops, depth 2, balanced
validation study2/val.json 1,000 3 ops, depth 2, balanced
test study2/test.json 1,000 3 ops, depth 2, balanced
ood study2/ood.json 1,000 3 ops, depth 3, chain

Each split was generated with its own random seed. The test splits were generated after the models were trained, from generator commit f636492, so they were never used for model selection. Every other split comes from commit f504457.

Usage

from datasets import load_dataset

s1 = load_dataset("Ajay0728/Compositional-reasoning-arithmetic-datasets", "study1")
print(s1["train"][0]["input"], "->", s1["train"][0]["output"])
ood7 = load_dataset("Ajay0728/Compositional-reasoning-arithmetic-datasets", "study1", split="ood_ops7")

You can also download the raw JSON files directly. Each file is a JSON object with the examples under "data" and the generation metadata in the other top-level keys.

Fields

Each example has these fields:

Field Type Description
input string Model input: the fully parenthesized expression, with spaces around operators
output string Target: the integer result as a string
expression string Same as input
result int Integer value of the expression
num_operations int Number of binary operators
depth int Depth of the expression tree
intermediate_max int Largest absolute intermediate value during evaluation
operator_counts dict Count of each of + - * /
seed_id int Index of the generator seed this example came from

Each file also has these top-level metadata keys:

  • study, split, seed, generator_commit, timestamp
  • buckets: the operation count, depth, tree shape and rejection rate for each group of expressions
  • operator_distribution_actual: how often each operator actually appears

How the data was generated

Each expression is built as a random binary expression tree with a target operation count, depth, and shape. A shape is either balanced or chain, where a chain nests to one side only. Candidates are rejected unless:

  • every division is exact (integer result, no remainder, no division by zero)
  • the final result satisfies |result| ≤ 10,000

All inputs are at most 51 characters long. Outputs are at most 6 characters (e.g. -10000).

Operator balance: division is rare in every split, about 3–5% of operators, because the exact-division requirement rejects most division candidates. The other three operators make up roughly 28–35% each. Results broken down by operator, especially for division, should account for these small counts.

Integrity

CHECKSUMS.txt lists the SHA-256 hash of each file. Its paths start with datasets_v2/, so to verify, put the files in a folder named datasets_v2 and run shasum -a 256 -c CHECKSUMS.txt from that folder's parent.

Superseded version

An earlier version of these datasets, datasets/ in the GitHub repo, was used with an evaluation path that silently cut inputs to 20 characters. Results from that version are retired. This v2 release is the one used for every number reported in the paper.

Citation

@misc{jamanjyothi2026partial,
  title  = {Partial Competence and Limited Transfer: Comparing LSTM and Transformer
            Generalization on Arithmetic Expressions},
  author = {Jamanjyothi, Ajay},
  year   = {2026},
  note   = {arXiv preprint (ID pending)}
}