Text Attribute Control via Closed-Loop Disentanglement (2024)

Abstract: Changing an attribute of a text without changing the content usually requires first disentangling the text into irrelevant attributes and content representations. After that, in the inference phase, the representation of one attribute is tuned to a different value, expecting that the corresponding attribute of the text can also be changed accordingly. The usual way of disentanglement is to add some constraints on the latent space of an encoder-decoder architecture, including adversarial-based constraints and mutual-information-based constraints. However, previous semi-supervised processes of attribute change are usually not enough to guarantee the success of attribute change and content preservation. In this paper, we propose a novel approach to achieve a robust control of attributes while enhancing content preservation. In this approach, we use a semi-supervised contrastive learning method to encourage the disentanglement of attributes in latent spaces. Differently from previous works, we re-disentangle the reconstructed sentence and compare the re-disentangled latent space with the original latent space, which makes a closed-loop disentanglement process. This also helps content preservation. In addition, the contrastive learning method is also able to replace the role of minimizing mutual information and adversarial training in the disentanglement process, which alleviates the computation cost. We conducted experiments on three text datasets, including the Yelp Service review dataset, the Amazon Product review dataset, and the GoEmotions dataset. The experimental results show the effectiveness of our model.

## introduction controlling the attributes of a text is an important application of interpretable natural language models. the term ''control'' usually means to take attributes as a handle, and pulling the handle causes corresponding changes in the text. the control process should not change the content of the text as is shown in figure 1 . usually, this is realized by disentangling the text into multiple irrelevant latent spaces for content and multiple attributes @xcite . previous work mainly use two methods for disentangling the attributes: adversarial learning @xcite and mutual information minimization @xcite . for each latent space (corresponding to the content or attributes), the former @xcite applies adversarial training to reduce the information that should not be contained in that space. also, @xcite uses an adversarial method to encourage the generated text to be compatible with the tuned attributes. to alleviate the training cost and the instability of adversarial methods, @xcite and @xcite proposed to minimize the mutual information between different latent spaces. when changing attributes, previous methods change the representation of an attribute in the latent space, expecting the generated text to satisfy the changed attribute. however, the generated text does not necessarily do so and preserve the content as well as other attributes, if this is not explicitly encouraged in the training process. in this paper, we propose a novel attribute control model, which uses contrastive learning to make the latent representation of attributes irrelevant to each other, while encouraging the content to be unchanged during attribute control. we still use an autoencoder architecture to disentangle the text into latent spaces. inspired by closed-loop control systems @xcite and closed-loop data transcription @xcite , we utilize the encoder once more to disentangle the generated text into re-disentangled latent figure 1 : attribute control: a sentence is disentangled into separate attributes. each dashed circle represents an attribute. after one of the attributes was changed to another value (here, attribute 3 was changed from a circle to a triangle), the corresponding attribute of the reconstructed sentence was changed accordingly. our contributions are briefly summarized as follows: implicit disentanglement does not use the attribute annotations in the training dataset, so for each disentangled component, it is hard to tell exactly which attribute it corresponds to. implicit disentanglement includes β-vae @xcite , β-tcvae @xcite , and many derivatives @xcite @xcite @xcite @xcite . the basic principle of implicit disentanglement is to capture the internal relationship between input examples. for example, @xcite break the evidence lower bound (elbo) into several parts and proposed the total correlation, which encourages the different attributes to be statistically independent. total correlation is also the cornerstone for mtdna @xcite . @xcite further break the elbo into more segments and discussed the effect of each segment toward implicit disentanglement. however, without the help of annotation, it is difficult for implicit disentanglement to obtain better disentangled latent spaces than explicit disentanglement. ## approach in this section, we introduce the design of our model for contrastive learning disentanglement (cld). differently from previous work, our proposed model is very simple, as it only contains the basic encoder-decoder architecture and three contrastive learning loss functions. the architecture of our model is shown in figure 2 . ## discussion recent work has explored utilizing large language models (llms) like chatgpt and gpt-4 for controllable text generation. for example, @xcite have proposed methods to steer text style transfer in these llms by conditioning on discrete attributes or continuous latent representations. compared to our approach, a key difference is that we train our model end-to-end to disentangle latent attributes, while llms rely on prompting or fine-tuning approaches applied post-hoc. every one is so tepid, and the food is awful. an excellent dining experience . the dining feels bad . an awful dining experience . original (neg) vanilla transferred (pos) vae transferred (pos) crap service with mediocre food is not a good business model to live by . the staff does a great job working with my teenagers. this machine was exactly a speller . the machine was a speller, just as its name indicated. ## limitations controlling the attribute's intensity our model is not designed to control the intensity of an attribute, like generating some neutral sentence instead of ''pos'' or ''neg''. if we want to generate a neutral sentence anyway, we just need to take the average vector of the mean value of the ''pos'' and ''neg'', and replace the original semantic style vector. then, the decoder will generate a neutral sentence. however, this method will not always be successful, because there is no guarantee that these latent spaces are smoothly distributed with overlapping regions, and the original vanilla transferred vae transferred my friend and i have been having good fun queuing mei/winston, trololo, and 2 bottles of whisky. (joy) my friend and i have been anxiously queueing mei/winston, trololo, and 2 bottles of whisky (fear) my friend and i anxiously wait in the endless, crawling queue for mei/winston, trololo, and 2 bottles of whisky. (fear) and then you're stuck on that medication for life, sounds like a scary trade-off. (fear) and then i guess you're stuck taking that medicine forever and ever, seems like a real bummer of a trade-off.(sadness) and then you're frustratedly stuck on that medication for life, sounds like a grim trade-off. (sadness) it's hurting my heart :( why did you leave me (sadness) it's sickening my heart :( why did you abandon me. (disgust) it's breaking my heart :( why did you betray and leave me in such a repulsive manner. (disgust) gross. i hate using those reusable cloth ones because they retain smells. you've got cats? i know, i can smell them. (disgust) damn it. it infuriates me to use those reusable fabric ones since they hold onto scents. throw out these cats! (anger) damn it. i detest using those reusable cloth ones because they retain odors. you've got cats? i know, i can detect their stench. (anger) i do remember this and wanted nothing more than to kill that guy (anger) yeah i totally remember this and was like, woah, my mind was blown about that guy. (surprised) i do recall this vividly and was utterly astonished at that guy. (surprised) can't believe [name] has been in the league that long. . . (surprised) it's amazing that [name] has been in the league that long! (joy) it's so thrilling that [name] has already been playing in the league for that many years! (joy) difficult attributes apart from the simple text attributes, there are also some complex attributes like some specific author's style of writing, which are usually intertwined together in the latent space. discrete categorical style types are hard to design for such kind of complex attributes. whether disentanglement can be used for controlling complex attributes requires further research. ## conclusion in this paper, we proposed a novel explicit disentanglement method, called contrastive learning disentanglement (cld), which uses contrastive learning as the core method. differently from previous works, we re-disentangle the reconstructed sentences, and conduct contrastive learning between the disentangled vectors and the re-disentangled vectors. to encourage the disentanglement of the attributes' latent space, we propose the re-disentangled contrastive loss l re and the transferred re-disentangled contrastive loss lk . the latter fully imitates the attribute control process. to encourage content preservation, we proposed the content contrastive loss l c , which contains three sub-losses. these sub-losses make the content space more distinguishable and encourage the content keep unchanged during attribute control. our proposed method is not only much easier in the mathematical derivations, it also outperforms all the compared methods in the evaluation metrics according to our experimental results.