Solving Quantitative Reasoning Problems with Language Models
Anonymous Author(s)
AfﬁliationAddress email
Abstract
Language models have achieved remarkable performance on a wide range of tasksthat require natural language understanding.
Nevertheless, state-of-the-art modelshave generally struggled with tasks that require quantitative reasoning, such assolving mathematics, science, and engineering problems at the college level.
Tohelp close this gap, we introduce Minerva, a large language model pretrained ongeneral natural language data and further trained on technical content.
The modelachieves state-of-the-art performance on technical benchmarks without the use ofexternal tools.
We also evaluate our model on over two hundred undergraduatelevel problems in physics, biology, chemistry, economics, and other sciences thatrequire quantitative reasoning, and ﬁnd that the model can correctly answer nearlya third of them.
Introduction
Artiﬁcial neural networks have seen remarkable success in a variety of domains including computervision, speech recognition, audio and image generation, translation, game playing, and robotics.
Inparticular, large language models have achieved excellent performance across a variety of naturallanguage tasks including common-sense reasoning, question answering, and summarization [1, 2, 3,4, 5].
However, these models have struggled with tasks that require quantitative reasoning, such assolving mathematics, science, and engineering problems [6, 7].
Quantitative reasoning problems are an interesting domain of application for language models becausethey test the capability of models on several fronts.
They require the solver to correctly parse anatural language input, potentially recall world knowledge that pertains to the problem, and applyan algorithm or series of computations to the information provided in order to arrive at a correctsolution.
They also require that the solver is able to correctly parse and generate precise sequencesof mathematical tokens, as well as apply a computational procedure to tokens via symbolic andnumerical manipulation.
Finally, such problems are a proving ground for research toward robustquantitative reasoning solvers that are useful in supporting the work of humans in scientiﬁc andtechnical ﬁelds.
Previous research has shown that large language models achieve impressive performance on math andprogramming questions after training on domain speciﬁc datasets [8, 9, 10].
In this work, we applythis approach to quantitative reasoning problems, in which the model is required to provide a completeand self-contained solution, without relying on external tools.
Such tasks include mathematics wordproblems, competition mathematics evaluations, and many problems in science and engineering.
1.1 Our Contribution
We present Minerva, a language model that achieves strong performance on many quantitative reasoning tasks.
Our model is able to process scientiﬁc and mathematical questions formulated in
Question:
A line parallel to y = 4 x + 6 passes through (5 , 10) .
What is the ycoordinate of the point where this line crosses the y -axis?
Target: Since the line is parallel to y = 4 x + 6 , we know that its slope is 4.
Thus the equation of the line is y = 4 x + b where b is the y -intercept.
Plugging (5 , 10) into this gives 10 = 4 · 5 + b ) b =  10 which is what we wanted.
Model output: The line is parallel to y = 4 x +6 , which means that it has the same slope as y
= 4 x + 6 .
Since the line passes through (5 , 10) , we can use the point-slope form of a line to ﬁnd the equation of the line:
[Equation]
Now that we have the equation of the line, we can ﬁnd the y -coordinate of the point where the line crosses the y -axis by substituting x = 0 into the equation:
[Equation]
Question: Assume that variance of ﬁrst n natural numbers is 10 and variance of ﬁrst m even natural numbers is 16 .
Compute m + n .
Model output: Variance of ﬁrst n natural numbers is n 2  1 12 .
Variance of ﬁrst m even natural numbers is 2 2 ( m 2  1).
So, n 2  1 12 =and 2 2 ( m 2  1)= 16 .
Solving for n and m , we get n = 11 and m = 7 .
So, m + n = 18 .
Question: Prove that for every a, b , b 6 = a , holds a 2 + b 2>  a + b 2 .
Model output: We have
[Equation]
natural language, and generate step-by-step solutions using correct L A TEX notation.
Figures 1 and 2show example responses from Minerva to mathematics and physics questions.
Minerva is based on BaseModel general language models 1 that are further trained on a high-qualitydataset containing scientiﬁc and mathematical data.
In particular, we start with 8B, 62B, and 540Bparameter pretrained models, and continue training them on our technical content dataset.
We achievestate-of-the-art performance on MATH [6], GSM8k [7], and a STEM subset of the MMLU [11]dataset, all of which include math and science questions formulated in natural language.
Notably, ourmodels achieve robust performance in a few-shot setting with no explicit training on these datasets.
The main novelty of this paper is the use of a large training dataset that juxtaposes natural languagewith correctly-formatted mathematical content in L A TEX format.
The data is collected from the arXivpreprint server and from web pages that we carefully process to minimise the loss of mathematicalcontent.
In addition to achieving state-of-the-art results, our work sets a new baseline for theperformance achievable on quantitative reasoning by increasing data quality and model size. To further increase the coverage of quantitative reasoning benchmarks, we build a dataset of over undergraduate-level questions in science and mathematics from MIT’s OpenCourseWare (OCW). This provides a measure of our model’s quantitative reasoning abilities in a chain-of-thought contextbeyond a pure mathematical setting
Question: A particle moves so that it is at  3 sin t 4 , 3 cos t at time t. Find the speed of the particle, measured in unit of distance per unit of time.
Target:
The parametric curve ( x, y ) =
3 sin t 4 , 3 cos t describes a circle with radius 3.
Furthermore, it makes a full revolution at time t = 8 ⇡ .
(ﬁgure)
Therefore, the speed of the particle is 6 ⇡ 8 ⇡ = 3 4 .
Model output: The speed is the magnitude of the velocity vector.
Therefore, we must ﬁrst ﬁnd the velocity vector, which is the derivative of the position vector.
We have
[Equation]
Therefore, the magnitude of the velocity vector is
[Equation]
Therefore, the speed of the particle is 3 4 .
1.2 Related Works
Solving quantitative reasoning problems expressed in natural language has been an active area ofstudy [12, 13].
Prompting language models using scratchpad [14] or chain-of-thought [15] solutionscan lead them to generate step-by-step solutions to unseen problems.
The GSM8k work [7] showedthat training veriﬁers to rerank model outputs can lead to improved performance.
The original versionof GSM8k included special syntax for algebraic calculations, which were processed by a calculator.
In this work we focus on self-contained models without access to external tools.
The standard method for evaluating language models on generative tasks is to greedily sample onesolution per problem.
Recent works [8, 16, 17, 18] have shown that it is advantageous to samplemultiple solutions per problem, and then ﬁlter those down to a ﬁnal answer.
We ﬁnd that majorityvoting [18] signiﬁcantly improves performance over greedy decoding.
The work [10] includes an evaluation of davinci-002, OpenAI’s latest publicly available languagemodel, on a subset of 90 problems from the MATH dataset.
Due to the focus on a subset of questions,as well as changes made to the way questions are formatted, it is difﬁcult to directly compare ourresults with those of [10].
In Section 3, we compare OpenAI davinci-002 with our models under thesame experimental conditions.
Code generation.
Applying code generating models to mathematical problems has been an activearea of exploration.
PaLM [5] showed that a large language model with code in its training datasetcan achieve good performance on a code version of GSM8k.
Furthermore, the Codex model [8] cangenerate code solutions to MATH problems [10].
These solutions often rely on external libraries toperform mathematical operations such as solving equations or taking limits.
This is a complementaryapproach to ours, in which we directly probe the model’s ability to arrive at an answer by relyingonly on its own reasoning capability.
Formal mathematics.
Mathematics developed as a discipline based in natural language, but itsaxiomatic fundamentals make it possible to simulate mathematical thinking.
This can be achieved using specialized programming languages that facilitate the simulation of logical and mathematicalthinking using a computer, such as Coq [19], Isabelle [20], HOL4 [21], Lean [22], Metamath [23]and Mizar [24].
Work on automation of proof assistants and automated theorem provers such as
E [25], leanCoP [26], and Vampire [27] has substantially beneﬁted from integration with machinelearning methods [28, 29, 30, 31, 32].
Language models applied to formal and synthetic mathematical problems.
Previous worktrained language models to predict mathematical expressions [33, 30, 31, 34, 35, 36, 37, 38].
In turn,such a predictive model can be used to guide a proof search, as done by [31].
Large language modelsexcel in modelling natural language, though in the case of formal languages, models that facilitateretaining information about the graph structure of a given mathematical formula, such as GNNs, arestill very competitive.
Modelling mathematics as a discipline of natural language.
New benchmark datasets [6, 39]cover more advanced mathematical topics.
In this domain language models are facing limitedcompetition from other classes of models.
Training and Evaluation2.1 Mathematical Training Dataset
Our models were trained on a dataset of 38.5B tokens from webpages ﬁltered for mathematicalcontent and from papers submitted to the arXiv preprint server.
In addition, the dataset includesgeneral natural language data, which is randomly sampled from the same dataset that was used forpretraining BaseModel.
Our mathematical webpage dataset was constructed by collecting pagesthat contain mathematical expressions in MathJax format.
The pages underwent a cleaning processthat removes most HTML tags but preserves natural language as well as mathematical notation,including L A TEX symbols and formatting. The result is that mathematical formulae like e ⇡ i + 1 = 0or E = mc 2 are presented in full to the model during training.
This procedure makes it possiblefor the model to perform well on tasks that require calculation and symbolic manipulation.
Table1 provides a breakdown of the training dataset.
See Appendix A for more details.
[Table]
2.2 Models and Training Procedure
Our approach is to start with the BaseModel pretrained decoder-only transformer language models 105, and further train (ﬁnetune) them on our mathematical dataset using an autoregressive objective.
Table 2 contains the main model and training hyperparameters.
The largest model, with 540 Bparameters, was ﬁnetuned on 26 B tokens.
While this model is highly undertrained compared tothe 8B and 62B models, it still achieves superior performance.
Additional details can be found in Appendix B.
2.3 Evaluation Datasets
We mainly focus on few shot evaluation, though see Appendix D.3 for a discussion of ﬁnetunedevaluation.
For evaluation, we truncate the inputs from the left to 1024 tokens and we use the modelto generate up to 512 tokens.
When sampling once per problem, we sample greedily.
When samplingmultiple times per problem we use nucleus sampling [40] with temperature T = 0 . 6 , p = 0 . For [Table]
generative tasks, the model produces a chain-of-thought answer and demarcates a ﬁnal answer.
Weevaluate a solution as correct if the ﬁnal answer matches the ground truth solution, independent of thequality of the chain-of-thought preceding it.
To evaluate correctness, we parse the ﬁnal answers andcompare them using the SymPy library [41].
This is done in order to correctly identify answers thatare mathematically equivalent such as 1 / p 3 and p 3 / 3 .
See Appendix C.1 for further details.
The existing datasets on which we focus are:
• MATH: a dataset of 12K middle school and high school mathematics problems [6].
Problem
statements are written in L A TEX.
We prompt the model with a ﬁxed 4-shot prompt (listed
in Appendix C.2).
This prompt includes four random examples from the training dataset
whose ground truth targets are not too long.
• GSM8k: middle school math word problems [7].
Models are evaluated using the chain-of-
thought prompt from Wei et al.
Previous models evaluated on GSM8k made use of anexternal calculator.
In this work, our model does not have access to any external tools.
• MMLU-STEM: subset of the MMLU dataset [11] focused on science, technology, engi-
neering, and mathematics (STEM).
For the original version, we use the 5-shot prompt from the development set for each task.
We also consider chain-of-thought prompting for thistask, where we prompt the model with examples that include step-by-step solutions.
Weuse a multiple-choice version of the MATH prompt for topics that involve mathematical
reasoning, and add step-by-step solutions to the standard 5-shot prompts for the rest of the
topics.
See Appendix F for more details
2.4 Undergraduate-Level STEM Problems
To evaluate the scientiﬁc reasoning capabilities of Minerva, we harvested a set of STEM problems atthe undergraduate level, most of which involve multi-step reasoning, which we refer to in this paperas OCWCourses.
Using publicly-available course materials offered by MIT (OpenCourseWare), we [Table] collected problems with automatically-veriﬁable solutions (either numeric or symbolically veriﬁablevia SymPy ) from courses including “solid-state chemistry”, “information and entropy”, “differentialequations”, and “special relativity.”
These problems were processed by contractors to be selfcontained and to have a clearly-delineated ﬁnal answer. Problems asking for a proof or open-endedshort answer were not included.
In total we curated 272 problems, 191 of which have numericsolutions and 81 have symbolic solutions.
In Appendix E, we detail the contributions from eachcourse, and the process of converting these course materials into a format suitable for processing bylanguage models.
We also provide the text of all problems.
We plan to release these as part of anopen-source dataset which will be detailed in an upcoming manuscript.
2.5 Inference-Time Techniques
We ﬁnd that we can considerably outperform greedy decoding by sampling k > 1 solutions (witha non-zero temperature) and selecting one using majority voting [18].
This consists of groupingpredictions with respect to their ﬁnal answer and selecting the most common answer.
We denote thisas maj1@k , following [16].
A variation of this algorithm, denoted majn@k , involves selecting the nmost common answers.
Intuitively, the reason majority voting improves performance is that whilethere are many ways to answer a question incorrectly, there are typically very few ways to answercorrectly. In other words, the truth is a Schelling point.
Contrast majority voting with pass@k , where a task is considered solved if any single sample solvesit out of k samples.
See Section 4.2 for more details on pass@k performance.
In Appendix D.1,we report on how performance depends on k for different metrics.
We ﬁnd that while pass@kcontinues to improve as k is increased, majority voting performance saturates faster: 97% of the largek accuracy is achieved at k = 64 for MATH and k = 16 for GSM8k.
This is likely because majorityvoting selects the most common answer in the modeled distribution, and the error of this estimatedecreases with increasing k .
This is in contrast to pass@k where the performance improvementcomes from the tail of the distribution, which can keep improving as k is increased.
Log-likelihood is another metric that can be used to rerank samples.
We found that majority votingperforms signiﬁcantly better than log-likelihood reranking (see Appendix D.2).
Results
Table 3 summarizes the results for Minerva models and other models, on the evaluation datasetsdescribed in Section 2.3. Figure 3 presents a breakdown of the MATH dataset results by subtopic.
For MMLU evaluations, unless otherwise noted, performance is measured by using the standard5-shot prompt per topic and picking the answer with the highest score.
When evaluating MMLU withmajority voting, we sample k = 16 model answers using a chain-of-thought prompt.
We present model output samples in Figures 1 and 2, and additional output samples are listed in the
Appendix. In addition, we evaluated Minerva 62B on the National Math Exam in Poland and foundthat it achieves a score of 57% , which happened to be the national average in 2021 [43, p. 23]. The540B model achieves 65% .
We include results on the latest publicly available language model from OpenAI, davinci-002,evaluated using the OpenAI API with temperature set to the ofﬁcial recommendation ( T = 0 . 2 ).
Thecombination of training data, scale and inference techniques yields state of the art results on all thetechnical tasks that we considered.
For all tasks (with the exception of GSM8k), the improvementwith respect to previous results is considerable. While our main focus is on few shot evaluation, we also tried to ﬁnetune Minerva on MATH; thisdid not yield any improvement; interestingly, however, ﬁnetuning BaseModel on MATH did give asigniﬁcant improvement.
Further details can be found in Appendix D.3.
3.1 Basic arithmetic
In Appendix H, we study the performance of Minerva 540B on simple arithmetic tasks.
The modelachieves over 80% accuracy on 10-digit addition and over 20% accuracy on 18-digit addition.
Performance Analysis
4.1 Model Mistakes
To better understand the types of mistakes our models make, we compare the performance of
Minerva 8B and Minerva 62B on 216 problems with high conﬁdence majority decisions of bothmodels.
Speciﬁcally, we selected examples where the top answer received at least 15% of votes, andthat either Minerva 8B was correct and Minerva 62B was incorrect (15 samples), or vice versa (201samples).
The categories and examples for each category are described in Appendix I.2.
As shown in Table 4, the prevailing errors of the 8B model were related to incorrect reasoning orcalculations.
Many of the calculation errors were relatively benign arithmetic mistakes.
Solutionsthat were too short were relatively rare (in these cases, the model immediately produces an incorrectanswer without any intermediate reasoning steps).
Finally, in a few cases, the model hallucinates anequation or mathematical fact that is not real.
In the samples where the 62B model was incorrect, the dominating failure modes were again incorrectreasoning and incorrect calculations.
In summary, we ﬁnd that the 62B Minerva model retains mostof the skills of the 8B model and improves upon both reasoning and calculation robustness.
[Table]
In our approach to solving quantitative reasoning problems, we are able to automatically verifywhether the ﬁnal answer to a problem is correct, but we do not have an automatic way to verify themodel’s chain of reasoning.
This leaves open the possibility of false positives: samples which havethe correct ﬁnal answer, but for which the reasoning is incomplete or incorrect.
We selected 100 random questions from MATH (20 per difﬁculty level), along with answers sampledat zero temperature from the 62B model.
We then manually inspected the answers to determine the false positive rate, which is the ratio between number of false positive examples and number ofexamples for which the ﬁnal answer is correct; for difﬁculty levels 1, 2, 3, 4, and 5, the false positiverates are < 5% , 10% , < 5% , 15% , and 30% , respectively. Averaging these per-level false positiverates (weighted by true positive rates), the overall false positive rate is estimated to be 8% .
Althoughthis overall rate is low, we ﬁnd that it does increase with difﬁculty level.
Our focus on pass@1 and majority voting as the primary evaluation metrics is due in part to the factthat they are less susceptible to false positives than pass@k [16].
While the pass@256 accuracyis 84 .
5% for the 62B model, false positives account for part of it.
We inspected the samples thatfailed in majority voting but passed on pass@k due to a single correct answer, and estimate the falsepositive rate for pass@256 to be 30% among samples selected in this way.
After removing falsepositives, we estimate that the pass@256 accuracy at greater than 68%; see Appendix I.3 for details.
Memorization
A central question in interpreting Minerva’s solutions is whether performance reﬂects genuine analyticcapability or instead rote memorization.
This is especially relevant as there has been much prior workindicating that language models often memorize some fraction of their training data [44, 45, 46].
When examining model solutions, we ﬁnd that memorization of intermediate facts, such as numericalvalues of square roots or trigonometric identities, are crucial elements of model solutions.
We wouldlike to investigate a strong form of memorization, where model performance is a result of memorizingthe explicit problems and solutions in our evaluation set, but also a weaker form, where the modelhas memorized alternate answers to the same questions.
In order to evaluate the degree to which our models solve problems by recalling information memorized from training data, we conduct three analyses on the MATH dataset.
First we directly searchfor problems and solutions in our training corpus.
Next, we generate modiﬁed versions of problemsand evaluate our models’ robustness to these changes.
Finally, we measure the degree of overlapbetween the ground truth solutions and solutions generated by our model and measure the effect ofthis similarity on model performance.
Overall, we ﬁnd little evidence that the model’s performancecan be attributed to memorization.
5.1 Training and Evaluation Dataset Overlap
We selected the problems for which our 62B parameter model produced a correct answer, and ﬁlteredthem to the 100 problems with the highest majority vote score, expecting that problems with a highmajority vote score are more likely to have been memorized.
For each of these question-answerpairs, we compute the BLEU score across chunks of 500 characters in our Math Web Pages dataset (ahistogram of the BLEU scores is shown in Appendix Figure 9).
We then manually inspect the 250documents with the highest BLEU scores.
While many of the top matches were from homework helpsites with math questions and solutions, none of the questions matched the questions in the subset of
MATH under consideration.
We have included these 250 segments in Appendix J.1.
We note thatsome problems from MATH can be found on the web.
Nevertheless, this analysis concludes thatthese problems did not make it through our data collection process.
5.2 Performance on Modiﬁed MATH Problems
To further investigate memorization, we randomly selected twenty problems which the 62B modelanswered correctly under majority voting.
We manually modiﬁed each problem either by introducingminor changes to problem wording (framing) or by changing the numbers which appeared in theproblem and modifying the solution accordingly.
We then compared the accuracy over sampledsolutions before and after the modiﬁcation.
Results are shown in Figure 4.
In both cases the accuracybefore and after modiﬁcations are correlated, with no clear bias in favor of the original formulation.
This is suggestive of minimal memorization.
The modiﬁed problems are listed in Appendix J.2.
5.3 BLEU Score Between Ground Truth and Generated Solutions
We seek to detect memorization of solutions by computing BLEU score between ground truthanswers and model generated answers.
We use the 62B model and analyze 256 samples per problemin the MATH dataset.
First, we compute overlap statistics for all correct samples.
We ﬁnd that 160 out of 5,000 test questions have a sample with a BLEU score greater than or equal to 80 (see Appendix J.3).
We note that they tend to be short solutions.
To understand the effect of answersimilarity on performance, we remove model samples above a certain BLEU score threshold, andrecompute the majority vote accuracy.
We ﬁnd that majority vote performance is robust even down torelatively low similarities (see Figure 4), indicating that performance cannot be attributed to modeloutputs that are very similar to ground truth answers.
Conclusions and Discussion
In this work, we take an approach to quantitative reasoning that relies on solving problems usingmathematical reasoning expressed in natural language.
We show that by training a large languagemodel on a high quality mathematical dataset, we are able to achieve strong performance on tasksthat require logical reasoning, numerical calculation, and symbolic manipulation.
Our model doesnot make use of external tools, and at inference time relies exclusively on autoregressive samplingto achieve this performance.
Complementary approaches to quantitative reasoning include codegenerating models and formal methods.
These are all different routes toward a common goal: anagent that can reason about and solve quantitative problems.
6.1 Limitations of Our Approach
Our approach to quantitative reasoning has several limitations.
First, we have no automatic wayof verifying the correctness of the model’s answers.
This is in contrast to formal approaches, forwhich automatic veriﬁcation is intrinsic.
Second, our model has no access to external tools such as acalculator or a Python interpreter.
It is therefore limited in its ability to perform quantitative reasoningtasks that require complicated numerical calculations.
Third, because our model was trained on a largeamount of data, we have little direct control over the speciﬁc capabilities that the model acquired.
Our inference time strategy also has limitations.
Majority voting requires generating many samplesand selecting the most common ﬁnal answer.
This can be computationally costly, and importantlyonly works for problems with well deﬁned ﬁnal answers, and so is less well suited for domains suchas theorem proving or open-ended scientiﬁc reasoning.
6.2 Societal Impact
Artiﬁcial neural networks capable of solving quantitative reasoning problems in a general setting havethe potential of substantial societal impact.
Minerva, while a step in this direction, is still far fromachieving this goal, and its potential societal impact is therefore limited.
The model’s performance isstill well below human performance, and furthermore, we do not have an automatic way of verifyingthe correctness of its outputs.
If these issues could be solved, we expect the impacts of this modelto be broadly positive.
A direct application could be an accessible and affordable math tutor whichcould help improve educational inequalities.