A Causal Lens for Controllable Text Generation

1 Introduction . Controllable text generation aims at producing fluent language with control over various attributes , ranging from sentiment , topic , politeness , to gender , persona , and so forth [ 60 , 22 ] . The problem lies at the heart of many NLP applications such as emotional chatbot , news article writing , language detoxification , etc . Of particular interest in this increasingly significant area are two settings for control , namely ( 1 ) attribute-conditional generation [ 14 , 30 ] which generates sentences that entail a given attribute , and ( 2 ) text attribute transfer [ 64 , 26 ] which rewrites a given sentence to possess a desired attribute while preserving all other original characteristics ( Figure 1 ) . The goal is to learn the control in each setting with ( attribute , text ) training pairs1 . The two settings have usually been considered as separate tasks and each led to various solutions , respectively . Let x denote a sentence and a an attribute . Previous attribute-conditional generation work typically concerns the conditional distribution p ( x|a ) [ 14 , 30 , 33 ] . Despite the success of simulating observed real text , the conditional distribution is known to be susceptible to capture spurious correlations or biases in the data [ 48 , 84 ] . For example , when generating biographical text given a gender attribute , the conditional model tends to generate text related to specific occupations such as nurse and yoga teacher for female , and architect and attorney for male [ 57 , 69 ] ( Figure 1 ) . The learned biases could impair the model generalization to new domains , and make negative social impact in downstream applications . A few very recent attempts have been made to mitigate the biases in the model with various machine learning techniques . Yet those methods are often specific to a particular attribute ( e.g. , gender ) [ 68 , 86 ] , or rely on access to additional resources , such as fully observed confounding labels or a priori debiased classifiers [ 23 , 40 , 67 ] , which can be costly to obtain in real applications . Furthermore , it is unclear how the diverse methods designed for 1Thus , for text attribute transfer ( a.k.a. , text style transfer ) , there is no direct supervision data , i.e. , ( original text , attribute , target text ) triples . 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . attribute-conditional generation could also be applied to debias text attribute transfer that has been formulated with distinct training objectives . This paper studies controllable text generation from a principled causal perspective , that offers a unifying formulation of the two central tasks , and enables mitigation of spurious correlations with well-established causality techniques . A growing number of recent work has used causality with machine learning [ 62 ] for disentangled representation [ 54 , 78 ] , model explanation [ 6 , 13 ] , and robust prediction [ 61 , 24 , 83 ] . Yet most approaches have focused on the vision domain , taking advantage of image spatial structures , and thus are not directly applicable to text with abstract attributes ( such as sentiment ) . Though previous research on text modeling has also studied related concepts such as counterfactuals , it either handles only correlation instead of causation [ 58 , 39 , 76 , 23 , 86 , 46 ] , or focuses on different applications such as data augmentation [ 85 , 28 , 82 ] and classification [ 13 , 29 ] . We discuss more related work in §4 . We develop the first unified causal framework for text generation under control . In particular , we devise a structural causal model ( SCM ) [ 56 ] that describes the causal relationships between different variables , where the text x is outcome and the attribute a to control ( e.g. , sentiment ) is treatment . The SCM further accounts for spurious correlations with confounders ( e.g. , category ) with latent variables . The resulting SCM enables us to formulate the two control tasks as performing causal inference at different rungs of the causal ladder [ 56 ] ( Figure 1 ) , respectively . Specifically , ( 1 ) for attribute-conditional generation , we go beyond the association-based conditional p ( x|a ) and propose to instead use p ( x|do ( a ) ) , corresponding to the intervention rung . The do-operation effectively eliminates the effect of confounders on the control , leading to unbiased text outputs ; ( 2 ) for text attribute transfer , the task naturally maps to counterfactual prediction on the SCM , which answers the question “ what the text would have been if the attribute had been different ” through the standard causal inference procedure [ 56 , 55 ] . The unifying perspective also allows us to draw from existing successful techniques and train the SCM for accurate control and confounder balancing [ 27 , 41 , 22 ] . Previous causal work typically assumes access to confounding labels or relevant proxy information for the entire observed data [ 43 , 44 , 48 ] . In many real applications , however , it is prohibitively expensive or impossible to measure all the confounding factors for unbiased training . For example , it is often not affordable to annotate massively the confounding labels for the entire ( attribute , text ) corpus . We thus consider a more practical yet challenging scenario where we observe confounding information for only a small subset ( e.g. , 1 % − 5 % ) of samples [ 15 ] . We experiment on difficult datasets where the target attributes and confounding factors have strong correlations . Results show the causal approach substantially improves over conventional conditional models with enhanced control accuracy and reduced bias , on both attribute-conditional generation and attribute transfer . 2 Background . We first briefly review the causal concepts most relevant to the paper . A structural causal model ( SCM ) [ 56 ] is defined by a directed graph consisting of nodes ( variables ) and edges ( direct causal dependence between variables ) , e.g. , Figure 2 . Different inference questions on an SCM correspond to different levels of the causal ladder ( Figure 1 ) and require different reasoning tools : ( 1 ) “ Association ” deals with correlations in observed data with joint/marginal/conditional distributions . ( 2 ) “ Intervention ” concerns what would happen were some actions been performed . A typical question is to estimate the distribution of an outcome variable x given an intervention on a treatment variable a : p ( x|do ( a ) ) , where the do-operation represents an action on a by setting it to a given value . With randomized experimental data ( i.e. , collected by randomly assigning treatment ) , p ( x|do ( a ) ) equals to the standard conditional p ( x|a ) . Yet in practice , we usually only have access to passively observed data , such as the ( attribute , text ) pairs from existing corpus , and have to adjust for confounders ( i.e. , variables that correlate with both treatment and outcome ) in order to estimate p ( x|do ( a ) ) from observational distributions . For example , we apply backdoor adjustment [ 56 ] in §3.2 for attribute-conditional generation . Finally , ( 3 ) “ Counterfactuals ” involves queries about what would have happened , given the knowledge of what in fact happened . We next show how the controllable text generation tasks are bridged together as different levels of causal inference , operationalized by the proposed SCM . 3 The Causal Framework for Controllable Text Generation . We now describe the unified causal perspective . We first develop the structural causal model that characterizes the causal structure in the controlled generation process ( §3.1 ) . We then show that intervention on the SCM leads to attribute-conditional generation ( §3.2 ) , while counterfactual prediction makes attribute transfer ( §3.3 ) . At last , §3.4 describes the training of the SCM with new objectives to encourage confounder balancing and de-correlation . Compared to previous causal modeling in other domains ( e.g. , images ) , modeling text as the outcome is challenging due to the complex unstructured information encoded in the text . We show here that the unifying perspective enables us to bring to bear rich tools and inspirations from causal inference , disentangled representation , and controllable generation , for effective text causal modeling . Figure 2 shows the SCM graphs as detailed below . In the appendix we illustrate the model architecture used in our experimental studies . 3.1 The Structural Causal Model . Figure 2 ( a ) shows the SCM that describes the controlled generation process of text . Here the attribute of interest a serves as the treatment , and the text x is the outcome . For simplicity , we assume a is binary ( e.g. , positive or negative sentiment ) , though the framework can straightforwardly be applied to more general cases where a has multiple classes and dimensions . Note that a as the condition for generating x can be instantiated in different forms depending on the concrete application . For example , it can be a scalar a ∈ { 0 , 1 } as an input to the generator , or a word sequence such as a ∈ { “ [ sentiment ] positive ” , “ [ sentiment ] negative ” } that acts as a prompt for the generator to produce text continuation [ 5 , 18 , 30 , 81 ] . In general , the confounder that induces spurious correlations between a and x is infeasible to be fully specified or observed . For example , to control the sentiment of a restaurant review , the confounder could involve popularity of the restaurant , personal preferences of the customer , and other factors , whose values can not be directly measured . Thus , following the recent causal approaches in other domains [ 43 , 48 , 44 ] , we model the unobserved confounder as a high dimensional latent variable z , and infer z from “ indirect ” confounding variables that are measurable in practice ( such as food type ) . The “ indirect ” variables are also called proxy variables in causality [ 50 , 1 , 70 ] , which we denote as c. More background of confounder and proxy is provided in the appendix . The goal of controllable text generation is thus to generate coherent text ( given original text in the case of text attribute transfer ) with accurate target attribute a while unbiased in terms of the confounders . Previous causal studies [ 43 , 48 , 44 ] have usually assumed the confounder proxy c is available for all data . Similarly , recent work of debiasing attribute-conditional generation ( based on machine learning ) has relied on access to those extensive proxy labels [ 23 , 40 ] . However , the assumption is often impractical due to the time and financial cost for obtaining the massive additional information beyond the common ( attribute , text ) data . We thus consider a more practical setting [ 15 ] where we only have access to the proxy information for a small subset ( e.g. , 1 % − 5 % ) of examples . In Figure 2 ( a ) , we use dashed circle of c to denote the new challenging setting . The resulting SCM thus defines a joint distribution pθ ( x , a , z , c ) = pθ ( x|a , z ) pθ ( a|z ) pθ ( c|z ) p0 ( z ) , ( 1 ) where the component pθ ( c|z ) applies when the proxy c is observed for the example ; p0 ( z ) is a standard Gaussian prior following the common practice ; and all components with free parameters θ are modeled as deep neural networks . We use the amortized variational inference as in variational auto-encoders ( VAEs ) [ 31 ] to infer the latent confounder z from observations . Specifically , we introduce a variational distribution qφ ( z|x , a , c ) with parameters φ . To infer z for those examples whose proxy c is not available , we could apply an auxiliary predictor that estimates c from the observed ( x , a ) . The auxiliary predictor can be trained on the subset of examples with available c. In this work , we instead set the default c to a dummy value when inferring z for simplicity . Note that previous work has also used VAEs for controllable text generation [ 22 , 4 ] . However , they reside purely at the association level . In particular , despite the latent variables , they do not explicitly model the confounder and/or its proxy information , rendering the causal effects between components not identifiable [ 56 ] . As a result , those models are vulnerable to biases , as shown in the experiments .

