Source-linked AI summary

Do NLP Models Know Numbers? Probing Numeracy in Embeddings

Eric Wallace, Yizhong Wang, Sujian Li, Sameer Singh, Matt Gardner

arXiv:1909.07940v2cs.CLcs.LG

TL;DR

Neural NLP models commonly represent numbers as distributed vectors, raising the question of whether those representations support numeracy. The paper analyzes NAQANet on DROP and probes standard embeddings on synthetic numerical tasks, finding substantial numerical information in embeddings, especially character-level ones, alongside limited extrapolation and weaker BERT performance on large ranges.

  • Problem

    The paper investigates whether standard distributed token embeddings capture numeracy, which is needed for numerical reasoning over natural language.

  • Method

    The authors evaluate NAQANet on numerical DROP questions and probe BERT, GloVe, ELMo, and character-level embeddings on synthetic list maximum, decoding, and addition tasks.

  • Results

    Across tasks, widely used pre-trained embeddings capture number magnitude and order, with character-level methods stronger than word- and sub-word-level methods; BERT reaches 52% accuracy on list maximum for [0,9999].

  • Takeaways & Limitations

    Numerical information is naturally present in standard embeddings, while character-level representations provide the strongest numeracy and neural models remain weak at extrapolating beyond training ranges.

  • Takeaways & Limitations

    The evaluation finds that neural models struggle to extrapolate to numbers outside their training range.

Abstract

from arXiv · show

The ability to understand and work with numbers (numeracy) is critical for many complex reasoning tasks. Currently, most NLP models treat numbers in text in the same way as other tokens---they embed them as distributed vectors. Is this enough to capture numeracy? We begin by investigating the numerical reasoning capabilities of a state-of-the-art question answering model on the DROP dataset. We find this model excels on questions that require numerical reasoning, i.e., it already captures numeracy. To understand how this capability emerges, we probe token embedding methods (e.g., BERT, GloVe) on synthetic list maximum, number decoding, and addition tasks. A surprising degree of numeracy is naturally present in standard embeddings. For example, GloVe and word2vec accurately encode magnitude for numbers up to 1,000. Furthermore, character-level embeddings are even more precise---ELMo captures numeracy the best for all pre-trained methods---but BERT, which uses sub-word units, is less exact.

1 Introduction

The paper asks whether standard neural NLP models encode numeracy and finds that both a DROP question-answering model and common embeddings capture substantial numerical information, though extrapolation remains limited.

  • Motivation: Neural NLP models are tested for numerical reasoning because existing systems struggle with complex reasoning involving comparing, sorting, and adding numbers.Numeracy is the ability to understand and work with numbers in digit or word form.
  • DROP case study: NAQANet performs strongly on numerical reasoning in DROP, scoring 89 F1 on numerical comparison questions despite 49 F1 on the full validation set.The model also computes list extrema, extracts superlative entities, and compares numerical quantities.
  • Embedding analysis: The paper probes BERT, GloVe, and other token embeddings on synthetic list maximum, number decoding, and addition tasks to study how numeracy emerges.The analysis focuses on numerical information available in embeddings without direct magnitude or ordering supervision.
  • Embedding analysis: All widely used pre-trained embeddings capture number magnitude, including for numbers in the thousands, while character-level methods generally outperform word- and sub-word-level methods.ELMo excels among pre-trained methods, whereas BERT is less exact; learned character-level models are strongest overall.

2 Numeracy Case Study: DROP QA

The DROP case study shows that NAQANet can perform several numerical reasoning operations from question-answer supervision, but its numeracy degrades when values move beyond familiar ranges or forms.

  • 2.1 DROP Dataset: DROP tests numerical reasoning through operations including counting, sorting, and addition, with answers that may be spans, numbers, or dates.The model must learn numerical reasoning while also reading and comprehending passages.
  • 2.1 DROP Dataset: NAQANet combines GloVe and character-CNN representations and uses separate output branches for passage spans, question spans, counts, and arithmetic answers.It has no auxiliary component explicitly representing number magnitude or performing comparisons.
  • 2.3 Comparative and Superlative Questions: Comparative and superlative questions evaluate binary comparisons, multi-step greater-than reasoning, list maxima and minima, and argmax extraction.Superlative span questions require finding the extreme quantity and then extracting its associated entity.
  • 2.4 Emergent Numeracy in NAQANet: 89.0 F1 is achieved on binary comparative questions, approximately 40 F1 points above the average validation question and within 7 F1 points of human test performance.Non-binary comparisons receive lower but respectable accuracy despite requiring multiple reasoning steps.
  • 2.4 Emergent Numeracy in NAQANet: Nearly 70 F1 is achieved on numerical superlatives and 66.3 F1 on span-answer superlatives, indicating list-extrema and argmax abilities.The examples require identifying the relevant number list, computing its maximum or minimum, and sometimes extracting the associated entity.
  • 2.5 Stress Testing NAQANet’s Numeracy: Small numerical perturbations cause minor degradation, but larger changes cause severe failures, including a 35.7 F1 drop for superlatives under Multiply [11,200].Converting digits to larger word forms also produces a 21.6 F1 drop over [21,100].
  • 2.6 Whence this behavior?: NAQANet can learn comparison algorithms while simultaneously learning to read and comprehend using only question-answer supervision.The paper attributes the numerical information ultimately to token embeddings, motivating direct embedding probes.

