Politeness Transfer: A Tag and Generate Approach (2020)

Abstract: This paper introduces a new task of politeness transfer which involves converting non-polite sentences to polite sentences while preserving the meaning. We also provide a dataset of more than 1.39 instances automatically labeled for politeness to encourage benchmark evaluations on this new task. We design a tag and generate pipeline that identifies stylistic attributes and subsequently generates a sentence in the target style while preserving most of the source content. For politeness as well as five other transfer tasks, our model outperforms the state-of-the-art methods on automatic metrics for content preservation, with a comparable or better performance on style transfer accuracy. Additionally, our model surpasses existing methods on human evaluations for grammaticality, meaning preservation and transfer accuracy across all the six style transfer tasks. The data and code is located at https://github.com/tag-and-generate .

## introduction politeness plays a crucial role in social interaction, and is closely tied with power dynamics, social distance between the participants of a conversation, and gender @xcite . it is also imperative to use the appropriate level of politeness for smooth communication in conversations @xcite , organizational settings like emails @xcite , memos, official documents, and many other settings. notably, politeness has also been identified as an interpersonal style which can be decoupled from content @xcite . motivated by its central importance, in this paper we study the task of converting non-polite sentences to polite sentences while preserving the meaning. prior work on text style transfer @xcite @xcite @xcite has not focused on politeness as a style transfer task, and we argue that defining it is cumbersome. while native speakers of a language and cohabitants of a region have a good working understanding of the phenomenon of politeness for everyday conversation, pinning it down as a definition is non-trivial @xcite . there are primarily two reasons for this complexity. first, as noted by @xcite , the phenomenon of politeness is rich and multifaceted. second, politeness of a sentence depends on the culture, language, and social structure of both the speaker and the addressed person. for instance, while using "please" in requests made to the closest friends is common amongst the native speakers of north american english, such an act would be considered awkward, if not rude, in the arab culture @xcite . we circumscribe the scope of politeness for the purpose of this study as follows: first, we adopt the data driven definition of politeness proposed by @xcite . second, we base our experiments on a dataset derived from the enron corpus @xcite which consists of email exchanges in an american corporation. thus, we restrict our attention to the notion of politeness as widely accepted by the speakers of north american english in a formal setting. even after framing politeness transfer as a task, there are additional challenges involved that differentiate politeness from other styles. consider a common directive in formal communication, "send me the data". while the sentence is not impolite, a rephrasing "could you please send me the data" would largely be accepted as a more polite way of phrasing the same statement @xcite . this example brings out a distinct characteristic of politeness. it is easy to pinpoint the signals for politeness. however, cues that signal the absence of politeness, like direct questions, statements and factuality @xcite , do not explicitly appear in a sentence, and are thus hard to objectify. further, the other extreme of politeness, impolite sentences, are typically riddled with curse words and insulting phrases. while interesting, such cases can typically be neutralized using lexicons. for our study, we focus on the task of transferring the non-polite sentences to polite sentences, where we simply define non-politeness to be the absence of both politeness and impoliteness. note that this is in stark contrast with the standard style transfer tasks, which involve transferring a sentence from a well-defined style polarity to the other (like positive to negative sentiment). we propose a tag and generate pipeline to overcome these challenges. the tagger identifies the words or phrases which belong to the original style and replaces them with a tag token. if the sentence has no style attributes, as in the case for politeness transfer, the tagger adds the tag token in positions where phrases in the target style can be inserted. the generator takes as input the output of the tagger and generates a sentence in the target style. additionally, unlike previous systems, the outputs of the intermediate steps in our system are fully realized, making the whole pipeline interpretable. finally, if the input sentence is already in the target style, our model won't add any stylistic markers and thus would allow the input to flow as is. we evaluate our model on politeness transfer as well as 5 additional tasks described in prior work @xcite @xcite on content preservation, fluency and style transfer accuracy. both automatic and human evaluations show that our model beats the stateof-the-art methods in content preservation, while either matching or improving the transfer accuracy across six different style transfer tasks( §5). the results show that our technique is effective across a broad spectrum of style transfer tasks. our methodology is inspired by @xcite and improves upon several of its limitations as described in ( §2). our main contribution is the design of politeness transfer task. to this end, we provide a large dataset of nearly 1.39 million sentences labeled for politeness ( https://github.com/tag-and-generate/ politeness-dataset ). additionally, we hand curate a test set of 800 samples (from enron emails) which are annotated as requests. to the best of our knowledge, we are the first to undertake politeness as a style transfer task. in the process, we highlight an important class of problems wherein the transfer involves going from a neutral style to the target style. finally, we design a "tag and generate" pipeline that is particularly well suited for tasks like politeness, while being general enough to match or beat the performance of the existing systems on popular style transfer tasks. ## related work politeness and its close relation with power dynamics and social interactions has been well documented @xcite . recent work @xcite in computational linguistics has provided a corpus of requests annotated for politeness curated from wikipedia and stackexchange. @xcite uses this corpus to generate polite dialogues. their work focuses on contextual dialogue response generation as opposed to content preserving style transfer, while the latter is the central theme of our work. prior work on enron corpus @xcite has been mostly from a socio-linguistic perspective to observe social power dynamics @xcite , formality @xcite and politeness @xcite . we build upon this body of work by using this corpus as a source for the style transfer task. prior work on style transfer has largely focused on tasks of sentiment modification @xcite @xcite , caption transfer @xcite , persona transfer @xcite , gender and political slant transfer @xcite , and formality transfer @xcite . note that formality and politeness are loosely connected but independent styles @xcite . we focus our efforts on carving out a task for politeness transfer and creating a dataset for such a task. current style transfer techniques @xcite @xcite @xcite try to disentangle source style from content and then combine the content with the target style to generate the sentence in the target style. compared to prior work, "delete, retrieve and generate" @xcite (referred to as drg henceforth) and its extension @xcite are effective methods to generate out-puts in the target style while having a relatively high rate of source content preservation. however, drg has several limitations: (1) the delete module often marks content words as stylistic markers and deletes them, (2) the retrieve step relies on the presence of similar content in both the source and target styles, (3) the retrieve step is time consuming for large datasets, (4) the pipeline makes the assumption that style can be transferred by deleting stylistic markers and replacing them with target style phrases, (5) the method relies on a fixed corpus of style attribute markers, and is thus limited in its ability to generalize to unseen data during test time. our methodology differs from these works as it does not require the retrieve stage and makes no assumptions on the existence of similar content phrases in both the styles. this also makes our pipeline faster in addition to being robust to noise. @xcite treats style transfer as a conditional language modelling task. it focuses only on sentiment modification, treating it as a cloze form task of filling in the appropriate words in the target sentiment. in contrast, we are capable of generating the entire sentence in the target style. further, our work is more generalizable and we show results on five other style transfer tasks. ## methodology we propose a two staged approach where we first infer a sentence z(x i ) from x (1) i using a model, the tagger. the goal of the tagger is to ensure that the sentence z(x i ) is agnostic to the original style (s 1 ) of the input sentence. conditioned on z(x i ), we then generate the transferred sentence ## experiments and results baselines we compare our systems against three previous methods. drg @xcite , style transfer through back-translation (bst) @xcite , and style transfer from nonparallel text by cross alignment @xcite . for drg, we only compare against the best reported method, delete-retrieve-generate. for all the models, we follow the experimental setups described in their respective papers. implementation details we use 4-layered transformers @xcite to train both tagger and generator modules. each transformer has 4 attention heads with a 512 dimensional embedding layer and hidden state size. dropout @xcite with p-value 0.3 is added for each layer in the transformer. for the politeness dataset the generator module is trained with data augmentation techniques like random word shuffle, word drops/replacements as proposed by @xcite et al., 2017). we empirically observed that these techniques provide an improvement in the fluency and diversity of the generations. both modules were also trained with the bpe tokenization @xcite using a vocabulary of size 16000 for all the datasets except for captions, which was trained using 4000 bpe tokens. the value of the smoothing parameter γ in eq. 2 is set to 0.75. for all datasets except yelp we use phrases with p 2 1 (w) ≥ @xmath0.9 to construct γ 2 , γ 1 ( §4.1). for yelp k is set to 0.97. during inference we use beam search (beam @xmath1. for the tagger, we re-rank the final beam search outputs based on the number of @xcite tokens in the output sequence (favoring more [tag] tokens). automated evaluation following prior work @xcite , we use automatic metrics for evaluation of the models along two major dimensions: (1) style transfer accuracy and (2) content preservation. to capture accuracy, we use a classifier trained on the nonparallel style corpora for the respective datasets (barring politeness). the architecture of the classifier is based on awd-lstm @xcite and a softmax layer trained via cross-entropy loss. we use the implementation provided by fastai. 5 for politeness, we use the classifier trained by @xcite . 6 the metric of transfer accuracy (acc) is defined as the percentage of generated sentences classified to be in the target domain by the classifier. the standard metric for measuring content preservation is bleu-self (bl-s) @xcite which is computed with respect to the original sentences. additionally, we report the bleu-reference (bl-r) scores using the human reference sentences on the yelp, amazon and captions datasets @xcite . we also report rouge (rou) @xcite and meteor (met) @xcite scores. in particular, meteor also uses synonyms and stemmed forms of the words in candidate and reference sentences, and thus may be better at quantifying semantic similarities. in while popular, the metrics of transfer accuracy and bleu have significant shortcomings making them susceptible to simple adversaries. bleu relies heavily on n-gram overlap and classifiers can be fooled by certain polarizing keywords. we test this hypothesis on the sentiment transfer task by a naive baseline. this baseline adds "but overall it sucked" at the end of the sentence to transfer it to negative sentiment. similarly, it appends "but overall it was perfect" for transfer into a positive sentiment. this baseline achieves an average accuracy score of 91.3% and a bleu score of 61.44 on the yelp ## conclusion we introduce the task of politeness transfer for which we provide a dataset comprised of sentences curated from email exchanges present in the enron corpus. we extend prior works @xcite on attribute transfer by introducing a simple pipeline -tag & generate which is an interpretable two-staged approach for content preserving style transfer. we believe our approach is the first to be robust in cases when the source is style neutral, like the "non-polite" class in the case of politeness transfer. automatic and human evaluation shows that our approach outperforms other state-of-the-art models on content preservation metrics while retaining (or in some cases improving) the transfer accuracies. non-polite input drg our model jon --please use this resignation letter in lieu of the one sent on friday . @xmath2. salsa is not hot or good . salsa is always hot and fresh . @xmath3. @xmath4 @xmath5: black patriots demand impeachment of obama video : black police show choose video : black patriots demand to endorse obama @xmath6. trump is good ... but mr. marco rubio is great ! ! thank you mr. good ... but mr. kaine is great senator ! ! mr. schumer is good ... but mr. pallone is great ! ! @xmath7. a woman is sitting near a flower overlooking a tunnel, determined to a woman is sitting near a brick rope , excited to meet her boyfriend . @xmath8. @xmath9. @xmath10. a black dog plays in the water . a black dog plays around in water looking for fish .