Measuring and Improving BERT ’s Mathematical Abilities by Predicting the Order of Reasoning. (2021)

Abstract: Imagine you are in a supermarket. You have two bananas in your basket and want to buy four apples. How many fruits do you have in total? This seemingly straightforward question can be challenging for data-driven language models, even if trained at scale. However, we would expect such generic language models to possess some mathematical abilities in addition to typical linguistic competence. Towards this goal, we investigate if a commonly used language model, BERT, possesses such mathematical abilities and, if so, to what degree. For that, we fine-tune BERT on a popular dataset for word math problems, AQuA-RAT, and conduct several tests to understand learned representations better. Since we teach models trained on natural language to do formal mathematics, we hypothesize that such models would benefit from training on semi-formal steps that explain how math results are derived. To better accommodate such training, we also propose new pretext tasks for learning mathematical rules. We call them (Neighbor) Reasoning Order Prediction (ROP or NROP). With this new model, we achieve significantly better outcomes than data-driven baselines and even on-par with more tailored models.

## introduction automatically solving math word problems has a long history dating back to the middle sixties @xcite . early approaches were rule-based matching systems that solve the problem symbolically. even though there are some impressive symbolic systems that operate in a relatively narrow domain, the inability to successfully scale them up is sometimes presented as a critique of the goodold-fashioned ai, or @xcite . one issue is to create a formalism that covers all the aspects needed to solve these problems. on the other hand, deep learning @xcite aims to develop artificial general intelligence that scales better to various problems. however, despite many successes in computer vision and natural language processing @xcite @xcite @xcite , data-driven methods evade our dream of building a system with basic, every-day, mathematical skills. as largescale natural language models become more common @xcite , we would expect them to also reason mathematically. since natural language understanding also involves symbolic manipulation @xcite , we treat mathematical reasoning as a language understanding and revisit the data-driven paradigm. for that, we rely on a recent language model, bert @xcite , and challenge it with math word problems @xcite . even though such language models have initially shown promising results, more recent investigation shows they may rely on various biases in their predictions @xcite @xcite . here, we also follow that line of investigation and show these models can answer correctly without an understanding of the rationale behind it. furthermore, as directly predicting answers to math problems often requires multiple steps of reasoning, we show that we can improve bert's generalization by exposing it to rationales @xcite @xcite . these are, however, only used during training similarly to a teacher that shows a student a justification for each answer. but then, the student is evaluated only on the ability to answer these questions during the college exam correctly with no access to rationales. finally, to learn a better representation figure 1 : bert (right) and our novel extension (left). we use shared architecture but we separate question tokens (green blocks) from rationales (blue blocks) using different segment and positional embeddings. we show all three losses. mlm predicts masked tokens (depicted here as p r q,k ). we use rop or nrop to predict if the ordering of rationale steps is correct. for question-answering, we fine-tune the whole model with a classification layer using softmax. we use the embedding that corresponds to the [cls] token as the input representation. from rationales and to improve the generalization even further, we introduce novel pretext tasks and corresponding losses, which we name (neighbor) reasoning order prediction (rop or nrop). we also show that permutation invariant losses can lead to less biased representations. with that, we outperform other data-driven baselines, and are even on-par with methods that are more tailored to mathworld problems and the aqua-rat dataset. ## methods we use the following methods, each initialized with bert-base pre-trained on wikipedia and books corpus @xcite . note that, in fine-tuning they all have the same number of parameters. 1) bert-base. we fine-tune bert to predict the correct answer and show its transfer to math word problems. later in this paper, we propose permutation invariant losses that additionally reduce positional biases of the bert-base model, and can work with all the pretext tasks described above. ## results dataset. we use aqua-rat @xcite . it has about 100k crowd-sourced math questions with five candidate answers (one is correct). each question has a rationale -a step-by-step explanation of how the answer is computed -that is only available during training. at test time answer predictions are based on questions. the train set has roughly 100k question-answer-rationale triples, while dev and test about 250 question-answer pairs each. main results. moreover, we observe a highly sensitive relationship between dev and test sets (figure 3 , left), where small changes in the accuracies in the former set can lead to more dramatic changes at test time. indeed, the correlation of results between both sets is only 0.082. as the validation set is quite small, we propose an extended dev consisting of 5000 randomly chosen samples from the training set extended by the whole dev set. although not ideal, and the sensitive relationship is still present (figure 3, right), we have increased the correlation to 0.401. with such a new validation set, we report 37% test accuracy but we can also see that 40% is within the reach (figure 3, right). rationales. we hypothesize that rationales contain information that is either missing or hard to extract from questions. for instance, their structure is different; they are more formal with emphasis on the logical steps. however, testing that hypothesis is non-trivial as there is a confounding factoradding more rationales results in more data. therefore, we artificially modify the dataset so that both models (one trained only on questions, and another one on questions and rationales) are trained on roughly the same number of data points. for that, we have estimated that rationales have 1.7 times more tokens than questions. this means that a question combined with rationale has around 3 times more tokens than just a question. if our hypothesis is valid, training on 20% questions and rationales should give better results than training on 60% questions (counting the number of tokens). we therefore created samples of respective sizes of just questions and questions combined with rationales. we show our results in figure 4 . the results suggest that adding more questions is insufficient and only slightly improves the overall performance. this shows that training with rationales leads to a better representation. even better than training with more questions. on the other hand, using rationales is more helpful. embeddings. to better understand the difference between bert and bert+nrop, we analyze theirs embeddings. for our analysis, we sample 2500 questions with a single operator in rationales, and next we visualise them with t-sne (van der @xcite . we show both in figure 5 . we observe that bert+nrop embeddings preserve more information about different operators. permutation consistency. random guessing on aqua-rat yields 20%. with that in mind to separate questions that were solved by chance, we have constructed a new evaluation task -permutation consistency test -where each question gets 5 answers at different positions. drop from 37.0% to 11.02% ( sep-nc and sep-c improve permutation consistency tests. yet, they give similar results to original methods in accuracy measuring task. they achieve respectively 33.5% (sep-nc) and 35.4% (sep-c). questions difficulty. to better understand the models' performance, we check which questions are difficult for the model. we categorize questions by their difficulty for bert-nrop and bert. to estimate a question's difficulty, we have ranked the candidate answers according to the model's uncertainties. for instance, if the correct answer has the 2nd largest probability, we assign to that question difficulty two. with that, we group questions into 5 difficulty categories, from the easiest: d 1 , .., d 5 . manual inspection shows that for bert+nrop: d 5 requires additional knowledge or implicitly defined numbers (e.g., adding first 100 numbers), d 4 requires geometry or non-linear equations and systems, d 3 requires solving linear systems with a few basic operations, d 2 requires solving simple equations, and d 1 has one or two basic operations with clearly written numbers. we show an example from each group in the supplementary material. we didn't observe a similar pattern for bert with the exception of the easiest group d 1 where the model chooses the answer that is somewhat different from other candidates. we provide an example of each group in the supplementary materials. finally, we also compare the difficulty of questions with the difficulty perceived by humans. for that, we have conducted a small-group human study, where we have asked participants to solve some aqua-rat questions and rate their difficulty. we find a positive correlation between the difficulty measured by our models (as described above) to the difficulty judged by humans. we give more details in the appendix.