{ "paper_id": "P17-1015", "header": { "generated_with": "S2ORC 1.0.0", "date_generated": "2023-01-19T08:18:56.790075Z" }, "title": "Program Induction by Rationale Generation: Learning to Solve and Explain Algebraic Word Problems", "authors": [ { "first": "Wang", "middle": [], "last": "Ling", "suffix": "", "affiliation": { "laboratory": "", "institution": "University of Oxford", "location": {} }, "email": "lingwang@google.com" }, { "first": "Dani", "middle": [], "last": "Yogatama", "suffix": "", "affiliation": { "laboratory": "", "institution": "University of Oxford", "location": {} }, "email": "dyogatama@google.com" }, { "first": "Chris", "middle": [], "last": "Dyer", "suffix": "", "affiliation": { "laboratory": "", "institution": "University of Oxford", "location": {} }, "email": "cdyer@google.com" }, { "first": "Phil", "middle": [], "last": "Blunsom", "suffix": "", "affiliation": { "laboratory": "", "institution": "University of Oxford", "location": {} }, "email": "pblunsom@google.com" }, { "first": "\u2666", "middle": [ "\u2660" ], "last": "Deepmind", "suffix": "", "affiliation": { "laboratory": "", "institution": "University of Oxford", "location": {} }, "email": "" } ], "year": "", "venue": null, "identifiers": {}, "abstract": "Solving algebraic word problems requires executing a series of arithmetic operations-a program-to obtain a final answer. However, since programs can be arbitrarily complicated, inducing them directly from question-answer pairs is a formidable challenge. To make this task more feasible, we solve these problems by generating answer rationales, sequences of natural language and human-readable mathematical expressions that derive the final answer through a series of small steps. Although rationales do not explicitly specify programs, they provide a scaffolding for their structure via intermediate milestones. To evaluate our approach, we have created a new 100,000-sample dataset of questions, answers and rationales. Experimental results show that indirect supervision of program learning via answer rationales is a promising strategy for inducing arithmetic programs.", "pdf_parse": { "paper_id": "P17-1015", "_pdf_hash": "", "abstract": [ { "text": "Solving algebraic word problems requires executing a series of arithmetic operations-a program-to obtain a final answer. However, since programs can be arbitrarily complicated, inducing them directly from question-answer pairs is a formidable challenge. To make this task more feasible, we solve these problems by generating answer rationales, sequences of natural language and human-readable mathematical expressions that derive the final answer through a series of small steps. Although rationales do not explicitly specify programs, they provide a scaffolding for their structure via intermediate milestones. To evaluate our approach, we have created a new 100,000-sample dataset of questions, answers and rationales. Experimental results show that indirect supervision of program learning via answer rationales is a promising strategy for inducing arithmetic programs.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Abstract", "sec_num": null } ], "body_text": [ { "text": "Behaving intelligently often requires mathematical reasoning. Shopkeepers calculate change, tax, and sale prices; agriculturists calculate the proper amounts of fertilizers, pesticides, and water for their crops; and managers analyze productivity. Even determining whether you have enough money to pay for a list of items requires applying addition, multiplication, and comparison. Solving these tasks is challenging as it involves recognizing how goals, entities, and quantities in the real-world map onto a mathematical formalization, computing the solution, and mapping the solution back onto the world. As a proxy for the richness of the real world, a series of papers have used natural language specifications of algebraic word problems, and solved these by either learning to fill in templates that can be solved with equation solvers (Hosseini et al., 2014; or inferring and modeling operation sequences (programs) that lead to the final answer (Roy and Roth, 2015) .", "cite_spans": [ { "start": 841, "end": 864, "text": "(Hosseini et al., 2014;", "ref_id": "BIBREF6" }, { "start": 952, "end": 972, "text": "(Roy and Roth, 2015)", "ref_id": "BIBREF18" } ], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1" }, { "text": "In this paper, we learn to solve algebraic word problems by inducing and modeling programs that generate not only the answer, but an answer rationale, a natural language explanation interspersed with algebraic expressions justifying the overall solution. Such rationales are what examiners require from students in order to demonstrate understanding of the problem solution; they play the very same role in our task. Not only do natural language rationales enhance model interpretability, but they provide a coarse guide to the structure of the arithmetic programs that must be executed. In fact the learner we propose (which relies on a heuristic search; \u00a74) fails to solve this task without modeling the rationales-the search space is too unconstrained.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1" }, { "text": "This work is thus related to models that can explain or rationalize their decisions (Hendricks et al., 2016; Harrison et al., 2017) . However, the use of rationales in this work is quite different from the role they play in most prior work, where interpretation models are trained to generate plausible sounding (but not necessarily accurate) posthoc descriptions of the decision making process they used. In this work, the rationale is generated as a latent variable that gives rise to the answer-it is thus a more faithful representation of the steps used in computing the answer.", "cite_spans": [ { "start": 84, "end": 108, "text": "(Hendricks et al., 2016;", "ref_id": "BIBREF5" }, { "start": 109, "end": 131, "text": "Harrison et al., 2017)", "ref_id": "BIBREF4" } ], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1" }, { "text": "This paper makes three contributions. First, we have created a new dataset with more than 100,000 algebraic word problems that includes both answers and natural language answer rationales ( \u00a72).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Introduction", "sec_num": "1" }, { "text": "Problem 1: Question: Two trains running in opposite directions cross a man standing on the platform in 27 seconds and 17 seconds respectively and they cross each other in 23 seconds. The ratio of their speeds is: Options: A) 3/7 B) 3/2 C) 3/88 D) 3/8 E) 2/2 Rationale: Let the speeds of the two trains be x m/sec and y m/sec respectively. Then, length of the first train = 27x meters, and length of the second train = 17 y meters. (27x + 17y) / (x + y) = 23 \u2192 27x + 17y = 23x + 23y \u2192 4x = 6y \u2192 x/y = 3/2. Correct Option: B Problem 2: Question: From a pack of 52 cards, two cards are drawn together at random. What is the probability of both the cards being kings? Options: A) 2/1223 B) 1/122 C) 1/221 D) 3/1253 E) 2/153 Rationale: Let s be the sample space. Then n(s) = 52C2 = 1326 E = event of getting 2 kings out of 4 n(E) = 4C2 = 6 P(E) = 6/1326 = 1/221 Answer is C Correct Option: C Problem 3: Question: For which of the following does p(a)\u2212p(b) = p(ab) for all values of a and b? Options:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 1 illustrates three representative instances", "sec_num": null }, { "text": "A) p(x) = x 2 , B) p(x) = x/2, C) p(x) = x + 5, D) p(x) = 2x1, E) p(x) = |x|", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 1 illustrates three representative instances", "sec_num": null }, { "text": "Rationale: To solve this easiest way is just put the value and see that if it equals or not. with option A. p(a) = a 2 and p(b from the dataset. Second, we propose a sequence to sequence model that generates a sequence of instructions that, when executed, generates the rationale; only after this is the answer chosen ( \u00a73). Since the target program is not given in the training data (most obviously, its specific form will depend on the operations that are supported by the program interpreter); the third contribution is thus a technique for inferring programs that generate a rationale and, ultimately, the answer. Even constrained by a text rationale, the search space of possible programs is quite large, and we employ a heuristic search to find plausible next steps to guide the search for programs ( \u00a74). Empirically, we are able to show that state-of-the-art sequence to sequence models are unable to perform above chance on this task, but that our model doubles the accuracy of the baseline ( \u00a76).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 1 illustrates three representative instances", "sec_num": null }, { "text": ") = b 2 so L.H.S = a 2 \u2212 b 2 and R.H.S = (a \u2212 b) 2 \u2192 a 2 + b 2 \u2212 2ab. so L.H.S not equal to R.H.S with option B. p(a) = a/2 and p(b) = b/2 L.H.S = a/2 \u2212 b/2 \u2192 1/2(a \u2212 b) R.H.S = (a \u2212 b)/2 so L", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Figure 1 illustrates three representative instances", "sec_num": null }, { "text": "We built a dataset with 100,000 problems with the annotations shown in Figure 1 . Each question is decomposed in four parts, two inputs and two outputs: the description of the problem, which we will denote as the question, and the possible (multiple choice) answer options, denoted as options. Our goal is to generate the description of the rationale used to reach the correct answer, denoted as rationale and the correct option label. Problem 1 illustrates an example of an algebra problem, which must be translated into an expression (i.e., (27x + 17y)/(x + y) = 23) and then the desired quantity (x/y) solved for. Problem 2 is an example that could be solved by multi-step arithmetic operations proposed in (Roy and Roth, 2015) . Finally, Problem 3 describes a problem that is solved by testing each of the options, which has not been addressed in the past.", "cite_spans": [ { "start": 710, "end": 730, "text": "(Roy and Roth, 2015)", "ref_id": "BIBREF18" } ], "ref_spans": [ { "start": 71, "end": 79, "text": "Figure 1", "ref_id": "FIGREF0" } ], "eq_spans": [], "section": "Dataset", "sec_num": "2" }, { "text": "We first collect a set of 34,202 seed problems that consist of multiple option math questions covering a broad range of topics and difficulty levels. Examples of exams with such problems include the GMAT (Graduate Management Admission Test) and GRE (General Test). Many websites contain example math questions in such exams, where the answer is supported by a rationale.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Construction", "sec_num": "2.1" }, { "text": "Next, we turned to crowdsourcing to generate new questions. We create a task where users are presented with a set of 5 questions from our seed dataset. Then, we ask the Turker to choose one of the questions and write a similar question. We also force the answers and rationale to differ from the original question in order to avoid paraphrases of the original question. Once again, we manually check a subset of the jobs for each Turker for quality control. The type of questions generated using this method vary. Some turkers propose small changes in the values of the questions (e.g., changing the equality p(a)p(b) = p(ab) in Problem 3 to a different equality is a valid question, as long as the rationale and options are rewritten to reflect the change). We designate these as replica problems as the natural language used in the question and rationales tend to be only minimally unaltered. Others propose new problems in the same topic where the generated questions tend to differ more radically from existing ones. Some Turkers also copy math problems available on the web, and we define in the instructions that this is not allowed, as it will generate multiple copies of the same problem in the dataset if two or more Turkers copy from the same resource. These Turkers can be detected by checking the nearest neighbours within the collected datasets as problems obtained from online resources are frequently submitted by more than one Turker. Using this method, we obtained 70,318 additional questions.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Construction", "sec_num": "2.1" }, { "text": "Descriptive statistics of the dataset is shown in Figure 1 . In total, we collected 104,519 problems (34,202 seed problems and 70,318 crowdsourced problems). We removed 500 problems as heldout set (250 for development and 250 for testing). As replicas of the heldout problems may be present in the training set, these were removed manually by listing for each heldout instance the closest problems in the training set in terms of character-based Levenstein distance. After filtering, 100,949 problems remained in the training set. We also show the average number of tokens (total number of tokens in the question, options and rationale) and the vocabulary size of the questions and rationales. Finally, we provide the same statistics exclusively for tokens that are numeric values and tokens that are not. Figure 2 shows the distribution of examples based on the total number of tokens. We can see that most examples consist of 30 to 500 tokens, but there are also extremely long examples with more than 1000 tokens in our dataset.", "cite_spans": [], "ref_spans": [ { "start": 50, "end": 58, "text": "Figure 1", "ref_id": "FIGREF0" }, { "start": 806, "end": 814, "text": "Figure 2", "ref_id": "FIGREF1" } ], "eq_spans": [], "section": "Statistics", "sec_num": "2.2" }, { "text": "Generating rationales for math problems is challenging as it requires models that learn to perform math operations at a finer granularity as each step within the solution must be explained. 17y)/(x + y) = 23 must be solved to obtain the answer. In previous work , this could be done by feeding the equation into an expression solver to obtain x/y = 3/2. However, this would skip the intermediate steps 27x + 17y = 23x + 23y and 4x = 6y, which must also be generated in our problem. We propose a model that jointly learns to generate the text in the rationale, and to perform the math operations required to solve the problem. This is done by generating a program, containing both instructions that generate output and instructions that simply generate intermediate values used by following instructions.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Model", "sec_num": "3" }, { "text": "In traditional sequence to sequence models (Sutskever et al., 2014; Bahdanau et al., 2014) , the goal is to predict the output sequence y = y 1 , . . . , y |y| from the input sequence x = x 1 , . . . , x |x| , with lengths |y| and |x|.", "cite_spans": [ { "start": 43, "end": 67, "text": "(Sutskever et al., 2014;", "ref_id": "BIBREF20" }, { "start": 68, "end": 90, "text": "Bahdanau et al., 2014)", "ref_id": "BIBREF1" } ], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "In our particular problem, we are given the problem and the set of options, and wish to predict the rationale and the correct option. We set x as the sequence of words in the problem, concatenated with words in each of the options separated by a special tag. Note that knowledge about the possible options is required as some problems are solved by the process of elimination or by testing each of the options (e.g. Problem 3). We wish to generate y, which is the sequence of words in the rationale. We also append the correct option as the last word in y, which is interpreted as the chosen option. For example, y in Problem 1 is \"Let the . . . = 3/2 . EOR B EOS \", whereas in Problem 2 it is \"Let s be . . . Answer is C EOR C EOS \", where \" EOS \" is the end of sentence symbol and \" EOR \" is the end of rationale symbol.", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "i x z v r From Id(\"Let\") Let y1 a Id(\"s\") s y2 pack", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Id(\"be\") be y3 of Id(\"the\") the y4 52", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Id(\"sample\") sample y5 cards Id(\"space\") space y6 , Id(\".\") . y7 two Id(\"\\n\") \\n y8 cards Id(\"Then\") Then y9 are", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Id(\"n\") n y10 drawn Id(\"(\") ( y11 together Id(\"s\") s y12 at Id(\")\") ) y13 random Id(\"=\") = y14 . Str to Float(x5) 52 m1 What", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Float to Str(m1) 52 y15 is Id(\"C\") C y16 the Id(\"2\") 2 y17 probability Id(\"=\") = y18 of Str to Float(y17) 2 m2 both Choose(m1,m2) 1326 m3 cards", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Float to Str(m3) 1326 y19 being Id(\"E\") E y20 kings Id(\"=\") = y21 ?", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "Id(\"event\") event ", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "y22 Id(\"of\") of y23 A) Id(\"getting\") getting y24 2/1223 Id(\"2\") 2 y25 Id(\"kings\") kings y26 B) Id(\"out\") out y27 1/122 Id(\"of\") of y28 . . . . . . . . . . . . . . . |z| Id(\" EOS \") EOS y |y|", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Problem Definition", "sec_num": "3.1" }, { "text": "We wish to generate a latent sequence of program instructions, z = z 1 , . . . , z |z| , with length |z|, that will generate y when executed. We express z as a program that can access x, y, and the memory buffer m. Upon finishing execution we expect that the sequence of output tokens to be placed in the output vector y. Table 2 illustrates an example of a sequence of instructions that would generate an excerpt from Problem 2, where columns x, z, v, and r denote the input sequence, the instruction sequence (program), the values of executing the instruction, and where each value v i is written (i.e., either to the output or to the memory). In this example, instructions from indexes 1 to 14 simply fill each position with the observed output y 1 , . . . , y 14 with a string, where the Id operation simply returns its parame-ter without applying any operation. As such, running this operation is analogous to generating a word by sampling from a softmax over a vocabulary. However, instruction z 15 reads the input word x 5 , 52, and applies the operation Str to Float, which converts the word 52 into a floating point number, and the same is done for instruction z 20 , which reads a previously generated output word y 17 . Unlike, instructions z 1 , . . . , z 14 , these operations write to the external memory m, which stores intermediate values. A more sophisticated instruction-which shows some of the power of our model-is z 21 = Choose(m 1 , m 2 ) \u2192 m 3 which evaluates m 1 m 2 and stores the result in m 3 . This process repeats until the model generates the end-of-sentence symbol. The last token of the program as said previously must generate the correct option value, from \"A\" to \"E\". By training a model to generate instructions that can manipulate existing tokens, the model benefits from the additional expressiveness needed to solve math problems within the generation process. In total we define 22 different operations, 13 of which are frequently used operations when solving math problems. These are: Id, Add, Subtract, Multiply, Divide, Power, Log, Sqrt, Sine, Cosine, Tangent, Factorial, and Choose (number of combinations). We also provide 2 operations to convert between Radians and Degrees, as these are needed for the sine, cosine and tangent operations. There are 6 operations that convert floating point numbers into strings and vice-versa. These include the Str to Float and Float to Str operations described previously, as well as operations which convert between floating point numbers and fractions, since in many math problems the answers are in the form \"3/4\". For the same reason, an operation to convert between a floating point number and number grouped in thousands is also used (e.g. 1000000 to \"1,000,000\" or \"1.000.000\"). Finally, we define an operation (Check) that given the input string, searches through the list of options and returns a string with the option index in {\"A\", \"B\", \"C\", \"D\", \"E\"}. If the input value does not match any of the options, or more than one option contains that value, it cannot be applied. For instance, in Problem 2, once the correct probability \"1/221\" is generated, by applying the check operation to this number we can obtain correct option \"C\". Figure 3 : Illustration of the generation process of a single instruction tuple at timestamp i.", "cite_spans": [], "ref_spans": [ { "start": 322, "end": 329, "text": "Table 2", "ref_id": "TABREF2" }, { "start": 3228, "end": 3236, "text": "Figure 3", "ref_id": null } ], "eq_spans": [], "section": "Generating Programs to Generate Rationales", "sec_num": "3.2" }, { "text": "h i softmax o i r i softmax r i q i,j=1 softmax q ij softmax copy input a ij q i,j+1 copy output h i+1 j < argc(o i )? v i execute", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Generating Programs to Generate Rationales", "sec_num": "3.2" }, { "text": "In our model, programs consist of sequences of instructions, z. We turn now to how we model each z i , conditional on the text program specification, and the program's history. The instruction z i is a tuple consisting of an operation (o i ), an ordered sequence of its arguments (a i ), and a decision about where its results will be placed (r i ) (is it appended in the output y or in a memory buffer m?), and the result of applying the operation to its arguments (", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Generating and Executing Instructions", "sec_num": "3.3" }, { "text": "v i ). That is, z i = (o i , r i , a i , v i ).", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Generating and Executing Instructions", "sec_num": "3.3" }, { "text": "Formally, o i is an element of the pre-specified set of operations O, which contains, for example add, div, Str to Float, etc. The number of arguments required by o i is given by argc(o i ), e.g., argc(add) = 2 and argc(log) = 1. The arguments are a i = a i,1 , . . . , a i,argc(o i ) . An instruction will generate a return value v i upon execution, which will either be placed in the output y or hidden. This decision is controlled by r i . We define the instruction probability as:", "cite_spans": [], "ref_spans": [], "eq_spans": [], "section": "Generating and Executing Instructions", "sec_num": "3.3" }, { "text": "p(o i , a i , r i ,v i | z