"""Regenerates data/arithmetic-14k.jsonl exactly (14,000 items = 7 types x 2,000, fixed seeds). python3 scripts/make_arithmetic_14k.py out.jsonl (needs numpy; RandomState(seed).randint is stable across numpy versions)""" import json, sys import numpy as np SPECS = [("2da", 2, "+", 101), ("2ds", 2, "-", 102), ("3da", 3, "+", 103), ("3ds", 3, "-", 104), ("4da", 4, "+", 105), ("5da", 5, "+", 106), ("2dm", 2, "*", 107)] NAMES = {"+": "addition", "-": "subtraction", "*": "multiplication"} def items(): n = 0 for tag, digits, op, seed in SPECS: rng = np.random.RandomState(seed); lo, hi = 10 ** (digits - 1), 10 ** digits - 1 for k in range(2000): x, y = int(rng.randint(lo, hi + 1)), int(rng.randint(lo, hi + 1)) if op == "-" and y > x: x, y = y, x # subtraction never goes negative z = x + y if op == "+" else (x - y if op == "-" else x * y) yield {"id": f"{tag}-{k:04d}", "type": tag, "operation": NAMES[op], "digits": digits, "a": x, "operator": op, "b": y, "question": f"What is {x} {op} {y}?", "answer": str(z)} n += 1 if __name__ == "__main__": with open(sys.argv[1], "w") as f: for it in items(): f.write(json.dumps(it) + "\n")