Place-Value Coordinates for Numbers in Pre-Trained Language Models

Language models handle prose well and arithmetic badly. One line of work tries to fix this by changing what the model sees during training: synthetic sums, masked numbers that can be recomputed from context, spreadsheet formulas. A second line finds that the real problem is where the model looks. Ordinary self-attention cannot reliably find "the tens digit of the second number" once numbers get longer than those seen in training. The fixes for that second problem, which assign position IDs by hand to tokens that share a place value, work on clean synthetic arithmetic but have never been carried into a general pre-trained model reading ordinary text.

This note proposes a way to join the two lines. We give every digit in every number a coordinate equal to its power of ten. The ones digit gets 0, the tens digit 1, and the first decimal digit −1. This coordinate is added as a second positional signal alongside the usual sequence position. When the model generates a number, it first emits a short "exponent header" token stating the number's order of magnitude. That header fixes the coordinates of the digits that follow. The scheme needs no task-specific design: the same rule applies to a number in a news paragraph, a table cell, or a synthetic sum.

Our bet is that this one change lets an ordinary-depth model length-generalize on arithmetic embedded in text, which existing numeracy pre-training does not achieve. It would also give magnitude-aware number representations a concrete computational job, rather than only helping with "which number is bigger."

Core Claim

Existing numeracy pre-training puts arithmetic into the data and leaves the positional machinery unchanged. Our claim is that a corpus-independent place-value coordinate, together with a predicted exponent header, should let a pre-trained encoder-decoder do two things that current numeracy pre-training cannot:

  • add and subtract operands much longer than any seen in training;
  • sum more terms than seen in training, when a running-sum scratchpad is used.

It should do this while keeping its reading-comprehension ability. The new element is not the position-coupling idea itself. It is making that idea automatic and general-purpose, so it can live inside a pre-trained language model rather than a one-layer model trained on a single synthetic task. The exponent header is what connects the magnitude-grounding literature to exact digit computation.

What the Prior Work Establishes

Three data-centric pre-training methods motivate the gap.

Injecting Numerical Reasoning Skills into Language Models (GenBERT) trains BERT on synthetic expressions and template word problems with digit-level tokens. It raises DROP F1 from 49.3 to 72.3, but it degrades sharply from two to three terms and fails at four.

Arithmetic-Based Pretraining Improving Numeracy of Pretrained Language Models (ABP) does two things to BART and Flan-T5. It aligns subword and digit views of numbers with a contrastive loss, and it masks numbers that can be inferred by computation from context. This lifts Flan-T5 DROP exact match from 46.34 to 72.18, but ABP never tests longer operands.

MWP-BERT adds eight numeracy objectives for word problems.

All three keep the model's standard position encoding. That leaves them exposed to the failure documented in Limitations of Language Models in Arithmetic and Symbolic Induction. That paper shows that content-based attention loses track of which repeated digit is which. Accuracy collapses to near 0% just beyond the training length (trained on 1–5 digits, tested to 30). Only a Turing-machine-style "tutor" trace recovers it, and that trace greatly lengthens the sequence.

Two papers supply the method we generalize.

Position Coupling gives tokens with the same place value the same position ID, plus a random starting offset. With this, a 1-layer, 2-head transformer exceeds 95% exact match on 200-digit addition after training on at most 30 digits.

Arithmetic Transformers Can Length-Generalize in Both Operand Length and Count adds further levels of ID for operand identity and multiplication shifts, together with a running scratchpad. It also reports that a scratchpad alone fails to extrapolate.

Both papers constrain us in two ways. First, their ID assignments are designed by hand for each task. Second, deeper models (6 layers) extrapolate worse than 1-layer models because depth enables shortcuts, which is a direct threat to any pre-trained model. Our coordinate removes the hand design by defining IDs from the number itself (powers of ten), not from the task. We test the depth threat explicitly.

Laying Anchors is the citation that seems to contradict us. It primes rare numerals with frequent "anchor" numerals. That gives near-perfect magnitude correlation (R² = 0.99) and about 92.5% on List Minimum in the range [10⁴, 10¹⁰], yet it does not improve multi-step arithmetic. We read this as support for our design. Knowing a number's magnitude is not computing with it. Our exponent header is a magnitude signal used as an address for each digit, not as a summary vector. If headers improve magnitude probes but not arithmetic, our hypothesis is wrong in exactly the way Laying Anchors predicts.

