Prompt-Based Editing for Text Style Transfer (2023)

Abstract: Prompting approaches have been recently explored in text style transfer, where a textual prompt is used to query a pretrained language model (PLM) to generate style-transferred texts word by word in an autoregressive manner. However, such a generation process is less controllable and early prediction errors may affect future word predictions. In this paper, we propose a prompt-based editing approach to text style transfer. Specifically, we prompt a PLM for style classification and use the classification probability to compute a style score. Then, we perform discrete search with word-level editing to maximize a comprehensive scoring function for the style-transfer task. In this way, we transform a prompt-based generation problem into a classification one, which does not suffer from the error accumulation problem and is more controllable than the autoregressive generation of sentences. In our experiments, we performed both automatic and human evaluation on three style-transfer benchmark datasets, and show that our approach largely outperforms the existing systems that have 20 times more parameters. Additional empirical analyses further demonstrate the effectiveness of our approach.

## introduction text style transfer aims to automatically rewrite a sentence by changing it from one style to another @xcite , such as transferring the positive-sentiment sentence "he loves eating sandwiches" into a negative one "he hates eating sandwiches". during the transfer, the style of the sentence must be changed, whereas the styleindependent content should be preserved. text style transfer has a wide range of real-world applications, such as personalized response generation @xcite ), text debiasing @xcite ), text simplification @xcite , and headline generation @xcite . early work on text style transfer falls mainly into three categories: 1) parallel supervision with labeled source-target sentence pairs in a sequenceto-sequence manner @xcite @xcite , 2) non-parallel supervision with style labels only, including learning latent representations of style and content separately @xcite @xcite and constructing pseudo-parallel training data for learning @xcite @xcite , and 3) unsupervised learning methods that do not require style labels @xcite . very recently, prompting methods have been explored in text style transfer @xcite , as large-scale pretrained language models (plms) enable us to perform various natural language generation tasks in a zero-shot @xcite or exemplar-based manner @xcite . in this paper, we also follow the promptbased setting. this does not require any training samples or labels, but directly performs inference with plms; thus, it is more challenging than the above three settings. in previous work, a prompt (e.g., a piece of text "rewrite the text to be positive:") is used to query a plm, which will then generate a style-transferred sentence in an autoregressive manner @xcite . however, such autoregressive generation is less controllable as words are generated one after another by the plm. it has the error accumulation problem where early errors of the plm will affect its future predictions, leading to less satisfactory performance in general. to this end, we propose a prompt-based editing approach to unsupervised style transfer. we first design a plm-based style scorer. specifically, we prompt a plm for style classification and use the classification probability to compute a style score. then, we perform steepest-ascent hill climbing (sahc; @xcite for discrete search with word-level editing (such as replacement, insertion, and deletion) to maximize a heuristically defined scoring function for style transfer. in this way, we transform a prompt-based generation problem into a classification one, which involves only a style-word prediction and is generally believed to be easier than multiple-word predictions for sentence generation. our approach provides several additional advantages. first, it does not suffer from the error accumulation problem, because it performs word edits scattered throughout the entire sentence instead of generating a sentence word by word. further, we design a discrete search algorithm that combines the plm-based style score with other scoring functions, including fluency and semantic similarity. consequently, the search algorithm contributes to a more controllable and refined generation of sentences. we used eleuther ai's gpt-j-6b (an off-theshelf plm) 2 and conducted both automatic and human evaluations on three style-transfer benchmark datasets. results show that our prompt-based editing approach largely outperforms existing prompting systems that have 20 times more parameters. additional empirical analysis shows the effectiveness of different scoring components and the search algorithm proposed in our approach. another method is few-shot prompting @xcite @xcite . it requires several task-specific examples for plm, but can achieve higher performance than zero shot prompting, and is thus more widely adopted in nlp tasks @xcite @xcite . prompting methods were initially applied to 2 https://github.com/kingoflolz/mesh-transformer-jax natural language classification tasks @xcite , where plms are asked to predict the masked word given a piece of text containing the token "[mask]", and the predicted word is then projected to a label by a predefined verbalizer. with the emergence of various plms @xcite @xcite @xcite , prompting methods have recently been widely applied to natural language generation tasks @xcite , such as text style transfer @xcite and machine translation @xcite @xcite ). ## experiments in this section, we will present empirical evaluation of our proposed prompt-based editing approach. first, we will introduce our datasets and setups. then, we will show our main results, followed by detailed analyses. ## conclusion in this paper, we propose a novel prompt-based editing approach to text style transfer that turns a prompt-based generation problem into a classification one. it does not suffer from the issue of error accumulation and is more controllable than autoregressive generation. our experiments on three benchmark datasets show that the proposed approach significantly outperforms the existing prompting systems while using 20x fewer parameters. additional empirical analysis shows the effectiveness of different scorers and the discrete search algorithm in our approach.