3 Probing Numeracy of Embeddings

The paper probes pre-trained and learned embeddings with synthetic tasks to test whether they encode numerical magnitude, ordering, and arithmetic. Character-level methods generally perform best, while BERT struggles on large ranges and models have difficulty extrapolating beyond training values.

  • 3.1 Probing Tasks: The probing setup evaluates whether embeddings encode ordering through list maximum, magnitude through decoding, and number manipulation through addition.Decoding regresses an embedding to its value, while addition predicts the sum of two embedded numbers.
  • 3.1 Probing Tasks: Synthetic probing tests list maximum, number decoding, and addition from token embeddings, using held-out numbers to assess generalization.Inputs include words, digits, floats, and negatives; evaluation uses interpolation splits with 80% of values for training and 20% for testing.
  • 3.3 Results: Embeddings Capture Numeracy: All pre-trained embeddings contain fine-grained information about number magnitude and order, with word2vec and GloVe significantly outperforming random vectors.These results show that numerical information can emerge from standard embedding training without explicit numerical supervision.
  • 3.3 Results: Embeddings Capture Numeracy: Character-level methods have a clear advantage: a learned Char-CNN is strongest overall, while ELMo and NAQANet’s Char-CNN are strongest among pre-trained methods.An untrained Char-CNN is surprisingly competitive, suggesting that character-level convolutions provide a useful architectural prior.
  • 3.3 Results: Embeddings Capture Numeracy: BERT achieves 52% list-maximum accuracy on [0,9999], and its performance degrades on larger decoding ranges.The authors suspect sub-word divisions encode similar-valued numbers inconsistently.
  • 3.4 Probing Models Struggle to Extrapolate: Models struggle to extrapolate for decoding and addition, although data augmentation can improve interpolation and extrapolation.Similar trends hold for word-form numbers, floats, and negatives, with BERT notably struggling on floats.

4 Discussion and Related Work

The paper situates its probing approach among work on emergent numerical and linguistic knowledge in embeddings. It highlights unresolved questions about how numeracy emerges and contrasts its nonlinear probing methodology with related approaches.

  • Discussion: Training-data origins of numeracy in word vectors and contextualized embeddings remain an open research question.The paper identifies tracing numeracy back to training data as a future direction.
  • Discussion: Embeddings can naturally encode relative ordering for numbers and other commonsense phenomena such as object size and vehicle speed.The paper places numeracy within a broader class of emergent knowledge properties.
  • Related Work: The study uses nonlinear neural probing classifiers, whereas concurrent work relies on nearest-neighbor and cosine-distance methods.It also examines ELMo, BERT, and learned embedding methods.
  • Related Work: Prior probing research shows that LSTMs encode sentence length, word order, and word presence, while language models leverage context and subject-verb agreement.These studies frame numeracy probing as part of broader investigations into neural models’ linguistic capabilities.
  • Related Work: Related numerical-prediction work improves number prediction or predicts numerical knowledge-base attributes, while this paper probes embeddings.The distinction is between improving models and understanding representations.
  • Related Work: Synthetic-task research has studied sorting, counting, and decoding to design better models, whereas this paper uses such tasks to understand token embeddings.Prior work also reports difficulty extrapolating beyond training values.

5 Conclusion

The paper concludes that pretrained token representations naturally encode numeracy, while neural models still have difficulty extrapolating beyond values seen during training. It identifies CNNs as a strong prior and leaves the origins of emergent numeracy open.

  • Conclusion: Pretrained token representations naturally encode numeracy, as shown by analysis of a successful model on the DROP dataset.The paper frames this as its central discovery about what NLP models know about numbers.
  • Conclusion: CNNs are a particularly good prior for numeracy, likely contributing to ELMo’s superior numeracy compared with BERT.The conclusion links this architectural property to the observed embedding differences.
  • Conclusion: Neural models have difficulty extrapolating beyond values seen during training.The paper presents extrapolation as a limit of the observed numeracy.
  • Conclusion: Future work should investigate why numeracy emerges naturally in embeddings and which other properties emerge similarly.The conclusion presents both questions as fruitful research directions.

