Arithmetic-Based Pretraining Improving Numeracy of Pretrained Language Models

Dominic Petrak, Nafise Sadat Moosavi, Iryna Gurevych

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language understanding and generation. However, their performance often falters when faced with tasks requiring basic arithmetic and numerical reasoning. Standard pretraining objectives, such as next-token prediction, prioritize linguistic structure over logical computation. To address this, researchers have introduced Arithmetic-Based Pretraining (ABP), a lightweight extended pretraining method designed to enhance the numeracy of existing models like BART and T5 without requiring architectural changes or full retraining.

The Challenges of LLM Numeracy

The authors identify two primary obstacles to numerical reasoning in standard LLMs:

  1. The Tokenization Trap: Algorithms like Byte Pair Encoding (BPE) often fragment numbers inconsistently based on frequency rather than value. For instance, 0.72 might be tokenized as [0, ., 72], while 0.73 becomes [0, ., 7, 3]. This prevents the model from learning a coherent internal representation of numerical magnitude.
  2. The Objective Gap: Standard denoising or language modeling tasks do not explicitly require mathematical operations. A model might learn that a specific context requires a number, but it lacks the mechanism to derive that number through calculation.

Methodology: Arithmetic-Based Pretraining (ABP)

ABP serves as a "finishing school" for numeracy through two core components:

Contrastive Learning for Numbers

To mitigate tokenization issues, the model is trained using a contrastive loss. It is presented with numbers in two formats: character-level (e.g., 1, 0, 8, ., 8, 9) and standard subword chunks. The model is forced to map both representations to similar points in its embedding space, ensuring that the underlying numerical value is preserved regardless of the string format.

Inferable Number Prediction (INP)

INP is a specialized denoising task where a number is masked in a sentence only if it can be logically inferred from the surrounding context or an associated table. To correctly predict the masked value, the model must perform operations such as addition, subtraction, multiplication, division, or sorting.

Experimental Setup

The effectiveness of ABP was evaluated across four diverse datasets:

  • DROP: A reading comprehension benchmark where ~60% of questions require discrete numerical reasoning.
  • InfoTabs: A dataset for natural language inference based on semi-structured tables.
  • SciGen: A task for generating descriptions of scientific tables, requiring complex arithmetic.
  • WikiBio: Table-to-text generation for biographical data, used to ensure the model retains its ability to handle non-arithmetic factual data.

Key Results

The application of ABP led to significant performance improvements across all tested models and benchmarks.

Performance comparison on the DROP benchmark showing significant gains for BART and Flan-T5 models using ABP.

On the DROP benchmark, BART-large’s Exact Match (EM) score improved from 36.00 to 45.60. The most dramatic gain was observed in Flan-T5, where the EM score surged from 46.34 to 72.18. Similarly, on the InfoTabs in-domain test set, BART-large’s accuracy more than doubled, increasing from 33.30 to 67.20. Human evaluations further indicated that ABP-trained models produced more factually correct descriptions of data with fewer numerical hallucinations.

Analysis: Transferability of Numeracy

A significant finding of the study is that numerical reasoning skills are transferable across domains. Pretraining on scientific tables (SciGen) was found to improve performance on general reading comprehension (DROP).

Transfer learning results demonstrating that pretraining on one domain (e.g., SciGen) can enhance performance on others (e.g., DROP).

As shown in the transfer analysis, training on SciGen and then testing on DROP actually yielded a higher EM score (47.70) than training on DROP's own in-domain data (45.60). This suggests that ABP helps models learn generalizable numerical logic rather than dataset-specific patterns.

Limitations and Future Work

Despite its success, ABP faces several challenges. Hardware constraints limited the testing of the largest T5 variants and restricted batch sizes for contrastive learning. Additionally, the 1024-token sequence limit of models like BART can lead to information loss when processing large tables. Finally, while performance is improved, the internal "reasoning steps" of the model remain opaque. Future research could focus on making these numerical computations more interpretable and scaling the method to even larger models.

Summary updated

BibTeX
@inproceedings{petrak2023arithmetic,
  author = {Dominic Petrak and Nafise Sadat Moosavi and Iryna Gurevych},
  title = {{Arithmetic-Based Pretraining Improving Numeracy of Pretrained Language Models}},
  booktitle = {SEM @ ACL},
  year = {2023},
  doi = {10.18653/v1/2023.starsem-1.42},
}
Figure