Abstract
Standard language models often struggle with numerical magnitude, treating numbers as arbitrary subword tokens. This paper investigates whether improving a model's "numeracy"—its understanding of numerical values—enhances its general "literacy" or word-prediction capabilities. By evaluating various number encoding strategies, including a novel "exponent embedding" approach, the authors demonstrate that magnitude awareness significantly improves performance in Masked Word Prediction (MWP) tasks across multiple datasets, even in sentences devoid of numbers.
Introduction
While numbers constitute over 6% of English Wikipedia, standard Natural Language Processing (NLP) models treat them poorly. Most tokenizers split numbers into arbitrary subword chunks (e.g., "4500" might become "45" and "00"), and models like BERT often treat numbers as individual, unrelated tokens.
The core issue is a lack of magnitude awareness. A standard model doesn't inherently "know" that 10,000 is much larger than 100. Consequently, it struggles with context: it might predict that a "statue" weighs 100 lbs and also predict it weighs 10,000 lbs, failing to realize that the change in magnitude should fundamentally change the likely subject of the sentence. The authors investigate whether improving a model's numeracy actually improves its general word-prediction capabilities.
Methods
The researchers operationalized "literacy" as the task of Masked Word Prediction (MWP). They compared a standard BERT baseline against models equipped with six different number encoding strategies:
- Default (Baseline): Standard subword tokenization.
- None: Removing all numbers to test if they were just noise.
- Num: Replacing every number with a single
[NUM]token. - Value Embeddings: Projecting the scalar magnitude of a number into a vector space.
- LogValue Embeddings: Projecting the log-scaled magnitude.
- Exponent Embeddings (The Winner): Representing numbers using a scientific notation-like approach (e.g., $3.29 \times 10^2$) and binning them on a log scale. This allows the model to learn specific embeddings for different "orders of magnitude."
The authors kept the base transformer weights frozen and only trained the masked language modeling (MLM) classifier and the new number encoders.
Datasets
The study utilized three primary datasets:
- Wiki-Convert: A novel benchmark containing over 900,000 sentences extracted from Wikipedia using the
{{Convert}}template, ensuring numbers represent actual measurements. - Numeracy600K: A dataset of financial market comments used to test models in a domain-specific context.
- Wikicorpus: A collection of sentences without annotated numbers, used to test if numeracy benefits generalize to purely textual contexts.
Key Insights and Ideas
- Numeracy → Literacy: There is a direct, positive transfer from numerical understanding to word prediction. When a model understands that "10,000 lbs" is heavy, it is more likely to predict "car" instead of "statue."
- Magnitude as Context: Numbers provide a unique form of grounding. By understanding the scale of a measurement, the model can narrow down the semantic space of missing words.
- The "Halo Effect": Surprisingly, the benefits of numeracy-aware training persist even in sentences that do not contain numbers. This suggests the model learns better overall semantic associations between concepts and their typical physical scales during training.
- Exponent Embeddings are Superior: Treating numbers as log-scaled bins outperformed linear projections, aligning with cognitive science research suggesting the human brain perceives numbers on a logarithmic scale.
Key Results
On the Wiki-Convert dataset, the Exponent model achieved a Hit@1 accuracy of 66.15%, a significant improvement over the BERT baseline's 65.57%. In the financial domain (Numeracy600K), the Exponent model reduced perplexity from 5.07 to 4.63, indicating much higher confidence in its word predictions. Qualitatively, when weight in a sentence changes from 100 lbs to 10,000 lbs, the numerate model correctly updates its prediction from "bomb" to "car," whereas the standard BERT model predicts "statue" for both.
Conclusion and Future Work
This study demonstrates that numeracy is a vital component of linguistic understanding. Future work may involve training numerate language models from scratch on massive corpora, exploring non-English numeral systems, and developing data-driven binning for historical or nominal ranges (e.g., identifying "1939-1945" as a specific era).
Summary updated