T ext SETTR : Few-Shot Text Style Extraction and Tunable Targeted Restyling (2021)

Abstract: We present a novel approach to the problem of text style transfer. Unlike previous approaches requiring style-labeled training data, our method makes use of readily-available unlabeled text by relying on the implicit connection in style between adjacent sentences, and uses labeled data only at inference time. We adapt T5 (Raffel et al., 2020), a strong pretrained text-to-text model, to extract a style vector from text and use it to condition the decoder to perform style transfer. As our label-free training results in a style vector space encoding many facets of style, we recast transfers as “targeted restyling” vector operations that adjust specific attributes of the input while preserving others. We demonstrate that training on unlabeled Amazon reviews data results in a model that is competitive on sentiment transfer, even compared to models trained fully on labeled data. Furthermore, applying our novel method to a diverse corpus of unlabeled web text results in a single model capable of transferring along multiple dimensions of style (dialect, emotiveness, formality, politeness, sentiment) despite no additional training and using only a handful of exemplars at inference time.

## introduction there has been a recent surge of interest in text style transfer, with the aim of training models able to modify specific attributes of input text (e.g., sentiment or formality) while preserving the remaining content. for example, a sentiment transfer model might transform the input "best book ever!" into "worst book ever!", while a formality transfer model might change the same input into "this is the best book i have ever read." in these contexts, we define "style" as the attributes intended to be changed, while "content" consists of the attributes intended to be preserved. 1 work in this area falls into three categories. supervised approaches like @xcite transfer between pre-selected styles, and rely on parallel training data to learn the desired input/output correspondence. this method is limited by the availability of parallel corpora. so-called "unsupervised" approaches like @xcite and @xcite remove the need for parallel data, but still require that all training examples have style labels, and are limited to transfer between a pre-specified set of styles. few-shot approaches like that of @xcite remove the need for any training labels, instead using a small number of labeled examples during inference. while the most challenging, this offers the potential for transferring between arbitrary styles at inference time and has significant value, as curated datasets are not available for many style attributes. in this work, we explore the hypothesis that large pretrained text-to-text models like t5 @xcite already contain a strong representation of textual style, which can be extracted and used to condition the decoder of a style transfer model through a relatively lightweight fine-tuning procedure. to isolate style information in the absence of labels, we rely on the observation that style is a "slow-moving" feature, which tends to be consistent over large spans of text. specifically, given two adjacent sentences from an unlabeled corpus, we train our model to extract a "style vector" from the first and use that vector to perform denoising and other reconstruction tasks on the second. this technique extends the approach of @xcite to the few-shot setting, and is loosely reminiscent of the work of @xcite , who found large context windows useful for encoding style information in word embeddings. our approach also allows us to reformulate the style transfer operation as a directional operation in style vector space using the difference between target and source style vectors; we call this "targeted restyling". when combined with a novel "tunable inference" technique for controlling token add/delete rates, this gives our final model: text style extraction and tunable targeted restyling (textsettr). our main contributions are to: (1) present a new, flexible approach to few-shot style transfer, (2) use sentence adjacency as a means for inducing text style representations, (3) reframe style transfer as "targeted restyling" directional operations in style space, (4) introduce "tunable inference" for finergrained control of transfers, (5) show the effectiveness of "noisy" back-translation training, and (6) illustrate few-shot generalization to a range of style attributes including dialect, emotiveness, formality, politeness, and sentiment. the key difference in our case is that the true style is unknown at training time. to overcome this, we jointly train a "style extractor" component to induce a useful style representation (that can aid in reconstruction) from text in the nearby context. we describe this in more detail below. ## one model for all styles an advantage of few-shot style transfer is that, in theory, a single model can perform transfer along any "dimension" of style given only a few exemplars, without the need for additional training. in this section, we investigate the degree to which our approach achieves this goal in practice. for this purpose, we train a single general-purpose textsettr model, with the same configuration as our model from section 3, except fine-tuned for 200k steps on english common crawl data (the same "c4" data that t5 pretrained on) instead of amazon reviews. qualitative evaluation given that our architecture limits the style representation to 1024 dimensions, one may ask how the unsupervised model will make use of this capacity, and which style attributes will be encoded in the learned space. encouragingly, we find that our model trained on un-before textsettr training (pretrained t5 initialization) after textsettr training figure 3 : 2d umap embeddings of the style vectors extracted by our textsettr model before and after training, for text inputs from amazon reviews covering three product categories and two sentiment labels. within each row, the same embeddings are labeled with product category (left) and sentiment (right). we sub-sample to 3,000 points after dimensionality reduction. note, we don't expect perfect separation, as inputs may be underspecified for category ("i love this product") or for sentiment ("i bought this last month"). we also don't expect to see crisp linear separation within each attribute since we aim for the learned embedding space to encode many style attributes simultaneously. reserved ⇒ emotive emotive ⇒ reserved i liked the movie. ⇒ i cannot even describe how amazing this movie was!! i loved every minute of the movie! ⇒ i liked the movie. i was impressed with the results. ⇒ i was absolutely blown away with the results!! i was shocked by the amazing results! ⇒ i was surprised by the results. american ⇒ british british ⇒ american the elevator in my apartment isn't working. ⇒ the lift in my flat isn't working. the lift in my flat isn't working. ⇒ the elevator in my apartment isn't working. the senators will return to washington next week. ⇒ the mps will return to westminster next week. mps will return to westminster next week. ⇒ representatives will return to washington next week. polite ⇒ rude rude ⇒ polite are you positive you've understood my point? ⇒ you've never understood my point! what the hell is wrong with your attitude? ⇒ perhaps the question is more about your attitude. could you ask before using my phone? ⇒ i ask you to stop using my phone! i could care less, go find somebody else to do this crap. ⇒ i could be wrong, but i would try to find somebody else to do this. formal ⇒ informal informal ⇒ formal i hereby commit to never purchase anything from this institution in the future. ⇒ i gonna never buy anything from this place again. best book ever!! ⇒ the book is highly recommended. positive ⇒ negative negative ⇒ positive i was pretty impressed with the results. ⇒ i was pretty disappointed with the results. i was pretty disappointed with the results. ⇒ i was pretty impressed with the results. i will definitely buy this brand again. ⇒ i will definitely not buy this brand again. i definitely won't buy this brand again. ⇒ i definitely won't hesitate to buy this brand again. across each type of transfer, we see evidence of generalization beyond the specifics of the chosen exemplars. in making text more emotive, the model uses amazing and blown away, despite these terms not occurring in the exemplars. in making text more polite, the model inserts novel hedges like perhaps and i could be wrong. in transferring between american and british styles, the model generalizes to unseen vocabulary items (elevator ↔ lift) and draws sound analogies (senators ↔ mps). we do note though that the latter case illustrates that the model is willing to change the semantic content of the input in cases where it would otherwise be outof-place in the target style. future work includes investigating ways to control this in settings where such behavior is not desired. quantitative evaluation to assess the quality of our general-purpose textsettr model, we benchmark the same model on three distinct transfer tasks in ## related work as mentioned at the outset, recent work on text style transfer falls into three classes: supervised, "unsupervised", and few-shot. supervised style transfer has seen limited research due to the difficulty of obtaining parallel data. examples include @xcite and @xcite . ## conclusion we have presented a unique approach to few-shot text style transfer that is competitive with systems trained with labels (an easier setting), while allowing control of how much of the input is changed. we demonstrate that this approach can produce a single system capable of transferring many different styles while requiring only a handful of exemplars at inference time.