Learning to Imagine: Integrating Counterfactual Thinking in Neural Discrete Reasoning (2022)

Abstract: Neural discrete reasoning (NDR) has shown remarkable progress in combining deep models with discrete reasoning. However, we find that existing NDR solution suffers from large performance drop on hypothetical questions, e.g. “what the annualized rate of return would be if the revenue in 2020 was doubled”. The key to hypothetical question answering (HQA) is counterfactual thinking, which is a natural ability of human reasoning but difficult for deep models. In this work, we devise a Learning to Imagine (L2I) module, which can be seamlessly incorporated into NDR models to perform the imagination of unseen counterfactual. In particular, we formulate counterfactual thinking into two steps: 1) identifying the fact to intervene, and 2) deriving the counterfactual from the fact and assumption, which are designed as neural networks. Based on TAT-QA, we construct a very challenging HQA dataset with 8,283 hypothetical questions. We apply the proposed L2I to TAGOP, the state-of-the-art solution on TAT-QA, validating the rationality and effectiveness of our approach.

## introduction neural discrete reasoning @xcite is an emerging technique for machine reading comprehension @xcite ) which aims at answering numerical questions from textual @xcite or hybrid @xcite ) context 1 . ndr combines deep neural network with discrete and symbolic reasoning (e.g., addition, sorting, or counting) @xcite and enables the comprehension of complex contexts and compositional questions, which is critical for many practical applications such as automatic diagnosis @xcite and robo-advisor @xcite . existing state-of-the-art ndr models implement the nu-merical reasoning process as neural network modules @xcite @xcite , e.g., a graph neural network for sorting @xcite . in this work, we extend ndr to hypothetical question answering (hqa), where the question consists of an assumption beyond the context (figure 1 ). the ability of hqa will undoubtedly enhance the practical use of ndr due to the universality of hypothetical questions. however, current ndr models face severe generalization failure on hypothetical questions. an empirical evidence on such vulnerability is that the state-of-the-art model @xcite encounters a sharp performance drop (f1 score drops from 68.6% to 3.8%) on the tat-qa dataset when changing the questions to be hypothetical by adding a related assumption (see details in section 2, in this light, we consider modeling counterfactual thinking as neural network modules that can be seamlessly incorporated into existing ndr models. one straightforward solution is to model counterfactual thinking as a generation procedure with the fact and assumption as inputs by using a generation model such as gpt @xcite . however, such uncontrollable model @xcite can hardly generate high-quality context for two reasons: 1) the context is more complex than plain text, which can include a table (figure 1 ); and 2) ndr requires a precise context with the correct numbers (figure 1 , @xmath0134,298 @xmath1174,550 @xmath2133,682 @xmath3442,530 @xmath4132,935 thousand instead? answer: -29253 counterfactual context fiscal year-end 2019 2018 purchased parts and assemblies @xmath5137,566 work-in-process @xmath6186,240 finished goods @xmath7162,935 total inventories @xmath8486,741 paragraph • inventories are stated at the lower of cost (first-in, first-out or weighted average cost) or net realizable value. inventories are as follows (in thousands): table answer: -30000 (133,682-162,935) (132,935-162,935) imagine figure 1: illustration of hypothetical question and the corresponding counterfactual context to be imagined. by intervening on the factual context. as shown in figure 1 , the assumption changes one entry in the table, e.g., @xmath9132,935. this is coherent with the causal inference theory @xcite where the target variable is intervened according to the hypothetical condition to infer a counterfactual. we propose learning to imagine, where the counterfactual thinking is implemented with two intervening steps: 1) identifying the facts to intervene, and 2) deriving the result of intervention. to pursue accurate context, we derive the intervention with a set of discrete operators such as swap and add for imagination. to evaluate the counterfactual thinking ability, we recruit volunteers with domain expertise to construct an hqa dataset based on tat-qa @xcite by posting an assumption for each original question, named tat-hqa. we apply l2i to tagop @xcite , and obtain a promising solution for hqa. in summary, the main contributions are as follows: ## hypothetical question answering in the general setting of machine reading comprehension, the task is to answer a question according to the facts in a given context. formally, it is to learn a function @xmath10, c), where y, q, and c are the word list representing the answer, the question, and the context foot_0 respectively. this work studies a new and more challenging task that focuses on hypothetical question. as shown in figure 1 , a hypothetical question includes an assumption, e.g., "if the amount in 2019 was $132,935 thousand instead". the target of hqa is to learn @xmath11, c, a) where a denotes the assumption. the existence of an assumption calls for the imagination of a counterfactual context before inferring the answer, pushing the ndr model to grasp both semantic understanding and counterfactual thinking. to facilitate the evaluation of hqa and diagnose counterfactual thinking, we construct an hqa dataset based on tat-qa @xcite , which is a qa dataset with a mix of tabular and textual context extracted from financial reports. inspired by previous work on constructing counterfactual samples @xcite , we recruit college students with finance-related majors to imagine an intervention based on the factual question and context from tat-qa which involves numerical thinking, e.g., a change of number. then they phrase the intervention into an assumption, forming a "what if " type of question, and calculate the answer (see an example in figure 1 ). to ensure the diversity of the phrasing, annotators are free to generate various phrasing of the assumption, and there is no restriction on the position of the assumption. usually, the assumption appears either before of after the factual question. each hypothetical question is related to one factual question from tat-qa, but each factual question in tat-qa is not guaranteed to have one hypothetical question. we follow the quality control approaches of annotator training and two-round validation in tat-qa to guarantee the quality of the hypothetical questions. following tat-qa, the hypothetical questions are also labeled with four answer types: arithmetic, span, count, and multi-span, three types of answer sources: table, text and table-text, and a derivation on how the answer is derived from the context. in total, we obtain 8,283 hypothetical questions, naming it as tat-hqa. the statistics of tat-hqa are shown in we conduct a pilot study on the generalization ability of existing ndr models on hypothetical questions. in particular, we evaluate tagop @xcite , which is the state-of-the-art model on tat-qa (see detailed settings in section 4.1) by training on tat-qa and testing on tat-hqa. in ## methodology we aim to empower ndr models with counterfactual thinking ability. firstly, we decide to choose the approach of explicitly modeling discrete operations, since existing ndr solutions have demonstrated its superiority @xcite @xcite . we devise a learning to imagine module to model counterfactual thinking (section 3.1), and then incorporate the l2i module (section 3.2) into existing nrd methods, followed by a discussion about potential extensions (section 3.3). ## experiments we conduct experiments on tat-hqa dataset to answer the following questions: rq1: how does l2i perform on hqa? rq2: what factors influ- ## conclusion in this work, we pointed out a key issue of existing ndr models: lacking counterfactual thinking. we proposed an l2i module, which can imagine the counterfactual according to a textual assumption. by applying the proposed module in the ndr model, we enable the model to answer hypothetical questions. we constructed a hqa dataset and conducted extensive experiments on the dataset, which validates the effectiveness of our method. this work opens up a new research direction about modeling counterfactual thinking through neural network. in the future, we will further extend the l2i from the following perspectives: 1) handling of multiple interventions; 2) rigorous derivation of intervention with consideration of successors; 3) incorporation of the relations across the deriving operators; and 4) construction of complex operators by dynamically combining basic operators. moreover, we will explore the translation between assumptions in natural language and causal expression to further connect the l2i framework with conventional causal theory, and facilitate automatic causal inference with neural network.