Two delegation approaches are the main practical competitors.

  • Pre-Calc teaches small models to emit expressions for an external calculator. This raises Flan-T5 on AWPNLI from 41.56 to 80.29, but it leaves internal computation unchanged and costs some linguistic performance.
  • TaCube precomputes first-order aggregations and appends them to the input. This raises TAPEX-Large on TAT-QA from 49.6 to 66.2 F1, but it cannot compose operations such as (A + B) / C.

Research Program

The representation. Every number in input or output is tokenized into digits. Each digit receives a place-value coordinate equal to its power of ten. Non-digit tokens receive a reserved "not a digit" coordinate.

The coordinate is mapped to a learned embedding and added to the token embedding. Its index is shifted by a random offset that is shared within a training example, following Position Coupling. The ordinary relative position bias of T5 (or the absolute positions of BART) is left intact, so the model still knows word order.

Retrofitting and generation. We start from Flan-T5-base and BART-large checkpoints and initialize the new embedding table at zero, so the retrofit begins as the original model. In the decoder, each generated number is preceded by an exponent header token such as <e5>, which states the power of ten of its leading digit. The coordinates of the following digits then count down deterministically.

Because carries flow from low to high digits, we also study an internal least-significant-first output format inside a delimited number span, detokenized before evaluation. Whether the header makes forward-order generation workable is an empirical question we answer.

Pre-training mixture. We use an ABP-style "finishing school" mixture with three components:

  • ABP's inferable-number masking over text and tables;
  • a synthetic arithmetic stream in GenBERT's style, extended with multiplication, decimals, and a running-sum scratchpad for multi-term expressions;
  • ordinary span-masking language modeling, to limit forgetting.

Training uses operands of up to 10 digits and expressions of up to 5 terms. Synthetic expressions are wrapped in varied textual templates, so numbers appear at variable distances inside prose rather than in a fixed arithmetic layout.

Operand identity. The multi-level coupling paper needed an explicit "which operand" ID. We test whether the ordinary sequence position already supplies that distinction in text. As a fallback, we add a second automatically computed coordinate, the index of the number within the sentence. This keeps the whole scheme free of task-specific design.

Analysis. For each model, we record which tokens the digit queries attend to. We measure the fraction of attention mass on same-coordinate digits of the operands. This tests whether the model has actually learned place-value alignment or found a different shortcut. We repeat the study across 2-, 6-, and 12-layer variants trained from scratch on the same mixture, to see whether the coordinate removes the depth penalty reported by Position Coupling.

Baselines

Do-nothing reference. The do-nothing reference is the unmodified checkpoint (Flan-T5-base, BART-large) fine-tuned directly on each downstream task with digit tokenization. It shows how much of any gain comes from pre-training at all. Reported reference points in the file:

  • BART-large DROP exact match of 36.00 and Flan-T5 DROP exact match of 46.34 (ABP paper);
  • base BERT DROP F1 of 49.3 and ADDSUB zero-shot accuracy of 2% (GenBERT paper).

Strongest data-only pre-training methods. The strongest data-only competitor is ABP itself, with reported Flan-T5 DROP exact match of 72.18 and BART-large InfoTabs accuracy of 67.20%. GenBERT is the closest prior method that trains on synthetic arithmetic, with reported DROP F1 of 72.3 and ADDSUB zero-shot accuracy of 22.8%.

We rerun both recipes ourselves on the same backbone, with the same corpus mixture, the same number of pre-training tokens, and the same hyperparameter search budget. The only difference is the absence of the coordinate and header. Beating them means three things together:

  • matching their DROP score within noise;
  • clearly exceeding them on operands and term counts beyond the training range, where we expect both to collapse;
  • doing better on the three-and-more-term regime where GenBERT is reported to fail.

Delegation. Pre-Calc-style calculator delegation is run with the same backbone and trained on the same arithmetic stream, converted to emitted expressions. It is the strongest competitor on short-operand benchmarks. Beating it is not required on AWPNLI, where Pre-Calc reports 80.29. It is required on long-operand, long-context items, where the model must copy exact digits into the calculator call.

