Investigating the Robustness of Natural Language Generation from Logical Forms via Counterfactual Samples (2022)

Abstract: The aim of Logic2Text is to generate controllable and faithful texts conditioned on tables and logical forms, which not only requires a deep understanding of the tables and logical forms, but also warrants symbolic reasoning over the tables according to the logical forms. State-of-the-art methods based on pre-trained models have achieved remarkable performance on the standard test dataset. However, we question whether these methods really learn how to perform logical reasoning, rather than just relying on the spurious correlations between the headers of the tables and operators of the logical form. To verify this hypothesis, we manually construct a set of counterfactual samples, which modify the original logical forms to generate counterfactual logical forms with rare co-occurred headers and operators and corresponding counterfactual references. SOTA methods give much worse results on these counterfactual samples compared with the results on the original test dataset, which verifies our hypothesis. To deal with this problem, we firstly analyze this bias from a causal perspective, based on which we propose two approaches to reduce the model’s reliance on the shortcut. The first one incorporates the hierarchical structure of the logical forms into the model. The second one exploits automatically generated counterfactual data for training. Automatic and manual experimental results on the original test dataset and counterfactual dataset show that our method is effective to alleviate the spurious correlation. Our work points out the weakness of current methods and takes a further step toward developing Logic2Text models with real logical reasoning ability.

## introduction recently, generating logical consistent natural language from tables has attracted the attention of the research community @xcite figure 1 : the gpt-2 based model makes a fluent and logical consistent prediction on the original logic2text sample, but generates a sentence logically inconsistent with the logical form of the counterfactual sample. state-of-the-art methods based on pre-trained models @xcite have achieved remarkable performance on the standard test dataset of logic2text. figure 1 shows an original sample of the task. however, we question whether these methods really learn how to perform logical reasoning, rather than just relying on the spurious correlations 1 between table headers such as "attendance" and logical operators such as "argmax". several previous studies have demonstrated that such shortcuts severely damage the robustness of models @xcite . to verify our hypothesis, we manually construct a set of counterfactual samples from the development set and test set of logic2text, named lcd (logical counterfactual data) 2 . we modify the original logical forms to generate counterfactual logical forms with rarely co-occurred table headers and logical operators, then we annotate the corresponding counterfactual label sentences. figure 1 compares the original sample of logic2text and the corresponding counterfactual sample. gpt-2 based model makes a fluent and logical consistent prediction on the original sample. however, for the counterfactual sample, the model still employs the "argmax" logical operator to describe "attendance", which is inconsistent with the logical form. the reason we suppose is that in the training dataset there are a large number of logical forms containing " argmax { all_rows ; attendance }", which is used to describe the phrase "the highest attendance". a model trained on this biased dataset would learn to exploit such spurious correlations to make predictions, thus failing to perform correct logical reasoning on the counterfactual samples. we evaluate the state-of-the-art methods on lcd, and they give much worse results compared with the results on the original test set. in addition to the bias in the training dataset, previous works directly using linearized logical forms as inputs fail to understand the hierarchical structure of the logical forms, which further aggravates the models to learn the spurious associations between the logical operators and the table headers. to deal with this problem, we firstly leverage 1 spurious correlations or shortcuts refer to connections between two variables that are non-causal in statistics @xcite . ## causal analysis to deal with this problem, we utilize causal inference @xcite to analyze this bias. the left graph of figure 3 illustrates the overall training process of conventional logic2text models from a causal perspective, where vertex l and y denote the linearized logical form and the label sentence, respectively. vertex u represents an unobserved confounder in logic2text foot_0 , which we suppose is the preference of the annotators to describe a table. there are also three edges in the left causal graph: @xmath0, @xmath1. edge @xmath2, respectively. @xmath3. this link is the objective that the model should learn. concretely, in the logic2text task, the confounder u can be interpreted as the preference of the annotators to describe a table. for example, given a table recording sports events, the annotators prefer to describe the game with the largest crowd attendance rather than the most recent game. as a consequence, this unobserved confounder has direct effects on the generation of the logical form (@xmath4, and the generation of the label sentence (@xmath5. these effects finally build a backdoor path from the logical form to the label sentence (l ← @xmath6. the backdoor path induces the model to learn the shortcut between the logical form and the label sentence, rather than the process of reasoning sentence from the real structure of logical form (@xmath7. for example, when a model trained on a dataset in which a large number of logical forms containing " argmax { all_rows ; attendance }", the model can make correct predictions "the highest attendance". however, when testing on the logical form " argmax { all_rows ; date }", the model leverages this shortcut and still employs the "argmax" logical operator to describe "attendance", which is inconsistent with the logical form. formally, given a confounder u , there exists a logical operator o @xmath8, h j |u ) is much higher than p(o i , h k |u ) for other h @xmath9, where o, h represent the set of logical operators and table headers in the dataset respectively. p(o, h) denotes the probability that the header h should reason with operator o. in this case, the models actually learns the probability p (y |u, l, t ), rather than p (y |l, t ). ## methodology based on the above analysis, we make two modifications on the causal graph as shown on the right part of figure 3 . firstly, we propose structureaware logical form encoder to build @xmath10. secondly, we remove the backdoor path l ← @xmath11. ## experiments in this section we conduct experiments on both the biased logic2text dataset and the counterfactual dataset, lcd. we compare our method with other sota models, and discuss the experimental results. baselines we use 1) the pointer generator network @xcite , 2) snowball @xcite , 3) gpt-2 @xcite and 4) t5 @xcite as baselines. the details about the baselines are shown in appendix c. ## case study we select a counterfactual sample from lcd to demonstrate why our method could perform better than previous works using the attention score distributions when decoding. the linearized logical form of the sample is "eq{ hop {argmax {all_rows ; score };attendance };5032}", and the label sentence is "the game with the highest score had 5032 spectators". specifically, after decoding the "highest" or "largest" token corresponding to the "argmax" logical operator in the logical form, we plot the attention values of the last transformer layer for each token of the logical form to explore which table header the model would choose, as shown in figure 6. as seen, for vanilla gpt-2, the attention score of the token "attendance" is higher than on "score", thus producing "highest attendance". for our method, the attention score of the token "score" achieves the largest, which is the corresponding table header the operator "argmax" should select. however, they all ignored the spurious correlation in logical forms, which is investigated in our work. ## conclusion we investigate the robustness of current methods for logic2text via a set of manually constructed counterfactual samples. a significant decline on the counterfactual dataset verifies the existence of bias in the training dataset. then we leverage causal inference to analyze the bias, based on which, two approaches are proposed to reduce the spurious correlations. automatic and manual experimental results on both logic2text and the counterfactual data demonstrate that our method is effective to alleviate the spurious correlations.