Summary: The goal of the paper is to control an attribute of the text without changing another associated attribute. Let's use the biased YELP dataset the authors created as an exampe. In the dataset, 90% of positive reviews come from restaurants and 90% of negative reviews come from the other categories (e.g., shopping). Their goal is to control the sentiment (attribute a) without changing its category (confounding factor c). This is difficult because the conditional generator might just generate a restaurant review when the task is to generate a positive review. Similarly, if most of the nurses are female, the text generator might just generate nurses to satisfy the requirement of generating a female character.  In conditional generation such as a seq2seq model, even the controlled attribute is given as the condition, the text generator might still generate the text that might imply confounding factors or some other attributes because the confounding factors and controlled attribute are associated or the prior probabilities of those factors/attributes are high. The paper solves the problem using backdoor adjustment (removing the dependency between the attribute a and the hidden representation of the sentence z). My understanding of their method is like assuming confounding factors and controlled attributes are independent or ignore the prior probability of observing other attributes. This would make the generated text less fluent but can generate the text that would have the attribute in a high probability.  The experiments show that the proposed method is significantly better than conditional LM or other text attribute transferring approaches when the training data is biased (e.g., the review category is highly correlated with the sentiment of the review in YELP). When the dataset is unbias, one experiment seems to show that the proposed method is also better than other approaches.