An Empirical Investigation of Contextualized Number Prediction

Daniel Spokoyny, Taylor Berg-Kirkpatrick · OpenReview

TL;DR

This paper tackles the challenge of accurately predicting and detecting numerical values within text, going beyond standard language modeling. They introduce novel output distributions that better capture the complex nature of real-world numbers and demonstrate that these, combined with powerful transformer encoders, significantly improve performance on both masked number prediction and anomaly detection tasks.

What Problem Does This Paper Address?

While large language models (LLMs) have revolutionized natural language processing, accurately understanding and generating numerical information within text remains a significant challenge. Standard LLMs often treat numbers as just another token, failing to capture their inherent properties like magnitude, scale, and distribution. This limitation hinders their effectiveness in domains rich with numerical data, such as finance and scientific literature, and can lead to errors in tasks like question answering or fact-checking. This paper addresses this by focusing specifically on "contextualized number prediction," aiming to build models that can predict missing numbers and identify erroneous ones within their textual context.

Methods

The authors propose a framework for contextualized number prediction that combines three key components:

  1. Input Representation: They experiment with different ways to represent numerical tokens. Beyond standard wordpiece embeddings and positional embeddings, they introduce a dedicated "numeric value embedding" to help models learn better numerical representations. They also explore "digit-RNN embedding" (encoding numbers as strings in scientific notation) and "exponent embedding" (learning embeddings for base-10 exponents).
  2. Contextual Encoder: They utilize two main encoder architectures:
  3. Transformer Encoder: Leveraging the power of pre-trained BERT (12-layer BERT-base), which excels at capturing contextual information.
  4. BiGRU Encoder: A bidirectional Gated Recurrent Unit, known for its effectiveness in sequence modeling tasks.
  5. Real-valued Output Distributions: This is a core contribution. Recognizing that simple continuous distributions (like Gaussian) are insufficient for real-world numbers (which are often heavy-tailed, asymmetric, or multi-modal), they propose several novel distributions:
  6. Log Laplace (LogLP): A transformed Laplace distribution that models the log of the number.
  7. Flow-transformed Laplace (FlowLP): A more flexible version of LogLP using a parameterized flow to better capture the distribution.
  8. Discrete Exponent (DExp): A mixture model that predicts the exponent using a multinomial distribution and the mantissa using a truncated Gaussian. This is a key innovation for handling multi-modal distributions.
  9. Gaussian Mixture Model (GMM): A standard approach for multi-modal distributions, used as a baseline.

The overall model predicts the probability of a numerical value $y$ given the context $X$, denoted as $P(y|X; \theta, \gamma)$, where $\gamma$ are encoder parameters and $\theta$ are output distribution parameters.

Datasets

The paper evaluates their models on two primary datasets:

  • FinNews: A collection of financial news and blog articles, providing a rich source of numerical data like ratios, quantities, and percentages.
  • Sci: A subset of the S2ORC dataset, comprising academic papers, offering diverse scientific and measurement quantities.

They also create a subset called FinNews-$ which specifically focuses on dollar quantities within financial news to test the model's ability to handle a more specific numerical type.

Key Insights and Ideas

  • Numbers are Special: The research strongly suggests that treating numbers as mere tokens is suboptimal. Dedicated numerical representations and specialized output distributions are crucial for accurate prediction and anomaly detection.
  • Multi-modality Matters: Real-world numerical data often exhibits multi-modal distributions (e.g., dates clustering around specific values, financial figures having different typical ranges). Models that can capture this multi-modality, like DExp, significantly outperform unimodal distributions.
  • Transformers Reign Supreme: Pre-trained transformer architectures (like BERT) provide superior contextual representations compared to recurrent networks (BiGRU), leading to better performance across the board.
  • Discrete Latent Variables are Powerful: The DExp model, which uses a discrete latent variable for the exponent, emerges as the best-performing approach, highlighting the effectiveness of this strategy for numerical prediction.

Key Results

  • DExp is the Champion: The Discrete Exponent (DExp) output distribution, when combined with the BERT encoder, consistently outperformed all other models across both masked number prediction (MNM) and numerical anomaly detection (NAD) tasks. It yielded, on average, 10% higher exponent accuracy (E-Acc) and a 0.13 gain in AUC for anomaly detection compared to other models.
  • BERT's Superiority: The BERT encoder consistently outperformed the BiGRU encoder, demonstrating the advantage of transformer architectures for capturing complex textual context relevant to numbers.
  • FlowLP Beats LogLP: The more flexible FlowLP distribution generally performed better than the simpler LogLP, indicating the benefit of parameterized flows for capturing numerical distributions.
  • Numerical Embeddings Help: Ablation studies showed that using numerical input embeddings (like digit or exponent embeddings) improved performance by around 8% on E-Acc and 0.03 on AUC for anomaly detection, confirming their utility.
  • Context is Key: Masking all input numbers led to a significant performance drop, underscoring the importance of surrounding numerical context for accurate predictions.

Limitations and Future Work

  • FlowLP vs. GMM: While FlowLP offers flexibility, it's limited to unimodal distributions. The paper notes that more complex flows could achieve multi-modality but are harder to construct and optimize. GMM, while capable of multi-modality, underperformed, possibly due to its fixed, pre-trained mixture components not adapting to textual context.
  • Domain Specificity: The FinNews-$ dataset, focusing on dollar quantities, proved more challenging than FinNews or Sci, suggesting that specific numerical distributions (like those of dollar amounts) are harder to characterize than others (like dates).
  • Future Directions: The authors suggest exploring the combination of more expressive flows with discrete latent variables. They also highlight the potential for combining contextual encoders with more sophisticated output distributions to further improve performance.

Summary updated

BibTeX
@inproceedings{spokoyny2020empirical,
  author = {Daniel Spokoyny and Taylor Berg-Kirkpatrick},
  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