Isolating ablations. These ablations isolate the key ingredient:

  • coordinate without header;
  • header without coordinate (a pure magnitude signal, analogous to exponent embeddings);
  • shuffled coordinates that preserve which tokens are digits but destroy place value;
  • the fallback operand-index coordinate on and off.

The shuffled-coordinate ablation matters most. If it performs as well as the true coordinate, the gain comes from marking digits, not from aligning them.

Upper bound. For synthetic tasks, a 1-layer Position Coupling model with hand-designed IDs gives the ceiling. It is reported at above 95% exact match on 200-digit addition from training on 30 or fewer digits.

Why not just…?

Why not just call a calculator? Delegation is the real threat on short-number benchmarks, and we expect it to win or tie there. The argument against it as a complete answer is that the operands still have to be found and copied exactly. Limitations of Language Models in Arithmetic and Symbolic Induction found that models calling an add() program still fail at this locating step for long inputs. Pre-Calc reports that division makes up about 60% of its residual errors and that linguistic tasks degrade. Our long-operand-in-text evaluation measures operand-copy accuracy for the delegation baseline separately from final-answer accuracy. If delegation copies 30-digit operands perfectly, our case narrows to settings where tools are unavailable, and we will say so. The two approaches are also complementary: a model with place-value coordinates should be a better calculator caller, and we test that combination.

Why not just precompute the candidate answers, as TaCube does? TaCube is restricted to first-order operations and covers about 70% of numerical questions. Composed operations blow up the candidate set. We include a compositional slice, two-step expressions over table cells, where the precomputed cube cannot contain the answer by construction.

Why not just use digit tokens plus a scratchpad? This is the cheapest alternative. GenBERT already uses digit tokens. Arithmetic Transformers Can Length-Generalize reports that a scratchpad combined with a strong relative position scheme still fails to extrapolate without coupling. However, that evidence comes from small synthetic models, not pre-trained ones. Our design therefore includes digit tokens with the running-sum scratchpad and without the coordinate as a full baseline, and the shuffled-coordinate ablation as well. If this baseline extrapolates in a 12-layer pre-trained model, the coordinate is unnecessary and the paper becomes a negative result about it.

Why not just scale up? The file reports that GPT-3 collapses on long addition out of distribution (Limitations of Language Models in Arithmetic and Symbolic Induction). It also reports that 355M-parameter numerically fine-tuned models beat GPT-3.5-Turbo on QuanTemp, while depth itself hurts extrapolation in coupling studies. We do not train large models. Our depth sweep tests directly whether added layers help or hurt under the coordinate.

Decisive Experiments

Experiment 1: length and term-count extrapolation inside text. Expressions are embedded in prose templates, with training up to 10 digits and 5 terms. Testing goes to 50 digits and 15 terms, under both integer and decimal operands. Metric is exact match.

The decisive outcome:

  • ABP and GenBERT reruns fall toward the near-zero out-of-distribution collapse reported for standard encodings;
  • our model stays high at 2–3× the training length;
  • the shuffled-coordinate ablation does not.

Experiment 2: downstream transfer. We evaluate on:

  • DROP, with exact match and F1, against ABP's 72.18 exact match and GenBERT's 72.3 F1;
  • InfoTabs, against ABP's 67.20%;
  • ADDSUB zero-shot, against GenBERT's 22.8%;
  • TAT-QA, against TaCube with TAPEX-Large at 66.2 F1, as an external reference.

We also build a stress split of DROP and TAT-QA in which numbers in the passages are rescaled to much longer digit strings while the answers are recomputed. This split is where standard positions should break and ours should not.

Experiment 3: whether magnitude helps computation. We run List Minimum in [10⁴, 10¹⁰], with ln Anchors reported at about 92.5% and GenBERT at 86%, plus a magnitude regression probe. Comparing header-only and header-plus-coordinate models settles whether magnitude grounding contributes to exact arithmetic or, as Laying Anchors found, only to ordering.

Experiment 4: forgetting. We fine-tune on SQuAD and generate on WikiBio, comparing against the unmodified checkpoint. The file has no reported numeric result on Lacuna for either benchmark under these methods, so we report our own paired baselines.

Experiment 5: depth sweep. The 2/6/12-layer from-scratch sweep, with the attention-alignment analysis, tells us whether the place-value coordinate fixes the depth shortcut problem or only works in shallow models.