Forward-Backward Reasoning in Large Language Models for Mathematical Verification (2024)

Abstract: Self-Consistency samples diverse reasoning chains with answers and chooses the final answer by majority voting. It is based on forward reasoning and cannot further improve performance by sampling more reasoning chains when saturated. To further boost performance, we introduce backward reasoning to verify candidate answers. Specifically, for mathematical tasks, we mask a number in the question and ask the LLM to answer a backward question created by a simple template, i.e., to predict the masked number when a candidate answer is provided. Instead of using forward or backward reasoning alone, we propose **FOBAR** to combine **FO**rward and **BA**ckward **R**easoning for verification. Extensive experiments on six standard mathematical data sets and three LLMs show that FOBAR achieves state-of-the-art performance. In particular, FOBAR outperforms Self-Consistency, which uses forward reasoning alone, demonstrating that combining forward and backward reasoning is more accurate in verification. In addition, FOBAR achieves higher accuracy than existing verification methods, showing the effectiveness of the simple template used in backward reasoning and the proposed combination.

## introduction pre-trained large language models (llms) @xcite @xcite generalize well on unseen tasks by few-shot prompting (or in-context learning (icl) @xcite @xcite @xcite . this is performed by concatenating a few examples (e.g., question-answer pairs) as a prompt, and then appending the testing question. however, it is still challenging for llms to answer mathematical questions by simply prompting the question-answer pairs, as mathematics is more complex and often requires many steps to derive the answer. recently, @xcite propose chain-ofthought (cot) prompting, which generates explicit intermediate steps that are used to reach the answer, for llms. specifically, each in-context example is augmented with several thinking steps described in natural language. a few examples are concatenated as a cot prompt. in inference, the testing question is appended to the prompt and then fed to an llm. the llm is expected to imitate the incontext examples, i.e., generating several reasoning steps before giving the answer. cot prompting has achieved promising performance on mathematical reasoning tasks @xcite @xcite , and many works have been proposed to improve its effectiveness @xcite @xcite @xcite and efficiency @xcite @xcite . self-consistency @xcite is a simple yet effective approach to improve cot prompting. using temperature sampling @xcite , it samples a diverse set of reasoning chains which may lead to multiple candidate answers. the one that receives the most votes is then chosen as the final answer. however, our experimental results foot_0 shows that simply sampling more reasoning paths may not lead to improvement in testing accuracy, particularly when the number of sampling paths is already large. moreover, among the failure questions of self-consistency, about 60% have at least one reasoning chain reaching the correct answer ( we introduce backward reasoning (or backward p(23) / p p f (23)p b (23) ⇡ 2.45 ⇥ 10 5 < l a t e x i t s h a 1 _ b a s e 6 4 = " m r a x h u r h i r m c s f s h c v 5 l l l y x 6 u @xmath0 figure 1 : a case study for the proposed forba method. as forward reasoning and backward reasoning are complementary, we propose a forward-backward reasoning (fobar) method to combine them. by estimating the forward probability p f ( âc ) as the proportion of votes âc gets in the forward direction, we propose to estimate the probability that âc is correct (denoted by p( âc )) as the geometric mean of forward and backward probabilities, i.e., p( âc ) ∝ p f ( âc ) our contributions are summarized as follows. ## related work chain-of-thought (cot) prompting. @xcite propose augmenting question-answer pairs with intermediate steps such that the llm can solve questions step-by-step. specifically, each in-context example is a triplet (q (i) , r (i) , a ⋆(i) ), where r (i) is a reasoning chain with natural language descriptions of steps leading from the question q (i) to the ground-truth answer a ⋆(i) . in inference, a new question q is appended to the prompt: and "p cot \n question: q \n answer:" is fed to the llm for generating both its reasoning chain r and answer a. cot prompting has achieved sota performance on a wide variety of tasks @xcite @xcite @xcite @xcite @xcite . a: jim spends 2 hours watching tv … spend 4*9=36 hours on tv and reading. the answer is 36. a: jim spends 2 hours watching tv and reads for half ... the answer is 12. … q: jim spends 2 hours watching tv and then decides to go to bed and reads for half as long. he does this 3 times a week. how many hours does he spend on tv and reading in 4 weeks? (answer: 36) forward reasoning fobar: forward-backward reasoning a: jim spends 2 hours … the value of x is 3. a: jim watches 2 hours tv, then ... the value of x is 3. … q: jim spends 2 hours watching tv and then decides to go to bed and reads for half as long. he does this x times a week. how many hours does he spend on tv and reading in 4 weeks? if we know the answer of the above question is 36, what is the value of unknown variable x? a: jim spends 2 hours … the value of x is 4. a: jim watches 2 hours tv ... the value of x is 3. q: jim spends 2 hours watching tv and then decides to go to bed and reads for half as long. he does this x times a week. how many hours does he spend on tv and reading in 4 weeks? if we know the answer of the above question is 12, what is the value of unknown variable x? ## forward-backward reasoning for verification in this section, we propose the fobar method for verification. an overview is shown in figure 2 . we first consider mathematical reasoning tasks. a set of candidate answers is generated in the forward direction, and we estimate each answer's probability based on the votes it receives (section 3.1). next, we mask a number in the question and propose a simple template to create backward questions for verifying candidate answers (section 3.2). we further propose fobar (section 3.3) to combine forward and backward reasoning. extension to non-mathematical tasks is discussed in section 3.4. ## conclusion in this paper, we study the problem of verifying candidate answers to mathematical problems using chain-of-thought prompting. to complement the use of only forward reasoning for verification, we introduce backward reasoning: a simple template is introduced to create questions and a prompt is designed to ask the llm to predict a masked word when a candidate answer is provided. furthermore, we proposed fobar to combine forward and backward reasoning for verification. extensive experiments on six standard mathematical data sets and three llms show that the proposed fobar achieves state-of-the-art performance on mathematical reasoning tasks. fobar can also be used on non-mathematical tasks and achieves superior performance.