Exploring Numeracy in Word Embeddings

Aakanksha Naik, Abhilasha Ravichander, Carolyn P. Rosé, Eduard H. Hovy

Introduction

While word embeddings like GloVe and FastText are the gold standard for representing text, they are surprisingly "innumerate." This paper demonstrates that while these models capture a fuzzy, approximate sense of number magnitude (knowing 5 is smaller than 1,000,000), they fail at precise mathematical relationships and cannot consistently link different symbols for the same number (e.g., "3" vs. "three").

Problem Statement

In NLP, the "distributional hypothesis" suggests that a word is defined by the company it keeps. This works well for synonyms like "couch" and "sofa," but numbers are different. Their meaning is derived from a strict mathematical system, not just linguistic context.

Numerical reasoning is a major bottleneck in language understanding. For instance, nearly 29% of contradictions in Wikipedia and Google News arise from numeric discrepancies. If a model doesn't understand that "1.5°C" is significantly different from "100°C," it cannot perform tasks like textual entailment or fact-checking reliably. This paper seeks to quantify exactly how much "math" is actually baked into standard word vectors.

Methodology

The researchers developed an analysis framework based on contrastive tests. For a given number $x$, they create a triple $(x, x_+, x_-)$ and check if the vector for $x$ is closer to the "correct" neighbor $x_+$ than to an "incorrect" choice $x_-$. They test two properties:

  1. Magnitude: Does the model understand the number line? (e.g., is 3 closer to 4 than to 5?)
  2. Numeration: Does the model associate different symbols for the same value? (e.g., is "3" closer to "three" than to "four"?)

To measure the "precision" of this understanding, they use three levels of difficulty:

  • OVA (One-vs-All): $x$ must be closer to $x_+$ than to every other number in the vocabulary.
  • SC (Strict Contrastive): $x$ must be closer to $x_+$ than to the next-closest number (e.g., is 3 closer to 4 than to 5?).
  • BC (Broad Contrastive): $x$ must be closer to $x_+$ than to a distant outlier (e.g., is 3 closer to 4 than to 1,000,000?).

Datasets

The authors evaluated popular pre-trained models including GloVe (trained on 6B, 42B, and 840B tokens), FastText (Wiki and Common Crawl), and SkipGram. To see if "seeing more numbers" helps, they retrained Word2Vec, GloVe, and FastText on two versions of a 1.5B token corpus: one containing only sentences with numbers (Num) and one subsampled without constraints (All). An evaluation set of 2,260 numbers common across all model vocabularies was used to generate the contrastive triples.

Key Insights

The "Fuzzy" Number Sense

Models behave much like human infants or animals—they possess an "Approximate Number System." They are great at distinguishing "small" from "huge" (Broad Contrastive), but they lose all precision when comparing "3" to "4" (One-vs-All).

Contextual Segregation

Why can models distinguish magnitudes at all? The authors found it's not because of math, but because of usage. Small numbers frequently appear in the context of days and months. Large numbers appear in contexts like "census," "election," or "refugees." The models cluster numbers based on these "social circles" rather than a mathematical line.

Contextual primitives associated with numbers at different frequency thresholds.

The Numeration Gap

Models treat "5" and "five" as entirely different concepts. Increasing the amount of numerical data during training does not fix this; the models still fail to beat random baselines on numeration tests.

Key Results

On the easiest magnitude test (BC-MAG), models achieved 80-95% accuracy. However, on the most precise test (OVA-MAG), performance plummeted to between 3% and 18%.

Magnitude performance across different contrastive test difficulties.

Most models were unable to outperform a random baseline on numeration tests. For example, SkipGram and FastText variants often showed 0% accuracy on One-vs-All numeration tests. Finally, using a k-nearest neighbor regressor to predict a number's value from its vector, GloVe-840B achieved an $R^2$ of 0.83, suggesting that while the "neighborhoods" are messy, there is a general global trend of magnitude preserved in the space.

Conclusion and Limitations

The authors highlight a fundamental flaw: word embeddings are static and based on co-occurrence, which may be inherently insufficient for capturing the infinite, precise nature of mathematics. They suggest that future work should move away from standard distributional training for numbers and instead look toward specialized architectures or training objectives that explicitly enforce mathematical constraints. Until then, developers should be cautious when using standard embeddings for tasks requiring high numerical precision.

Summary updated

BibTeX
@inproceedings{naik2019exploring,
  author = {Aakanksha Naik and Abhilasha Ravichander and Carolyn P. Rosé and Eduard H. Hovy},
  title = {{Exploring Numeracy in Word Embeddings}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2019},
  doi = {10.18653/v1/p19-1329},
}
Figure