An Empirical Investigation of Contextualized Number Prediction

Taylor Berg-Kirkpatrick, Daniel Spokoyny

Introduction

While modern Large Language Models (LLMs) demonstrate remarkable linguistic capabilities, they often exhibit a fundamental "numbness" regarding numerical data. Standard architectures like BERT typically treat numbers as discrete tokens, failing to capture their underlying magnitudes or the mathematical relationships inherent in textual context. In the paper "An Empirical Investigation of Contextualized Number Prediction," researchers Daniel Spokoyny and Taylor Berg-Kirkpatrick propose a shift in perspective: treating number prediction not as a classification task, but as a regression problem over the real number line, conditioned on bidirectional textual context.

Problem Statement: The Complexity of Numbers in Text

Most NLP research treats numbers as either unrelated categories or simple order-of-magnitude classifications. However, numerical values in natural language are characterized by being heavy-tailed, asymmetric, and multi-modal. For instance, in a financial context, a missing value for revenue might reasonably be 2, 5, or 20 billion, but is highly unlikely to be 0.0001 or 1,000,000. Existing models struggle to represent this uncertainty and the specific real-world constraints that text imposes on numerical values.

Methodology

The authors introduce the Masked Number Prediction (MNM) task, analogous to BERT’s masked language modeling but specifically targeting numerical tokens.

Model Architecture

The framework combines contextualized encoders with specialized output distributions designed for numerical data.

Overview of the Masked Number Prediction architecture, showing the flow from input sentence to the predicted numerical distribution.

The pipeline involves several key components:

  1. Input Representation: Beyond standard word-piece embeddings, the authors experiment with Digit-RNNs and explicit Exponent Embeddings to capture magnitude.
  2. Contextual Encoders: A comparison between BiGRU (recurrent) and pretrained BERT (transformer) architectures to determine which better extracts numerical "clues" from surrounding text.
  3. Output Distributions: The core contribution involves novel real-valued distributions:
  4. Flow-transformed Laplace (FlowLP): Uses a parameterized "flow" to warp a base distribution into a flexible, log-shaped one.
  5. Discrete Latent Exponent (DExp): The most successful approach, using a discrete latent variable to select an exponent (e.g., $10^2$ vs $10^6$) and a truncated Gaussian to predict the mantissa. This allows for multi-modal predictions, enabling the model to "hedge its bets" across different orders of magnitude.

Datasets

Evaluation was conducted across three distinct corpora to test various numerical contexts:

  • FinNews: Over 300,000 financial news articles rich in ratios and quantities.
  • FinNews-$: A subset focused exclusively on dollar amounts to test domain-specific volatility.
  • Sci: 24,000 scientific papers from the S2ORC dataset, where numerical precision is paramount.

Key Results and Insights

The experimental results highlight the superiority of the BERT-DExp model across various metrics, including Log-Mean Absolute Error (LMAE) and Exponent Accuracy (E-Acc).

Comparison of model performance across metrics like LMAE, Exponent Accuracy (E-Acc), and Anomaly Detection AUC (r-AUC, s-AUC).

Major Findings

  • Multi-modality is Essential: Numbers in text are rarely unimodal. The DExp model's ability to represent distinct probability "peaks" allowed it to significantly outperform "Flow" models that tend to average out predictions. On the FinNews dataset, BERT-DExp achieved an Exponent Accuracy of 74.6%.
  • BERT as an "Accountant": Pretrained BERT models proved far more effective at extracting relevant context for number prediction than BiGRUs trained from scratch, despite not being specifically designed for mathematical tasks.
  • Contextual Dependency: Through "All-Numbers-Masked" tests, the authors demonstrated that models actively use other quantities in the text to inform their predictions. Masking related numerical values significantly degraded performance on the target prediction.
  • Anomaly Detection: The BERT-DExp model achieved an AUC of 0.86 in Numerical Anomaly Detection (NAD), effectively identifying "typos" and random value swaps.

Conclusion

By transitioning numerical representation from discrete tokens to continuous distributions, this research provides a robust framework for enhancing LLMs' understanding of data. The success of the DExp model suggests that capturing the multi-modal nature of numbers is key to bridging the gap between linguistic fluency and numerical reasoning.

Summary updated

BibTeX
@inproceedings{bergkirkpatrick2020empirical,
  author = {Taylor Berg-Kirkpatrick and Daniel Spokoyny},
  title = {{An Empirical Investigation of Contextualized Number Prediction}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.385},
}
Figure