Text Style Transfer via Optimal Transport (2022)

Abstract: Text style transfer (TST) is a well-known task whose goal is to convert the style of the text (e.g., from formal to informal) while preserving its content. Recently, it has been shown that both syntactic and semantic similarities between the source and the converted text are important for TST. However, the interaction between these two concepts has not been modeled. In this work, we propose a novel method based on Optimal Transport for TST to simultaneously incorporate syntactic and semantic information into similarity computation between the source and the converted text. We evaluate the proposed method in both supervised and unsupervised settings. Our analysis reveal the superiority of the proposed model in both settings.

## introduction text style transfer (tst) is an important task in nlp that aims to change the style of a given text from source style to target style (e.g., formal to informal) while preserving its content. for instance, the formal sentence "however, i do believe it to be punk" is converted to the informal equivalent sentence "i'd say it is punk though". this task could be helpful for downstream applications such as text simplification, information extraction, and question answering. due to the importance of tst, this task has been approached with different techniques ranging from feature-based models @xcite to recent advanced deep learning solutions @xcite @xcite . the recent work can be categorized as supervised (i.e., parallel corpus with sentences in source and target style) @xcite , unsupervised (i.e., sentences in source and target style are available but they are not aligned) @xcite , or semi-supervised (combination of parallel and non-aligned corpora) @xcite methods. the three crit-ical objectives of any tst system are to (1) generate a text in the target style, (2) keep the content of the source text, and (3) generate fluent sentences @xcite . it has been shown that fine-tuning transformer-based language models on each of these objectives (i.e., using reinforcement learning) can achieve promising results @xcite . however, one of the limitations of the existing works is that the content preservation (i.e., the second objective) is fulfilled at either the surface-form level (i.e., by encouraging the same words to appear in both texts) @xcite or at the semantics level (i.e., by encouraging high mutual information between the two texts) @xcite ; ignoring the role of syntactic information. syntactic information (e.g., dependency tree) can be used to explicitly encode the connections between the words of the sentence, thereby playing an important role in the equivalency of two sentences. for instance, consider the source sentence "a crap touch bar with a nice screen!!!" and the converted sentence "the screen is great but the touch bar is terrible". the corresponding dependency between "touch @xmath0. although the pre-trained language models such as bert have been shown to be able to encode the syntactic information, it is not yet verified that these models can take into account the syntactic dependencies when computing the similarity between two sentences, especially for the tst task. to the best of our knowledge, there is one prior work that shows the importance of the syntactic information for transformer-based tst models @xcite . specifically, @xcite shows that reconstructing both the words of the source text and their pos tags could boost the performance of tst. however, there are two limi-tations in this work: (1) the syntactic structure (i.e., dependencies between words) is ignored; (2) the interaction between semantics and the syntax of the sentences is neglected. more specifically, to obtain the most value of the syntactic information, it is crucial to consider the relations between the words and also their semantics as shown in the example above. as such, in this work, we propose a novel method to simultaneously incorporate the interaction between syntax and semantics of the sentences into the content preservation objective of tst training. more specifically, for the first time in text style transfer, we propose to use optimal transport (ot) as an efficient method to consider both the syntax and the semantics of the two sentences when computing their content similarity. ot has been shown to be an effective method for image style transferring @xcite and our work exhibits its application for the domain of the text. we evaluate the proposed model on three benchmark datasets and two settings, i.e., supervised and unsupervised. our extensive analysis reveals the effectiveness of the proposed model by establishing new state-of-the-art results. in this work, we employ a transformer-based generative language model, i.e., gpt-2 @xcite , for tst and we train the model using reinforce algorithm. specifically, the source sentence d is prompted to the gpt-2 model to generate the target sentence d ′ . following the prior work, @xcite , the gpt-2 model is encouraged to generate the sentence d ′ in the target style t and with the same content as d. also, in the supervised setting, we use the gold target sentence d as an additional supervision signal to train the model. since d is not available in the unsupervised setting, we follow the prior work @xcite to use reconstruction loss as an additional training signal. the rest of this section provides details for generating sentences, rewards for generation, and training procedures. ## training to train the model, we combine the content preservation reward r cp (d ′ ), with style conversion and the language model loss. we use rein-force algorithm @xcite to train the model. in particular, the gpt-2 model is trained on the combination of the language model loss, i.e., l lm and the rewards of style conversion and content preservation. the reinforce algorithm is employed to incorporate rewards into fine-tuning of gpt-2. first, the overall reward is computed by r(d for the unsupervised setting, we employ two commonly used datasets: yelp @xcite and imdb @xcite review. both datasets contain sentiment-annotated reviews. the text style transfer on these datasets is defined as sentiment polarity conversion. in particular, given a sentence with a specific sentiment polarity (e.g., positive), the goal is to generate a new sentence with the opposite sentiment polarity (e.g., negative). note that no parallel data is available for the sentences in these datasets. the statistics of both datasets are provided in baselines: we compare our model with the prior state-of-the-art models in each setting. specifically, for the supervised setting on gyafc, we compare our model with gpt-2 + sc & bleu @xcite : similar to our model, this baseline employs gpt-2 to generate the target sentence. the generative model is trained using rewards for style conversion (sc) and content preservation (bleu); bart + sc & bleu @xcite : the same as the previous baseline with the difference of using bart instead of gpt-2; nmt-combined @xcite : this baseline casts tst as a machine translation problem and employs attention based bilstm encoder-decoder architecture; bi-directional ft @xcite : this model employs bilstm encoder to jointly learn text formality style transfer in both direction (from formal to informal and vice versa); cpls @xcite : this baselines employs an encoder-decoder architecture to obtain latent space representation of the styles, then a projection model converts the styles in the latent space; gpt-cat @xcite : this baseline combines rule-based methods with neural-based tst systems. gpt-2 is employed as the neural component; @xmath1: this model exploits reinforcement learning to explicitly encourage content preservation and transfer strength. it exerts bleu score between generated and ground-truth sentence to compute content preservation reward; and chawla's @xcite : this baseline uses a language model discriminator to guide the text formality style transfer. for content preservation, it employs mutual information between source and target sentence. for the unsupervised setting on imdb and yelp, we compare with cross-alignment @xcite : this baseline is trained to generate a sentence in the target style that could match the example sentences in the source style. to this end, a cross-aligned auto-encoder is utilized; controlled-gen @xcite : this model employs variational author encoder (vae) with attribute discriminators to impost semantic structure, including text style; style transformer @xcite : in this baseline, a transformer model is employed to directly takes the input sentence and target style to generate the target sentence; deep latent @xcite : this baseline models the unsupervised text style transfer as the task of inferring latent variables, i.e., target sentences, on the partially observed data of each style. a recurrent language model is employed to fulfill the objective. racoln @xcite : in this baseline, the reverse attention technique is employed to remove style information from the representations of the tokens in the source sentence. ## conclusion we propose a new model for encouraging content preservation in text style transfer. we demonstrate that both syntax and semantics of the input sentence and the generated sentence should be taken into account for content preservation. more importantly, we empirically show that the interaction between syntax and semantics of the input and target sentences is necessary for tst. we conducted extensive experiments on benchmark datasets in supervised and unsupervised settings, achieving state-of-the-art performance on multiple datasets.