Skip to content

Reproduce small size Transformer digit addition results #427

@lukstafi

Description

@lukstafi

Via Axis of Ordinary (Alexander Kruel)

A neat proof-of-concept paper showing that transformers can snap into a general algorithm rather than memorize examples.

A tiny transformer (~777 parameters) can learn 10-digit addition and then generalize to new numbers after a sudden “grokking” jump in performance.

They set the experiment up so the model can’t “cheat” with a trivial numeric shortcut: it never sees the operands as real numbers, only as fixed-length digit tokens in a string like 000...A+000...B=, and it must generate the sum as digits (often reversed to match carry order) one token at a time. Training examples are generated on the fly, so there isn’t a small static dataset to memorize, and success is measured on large held-out test sets of fresh random problems (including runs with ~100k independent test cases). Under those constraints, the classic “reward hacks” (like learning a single linear coefficient, exploiting a narrow validation set, or memorizing a lookup table) don’t plausibly explain the results. Anything that keeps working across that many unseen digit combinations has to capture the underlying regularity, i.e., something very close to the actual carry-based addition algorithm.

Paper: https://github.com/yhavinga/gpt-acc-jax/blob/main/latex_report/report.pdf

Update: A 456-Parameter Transformer Solves 10-Digit Addition https://github.com/yinglunz/A-456-Parameter-Transformer-Solves-10-Digit-Addition/blob/main/report.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementPriority below unlabeled

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions