TL;DR
Language models struggle with numerical representation due to subword tokenization. This paper demonstrates that simply changing how numbers are tokenized, specifically by grouping them on a log-scaled number line, achieves near state-of-the-art performance on number estimation tasks. This "vocabulary change" approach is surprisingly effective and requires no architectural modifications to the language model, making numeracy more accessible.
What Problem Does This Paper Address?
Modern language models (LMs) treat numbers like any other word, breaking them down into subword tokens. For example, the number 600 might become "6" and "##00". This arbitrary splitting prevents the model from understanding the numerical relationships between numbers, such as 600 being close to 800. This deficiency limits LMs' ability to grasp numerical concepts, impacting tasks that require even basic numerical understanding. While previous work has explored modifying the notation (e.g., scientific vs. decimal), the model's vocabulary, or the model's architecture itself, this paper investigates a more straightforward approach: improving the vocabulary representation of numbers.
Methods
The authors explore three main categories of methods to improve number representation in LMs:
- Notation Change: This involves altering the way numbers are written before tokenization, such as using scientific notation (e.g., 6e2) or splitting numbers into individual digits (e.g., 600 becomes "6", "0", "0").
- Vocabulary Change: This is the core contribution. Instead of arbitrary subword splitting, numbers are grouped into discrete bins based on their position on a log-scaled number line. For instance, a range of numbers like 100-1000 might be represented by a single token. The paper compares two variants: Vocab-AM (using arithmetic mean for binning) and Vocab-GM (using geometric mean).
- Architecture Change: This involves modifying the LM's architecture to directly predict continuous numerical values. The paper compares against a state-of-the-art method called DExp (Discrete Latent Exponents).
The primary task for evaluation is masked number prediction (MNP), where the model predicts a masked number in a sentence.
Datasets
The experiments were conducted on three datasets:
- Financial News Articles (FinNews): A general dataset of financial news.
- FinNews-$: A subset of FinNews focusing on price-based numbers.
- Scientific Articles (SciDocs): A dataset of scientific articles.
All datasets contain numbers ranging from 1 to $10^{16}$. The downstream task of numerical fact estimation used the Fermi Problems dataset.
Key Insights and Ideas
- Vocabulary is King (for approximation): The most surprising finding is that simply changing the vocabulary to group numbers on a log-scaled number line (Vocabulary Change) performs nearly as well as, and sometimes better than, complex architectural changes (Architecture Change) for approximate number estimation.
- Notation Changes are Insufficient: Altering the notation (e.g., scientific or digit-based) alone does not significantly improve performance and can even be worse than the standard subword approach.
- Simplicity Wins: The vocabulary change method is easy to implement and requires no pretraining or architectural modifications, making it highly practical for improving LM numeracy.
- Logarithmic Scale is Natural: The success of log-scaled binning suggests that LMs can effectively learn numerical relationships when numbers are presented in a way that aligns with human intuition about magnitudes.
- Architecture Gains are Overstated (for approximation): The paper challenges the notion that significant architectural changes are necessary for LMs to gain approximate numerical understanding.
Key Results
- On the masked number prediction task, the vocabulary change methods (Vocab-AM/GM) achieved performance comparable to or better than the state-of-the-art DExp (architecture change) across all datasets. For example, on FinNews, Vocab-AM achieved an E-Acc of 74.4% and LogMAE of 0.65, while DExp achieved 74.6% and 0.50 respectively.
- Notation change methods performed worse than the standard subword baseline.
- In the downstream task of numerical fact estimation (Fermi Problems), vocabulary change methods also showed similar or better performance than architectural changes, demonstrating their generalization ability.
- The paper highlights that the gains from architectural changes can be largely retained by simply tokenizing numbers in log space.
Limitations and Future Work
- Approximate vs. Exact Numeracy: The authors acknowledge that their vocabulary-based approach is lossy and collapses numbers into bins, making it unsuitable for tasks requiring exact arithmetic. They note that an ideal number representation should capture both approximate and exact numeracy.
- Generalizability Beyond English/Hindu-Arabic: The findings may not directly apply to other language or number systems, and the authors encourage further research in this direction.
- Variable Length Binning: While exploring variable length binning based on corpus frequency, the results did not show significant improvements over the simpler, fixed log-scaled bins, suggesting the robustness of the latter.
- Neuron Probing: The paper includes an analysis of individual neurons in language models that can predict numerical magnitudes, suggesting that the learned representations are indeed capturing this information, further supporting the vocabulary-based approach. Future work could involve interventions to update model beliefs based on these findings.
Summary updated