NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Don’t Learn What You Can Compute: Arithmetic Residual Blocks for Exact Arithmetic in Transformers

Eric GilersonNeurIPS 2026

TL;DR

Instead of forcing language models to waste precious weights approximating carrying and long division, this paper embeds a frozen, exact arithmetic circuit directly inside the transformer’s forward pass. By offloading deterministic math to an "Arithmetic Residual Block" (ARB), a small learned interface can translate exact results into tokens with near-perfect accuracy while freeing up the model's capacity to learn other things faster and without interference.

What Problem Does This Paper Address?

Asking a standard language model to multiply three-digit numbers is a bit like asking a poet to do taxes by intuition alone. Carrying, borrowing, and multi-digit dependencies are notoriously awkward for next-token predictors to approximate in learned weights.

Currently, builders face two main choices: hope the model memorizes enough arithmetic patterns in its weights, or teach it to pause generation and call an external calculator tool (like Toolformer). This paper explores a third architectural path: Don’t Learn What You Can Compute. What if deterministic, bounded math lived natively inside a single forward pass—giving the model exact answers on tap without leaving the tensor stream?

Methods

The author introduces the Arithmetic Residual Block (ARB), which pairs a strict, frozen mathematical core with a lightweight learned translator.

Figure 1: ARB components. Blue is frozen and orange is learned. Invalid inputs bypass all ARB- specific learned paths.
  1. Guarded Contract: A token-level detector watches the end of the prompt for valid expressions (a op b =) covering addition, non-negative subtraction, multiplication, and exact division within a bounded integer range. If the text is ordinary prose, malformed, or out-of-bounds (like dividing by zero), ARB stays completely dormant.
  2. Frozen Residue-Number Core: Instead of standard binary logic, valid operands are mapped into a Residue Number System (RNS) using six coprime primes $\{7, 11, 13, 17, 19, 23\}$, covering integers up to $7,436,429$. Residues are encoded onto unit circles via $(\cos(2\pi r/p), \sin(2\pi r/p))$, turning modular addition and subtraction into simple complex rotations, while multiplication and division use tiny frozen lookup tables. The Chinese Remainder Theorem (CRT) reconstructs the exact integer and breaks it into decimal digits—all in standard tensor ops with zero learned arithmetic weights.
  3. Learned Interface: A tiny MLP injects the fixed result representation (plus the current answer-digit position) into the transformer's residual stream at middle and final layers, paired with an answer-gated LoRA adapter on the language-model output head to steer logits toward the right digits.

Datasets

  • Synthetic Arithmetic Suites: 250,000 generated 1–3 digit expressions for retrofitting a frozen 360M model, evaluated on a balanced 36,000-example test set ( plus targeted edge-case suites for prime-multiple division).
  • Mixed Pretraining Corpus: A blend of FineWeb-Edu passages (75%), direct equations (15%), and instruction-prefixed equations (10%) used to train 20M-parameter transformers from scratch.
  • Synthetic Associative Memory: 40,000 opaque key–value fact pairs (e.g., <factkeyba><factkeyde><factmap><factvalueco>) paired with 2-digit arithmetic to test memory competition.
  • Containment Benchmarks: WikiText-103 (256 documents) and SWE-bench Lite (100 code patches) to verify the gate doesn't misfire on normal text or code.

Key Insights and Ideas

  • Translating math into tokens takes shockingly few parameters: You don't need a massive adapter to read out the frozen core. Shrinking the output-head LoRA all the way down to rank 1 (just 305,602 total interface parameters) still hits 99.89% exact match.
  • Exact primitives coexist peacefully with pretraining: Training a model from scratch with ARB inside doesn't degrade its ability to model ordinary English text, and the model generalizes effortlessly to unseen instruction phrasings.
  • Offloading computation reduces task interference: When a small model has to maintain arithmetic skills in its weights while memorizing 40,000 arbitrary facts, its math accuracy degrades and early fact-learning slows down. Keeping math in a frozen block eliminates arithmetic forgetting and speeds up early fact acquisition.

Key Results

  • Retrofitting a Frozen Model: Attached to a frozen SmolLM2-360M, ARB jumps from 4.56% to 99.95% exact match across 36,000 expressions (including 99.7% vs. 0.0% on $3 \times 3$ multiplication). The 17 total errors mostly happen on later digits, pointing to minor autoregressive readout hiccups rather than math errors.
Table 1: Frozen SmolLM2-360M exact match (%). Entries are ARB/base; every cell has 1,000 examples.
  • Training from Scratch (20M Models): ARB achieves 97.7% direct accuracy and 99.0% on held-out instruction templates, crushing an equally sized learned-arithmetic baseline (19.0% and 37.0%), while matching held-out FineWeb-Edu text loss (NLL of 3.13381 vs. 3.13463).
Table 6: End-to-end 20M training from random initialization: mean across three 25k-step seeds. “Text NLL” is next-token loss on held-out FineWeb-Edu passages (lower is better). Contextual evaluation supplies an equation after a textual prefix.
  • Containment & Runtime: Zero false triggers occurred across WikiText-103 and SWE-bench Lite. In an eager PyTorch prototype on an A100, active ARB adds 12.4% latency (+25.2 ms across 96 equations, only 4.0 ms of which is the RNS math step) and +2.1% overhead on non-triggering prose.

Limitations and Future Work

ARB intentionally solves a narrow slice of the puzzle: supplied, single-step bounded integer equations. It does not handle negative results, decimals/fractions, multi-step nested expressions, or word problems where the model must formulate the equation itself. Furthermore, its trigger is purely syntactic—meaning if a user quotes a false statement like "2+2=5", the detector sees 2+2= and activates anyway—and relies on tokenizers having clean digit/operator tokens.

For future work, the author suggests training larger models to actively write their own equations mid-response (learning when to invoke the block), expanding the parser to signed/rational numbers and compound expressions, and writing fused GPU kernels to eliminate the Python/PyTorch routing overhead.

Summary updated

Abstract

Language models typically approximate arithmetic through learned weights, even when an exact computation is available. We introduce Arithmetic Residual Blocks (ARBs), which recognize a supported terminal equation, compute its bounded integer result with a frozen residue-number core, and expose that result inside a transformer's forward pass through a small learned residual/output interface. On a frozen SmolLM2-360M model, ARB reaches 99.95\% exact match on 36,000 supplied 1--3-digit expressions, versus 4.56\% for the unmodified model. The interface remains near ceiling at rank one (99.89\% with 305,602 learned parameters, versus 1.86M at rank 32). We next train two equally sized 20M decoders from random initialization on a mixture of ordinary text and equations: the ARB model reaches 97.7\% supplied-equation accuracy versus 19.0\% for the learned-arithmetic baseline, with essentially the same held-out ordinary-text NLL. Finally, a five-seed staged experiment shows that keeping arithmetic exact lets a model retain it while acquiring 40,000 unrelated key--value associations. ARB therefore provides a concrete in-forward computation primitive, evidence that it integrates with language-model training, and a controlled first measurement of reduced task interference.
BibTeX
@inproceedings{gilerson2026dont,
  author = {Eric Gilerson},
  title = {{Don’t Learn What You Can Compute: Arithmetic Residual Blocks for Exact Arithmetic in Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=HkTpQ00UDJ},
}
Figure