Do Language Embeddings capture Scales? (2020)

Abstract: Pretrained Language Models (LMs) have been shown to possess significant linguistic, common sense and factual knowledge. One form of knowledge that has not been studied yet in this context is information about the scalar magnitudes of objects. We show that pretrained language models capture a significant amount of this information but are short of the capability required for general common-sense reasoning. We identify contextual information in pre-training and numeracy as two key factors affecting their performance, and show that a simple method of canonicalizing numbers can have a significant effect on the results.

## introduction the success of contextualized pretrained language models like bert @xcite and elmo @xcite on tasks like question answering and natural language inference, has led to speculation that they are good at common sense reasoning (csr). on one hand, recent work has approached this question by measuring the ability of lms to answer questions about physical common sense @xcite ("how to separate egg whites from yolks?"), temporal reasoning (zhou et al., 2020) ("how long does a basketball game take?"), and numerical common sense @xcite . on the other hand, after realizing some high-level reasoning skills like this may be difficult to learn from a language-modeling objective only, @xcite injects numerical reasoning skills into lms by additional pretraining on automatically generated data. all of these skills are prerequisites for csr. figure 1 : scalar probing example. the mass of "dog" is a distribution (gray histogram) concentrated around 10-100kg. we train a linear model over a frozen (shown by the snowflake in the figure) encoder to predict this distribution (orange histogram) using either a dense cross-entropy or a regression loss (section 3). here, we address a simpler task which is another pre-requisite for csr: the prediction of scalar attributes, a task we call scalar probing. given an object (such as a "wedding ring") and an attribute with continuous numeric values (such as mass or price), can an lm's representation of the object predict the value of that attribute? since in general, there may not be a single correct value for such attributes due to polysemy ("crane" as a bird, versus construction equipment) or natural variation (e.g. different breeds of dogs), we interpret this as a task of predicting a distribution of possible values for this attribute, and compare it to a ground truth distribution of such values. an overview of this scalar probing is shown in figure 1 . examples of ground-truth distributions and model predictions for different objects and attributes are shown in figure 2 . our analysis shows that contextual encoders, like bert and elmo, perform better than noncontextual ones, like word2vec, on scalar probing de-spite the task being non-contextual @xcite . further, we show that using scientific notation to represent numbers in pre-training can have a significant effect on results (though sensitive to the evaluation metric used). put together, these results imply that scale representation in contextual encoders is mediated by transfer of magnitude information from numbers to nouns in pre-training and making this mechanism more robust could improve performance on this and other csr tasks. we also show improvements by zero-shot transfer from our probes to 2 related tasks: relative comparisons @xcite and product price prediction (jianmo ni, 2019), indicating that our results are robust across datasets. ## problem definition and data we define the scalar probing task (see figure 1 ) as the problem of predicting a distribution over values of a scalar attribute of an object. we map these values into 12 logarithmically-spaced buckets, so that our task is equivalent to predicting (the distribution of) the order of magnitude of the target value. we explore both models that predict the full distribution and models that predict a point estimate of the value, which is essentially a distribution with all the mass concentrating on one bucket. our primary resource for the scalar probing task is distributions over quantities (doq; @xcite which consists of empirical counts of scalar attribute values associated @xmath0, adjectives, and verbs over 10 different attributes, collected from web data. in this work, we focus only on nouns (which we refer to as objects) over the scalar attributes (or scales) of mass (in grams), length (in meters) and price (in us dollars). for each object and scale, doq provides an empirical distribution over possible values (e.g. figure 2 ) that we map into the 12 afore-mentioned buckets and treat it as "ground truth". we note that doq itself is derived heuristically from web text and itself contains noise; however, we use it as a starting point to evaluate the performance of different models. moreover, we validate our findings with transfer experiments shown in section 6, using doq to train a probe that is evaluated on the ground-truth data of @xcite @xcite . to explore the role of context in scalar probing, we also trained specialized probing models on a subset of doq data in narrow domains: mass of animals and price of household products. ## probing model we probe three different embedding models: word2vec @xcite , elmo @xcite and bert @xcite (the latter two of which are contextualized encoders). for each encoder, the input layer extracts an embedding of the object and the probing layer predicts the scalar magnitude. 2 input representations for word2vec, we follow the standard practice of averaging the embeddings of each word in the object's name. if an object name is a full phrase in the dictionary, we use its embedding instead. as bert and elmo are contextual text encoders operating on full sentences, we generate artificial sentences with the following templates: and use the cls token emebedding (for bert) or final state embedding (for elmo) as the input representation. for length, we use "big" instead of "long", since length measurements in doq can be widths or heights as well. variations of these templates with different adjectives and sentence structures (e.g. "the x is small." or "what is the length of x?" for length) led to very similar performance in our evaluations. probes we use linear probes in all cases following many previous probing work @xcite @xcite since we want to use a simple probe to find easily accessible information in a representation. @xcite also demonstrates that linear probes achieve relatively high selectivity compared to non-linear ones like mlp. we experiment with two different approaches for predicting scales: regression (rgr) for the point estimate, we use a standard linear regression model trained to predict log of the median of all values for each object for the scale attribute under consideration. ## numeracy through scientific notation to examine the effect of numerical representations on scalar probing, we trained a new version of the bert model (which we call numbert) by replacing every instance of a number in the training data with its representation in scientific notation, a combination of an exponent and mantissa (for example 314.1 is represented as 3141[exp]2 where [exp] is a new token introduced into the vocabulary). this enables the bert model to more easily associate objects in the sentence directly with the magnitude expressed in the exponent, ignoring the relatively insignificant mantissa. this model converged to a similar loss on the original bert masked lm+nsp pre-training task and a standard suite of nlp tasks (see appendix) as bert-base, demonstrating that it was not over-specialized for numerical reasoning tasks. ## evaluation we offer the following aggregate baseline to help interpret our results: for each attribute, we compute the empirical distribution over buckets across all objects in the training set, and use that as a predicted distribution for all objects in the test set (this is a stronger version of the majority baseline used in classification tasks). since we are comparing results from regression and classification models, we report results on 3 disparate metrics that give a full picture of performance: accuracy for mcc we use the highest scoring bucket from the predicted distribution as the predicted bucket, while for rgr we map the predicted scalar to the single containing bucket and use that as the predicted bucket. then the accuracy is calculated between the predicted bucket and the groundtruth bucket, which is the highest scoring bucket in the empirical distribution in doq. ## results from comparing results by encoders, we see that word2vec performs significantly worse than the contextual encoders -even though the task is noncontextual -indicating that contextual information during pre-training improves the representation of scales. despite being weaker than bert on downstream nlp tasks, elmo does better on scalar probing, consistent with it being better at numeracy @xcite due to its character-level tokenization. numbert does consistently better than elmo and bert on the emd metric, but worse on mse and accuracy. this is in contrast to other standard benchmarks such as q/a and nli, where num-bert made no difference relative to bert. our key takeaway is that the numerical representation has an impact on scale prediction (see figure 2 for qualitative differences), but the direction is sensitive to the choice of evaluation metric. as discussed in section 5, we believe emd to be the most robust metric a priori, but this finding highlights the need to still examine the full range of metrics. results on animal masses ( note that, despite significant differences in the raw numbers for each scale (mass/length/price), the relative behavior of encoders, metrics and probes are the same, indicating that our conclusions are broadly applicable. transfer experiments on the f&c relative comparison task ( ## conclusion from our novel scalar probing experiments, we find there is a significant amount of scale information in object embeddings, but still a sizable gap to overcome before lms achieve this prerequisite of csr. we conclude that although we observe some non-trivial signal to extract scale information from language embedding, the weak signals suggest these models are far from satisfying common sense scale understanding. our analysis points to improvements in modeling context and numeracy as directions in which progress can be made, mediated by the transfer of scale information from numbers to nouns. the numbert intervention has a measurable impact on scalar probing results, and transfer experiments suggest that it is an improvement. for future work we would like to extend our models to predict scales for sentences bearing relevant context about scalar magnitudes, e.g. "i saw a baby elephant". yiben yang, larry birnbaum, ji-ping wang, and doug downey. 2018. extracting commonsense properties from embeddings with limited human guidance. in proceedings of the 56th annual meeting of the association for computational linguistics (volume 2: short papers), pages 644-649, melbourne, australia. association for computational linguistics. ben zhou, qiang ning, daniel khashabi, and dan roth. 2020. temporal common sense acquisition with minimal supervision. in association for computational linguistics.