A NAQANet Details and Numeracy Requirements

NAQANet answers DROP arithmetic questions by extracting numbers and assigning coefficients, so some addition and subtraction questions can be solved without representing numerical magnitude. Character-level padding choices nevertheless affect numeracy learning and generalization.

  • NAQANet Details: NAQANet generates arithmetic answers by extracting passage numbers, assigning each a coefficient in {-1,0,1}, and summing the resulting terms.Its output branches also include passage spans, question spans, and counts from 0–9.
  • Numeracy Requirements: Addition and subtraction questions may not require numeracy because context can determine the correct coefficients without understanding number magnitude.The paper illustrates this with coefficients +1 for 2003 and -1 for 1997.
  • Left-padding: Character-level convolutions require padding when words are shorter than the minimum kernel width.The implementation reuses right-padding for character inputs.
  • Left-padding: Left padding substantially decreases generalization error and convergence rate for Char-CNN models trained on synthetic numeracy tasks.Right padding places corresponding hundreds and tens digits in the same position across numbers, which is detrimental to learning numeracy.
  • Left-padding: Padding on both the left and right via SAME convolutions also mitigates the positional-padding issue.This is reported as an additional implementation option.

C Training Details for Probing

The probing experiments construct controlled train/test splits for addition and list maximum tasks. Numbers are partitioned into disjoint training and test pools, with large-range pair data subsampled for tractability.

  • Training Details: Addition splits place 80% of an integer range in training and 20% in testing before enumerating number pairs.For ranges such as [0,999], the study randomly subsamples 10% of training and test pairs.
  • Training Details: List maximum splits place 80% of numbers in a training pool and 20% in a test pool.The experiments generate 100,000 training examples and 10,000 test examples after modifying the initial sampling strategy.

D.1 Linear Regression Accuracies

This section reports interpolation accuracies for number decoding with linear regression, showing that linear regression is competitive for smaller numbers.

  • Table 8 reports number-decoding interpolation accuracies using linear regression.
  • The comparison concerns whether a linear model can recover numerical values from embeddings during interpolation.
  • Linear regression is competitive with the fully connected probe for smaller numbers.Its performance is reported in the interpolation setting.

D.2 Variances on Digit Form Results

This appendix examines variance and representation-specific results across digit, float, and word-form inputs, with experiments reporting variation across random shuffles.

  • D.2 Variances on Digit Form Results: Table 9 reports means and standard deviations for the synthetic integer interpolation tasks across five random shuffles.
  • D.2 Variances on Digit Form Results: The digit-form variance analysis uses five random shuffles to characterize result variability.
  • D.3 Float Values: Float experiments use one decimal point and modify the list-maximum setup.
  • D.3 Float Values: Half of the float lists repeat one integer with different decimal values, while the other half contain random integers and decimal digits.
  • D.4 Word Form Results: Word-form results are presented in Table 10, with numbers larger than 100 excluded because they contain multiple words.
  • D.4 Word Form Results: The word-form appendix reports interpolation results for number representations written as words.
  • E Automatically Modifying DROP Paragraphs: For DROP paragraph modifications, the original text is retained while the model’s internal number embeddings are changed directly.

F Extrapolation with Data Augmentation

This section evaluates data augmentation for numerical extrapolation by creating modified DROP paragraphs with larger transformed numbers and comparing performance on original and Bigger validation sets.

  • Training adds one modified paragraph per example after multiplying numbers by a random integer from [1, 10] and adding a random integer from [0, 20].The additional paragraph is used for computational efficiency.
  • The Bigger validation set multiplies paragraph numbers by a random integer from [11,20] and adds a random value from [21,40].This transformation range exceeds the one used for augmentation.
  • Data augmentation provides small gains on the original superlative and comparative subsets and significant improvements on the Bigger version.
  • Data augmentation doubles NAQANet’s F1 score for superlative questions on the Bigger validation set.
  • Table 9 reports means and standard deviations for the integer interpolation tasks.
  • Table 10 reports word-form interpolation accuracies using an 80% training split and a 20% test split over randomly shuffled integer ranges.
  • Table 11 reports interpolation and extrapolation results in EM / F1 format.
Loading 1909.07940v2…