Customized Style Transfer using Discrete Sampling (2024)

Abstract: Customizing text style or content typically involves extensive fine-tuning of large models, demanding significant data and training. Traditional unsupervised approaches using sampling often yield low diversity and creativity. We present a novel discrete Langevin proposal that samples directly from the categorical token distribution, overcoming these limitations. By adapting the continuous Langevin algorithm for discrete spaces, our approach enables efficient gradient-based sampling. Evaluations on style transfer tasks demonstrate superior performance over state-of-the-art methods in accuracy, BLEU, BERTScore, and diversity. Our proposed approach paves way for advanced customized text generation with desired styles as well as allows future scope for prompt generation for model safeguarding and jail-breaking.

## introduction customizing text style is an important task in natural language processing that involves generating text conditioned on specific styles or topics @xcite @xcite . traditional techniques for tailoring large language models to specific applications typically necessitate extensive fine-tuning on specialized datasets, a process that can be both resource-intensive and inflexible @xcite @xcite . other approaches avoid extensive retraining by guiding pre-trained models during decoding, blending model-generated likelihoods with heuristic scoring functions @xcite @xcite . these approaches, however, often require significant modifications to the model architecture or the addition of complex auxiliary modules. to address these challenges, recent research has focused on improving existing generative strategies. traditional approaches like markov chain monte carlo (mcmc), including gibbs sampling, often make minor, localized adjustments to text, which can limit diversity and innovation @xcite . more recently, techniques such as gradient-based langevin dynamics sampling have been explored to enhance efficiency in continuous spaces @xcite . however, these approaches face difficulties such as prompt deviation and mismatches between continuous and discrete representations @xcite . in response to these issues, we propose a novel discrete langevin dynamics-based approach that facilitates direct sampling from the categorical distribution of tokens inspired by @xcite recent work. our approach enables efficient exploration of the distribution and simultaneous updates of multiple tokens, overcoming the constraints of traditional discretization techniques. we demonstrate that this approach achieves faster convergence and greater output diversity compared to conventional gibbs and langevin sampling. in a series of empirical evaluations, our approach surpasses established techniques like mix-match @xcite and mucola @xcite in style transfer and text generation tasks. our contributions are threefold: ## related work recent works closely related to our approach include mixmatch and mucola. mixmatch operates within the energy-based model (ebm) framework and employs gibbs sampling to generate text @xcite . while this method is effective, it relies on traditional mcmc techniques, which can be slower and less efficient, particularly when applied to discrete data spaces commonly found in text style transfer and generation tasks. mucola, on the other hand, represents a more recent advancement in customizable text generation. it combines the log-likelihood of language models with differentiable constraints into a unified energy function. mucola utilizes a nonautoregressive sampling method based on langevin dynamics in continous spaces, allowing it to maintain fluency while adhering to user-defined constraints @xcite . this approach has proven to be a strong baseline in customized text generation but suffers from prompt deviation and mismatches between continuous and discrete representations @xcite . our work builds upon these concepts by introducing a discrete langevin dynamics approach that offers a more efficient gradient-based sampling method specifically designed for discrete spaces. this enables robust conditional generation based on desired styles without the need for additional training, positioning our approach as an improvement over both mixmatch and mucola in customized style transfer and text generation tasks. ## gradient based discrete sampling on ebms the sections provide detailed information about our proposed approach. first, we explain the ebm we will use for sampling. then, we describe how the discrete sampling approach works with this ebm. ## experiments we apply our proposed approach to style transfer tasks, focusing on sentiment transfer as our primary task. our method's performance on sentiment transfer is demonstrated using the yelp dataset test set @xcite , which includes 1000 sentences evenly split by sentiment. we conducted the experiment using an nvidia 1660 super gpu. the step size η max was set to 0.07, and η min was set to 0.03. we performed sampling for 150 steps, limiting the token updates to 4 tokens. α mlm , α disc and α hamm is set to 1, 200 and 60 respectively for sentiment transfer. overall, given a sample text with negative sentiment, the goal is generate text with positive sentiment or vice-versa. our setup employs a bert-base-uncased mlm for generating proposals. to obtain e disc , we train bert-based classifiers on the training set of our datasets to use as attribute discriminators. while we could have used any pre-trained attribute classifier from huggingface for e disc , we reserved those for use as external attribute classifiers for fair evaluation against baselines. ## conclusion in conclusion, our discrete langevin-based proposal offers a highly efficient gradient-based discrete sampler, demonstrating robust conditional generation capabilities without necessitating additional training. by simultaneously adjusting multiple tokens, it effectively navigates the complex discrete distribution of text, resulting in diverse outputs compared to methods that modify a single token per step. furthermore, this approach provides a versatile, general-purpose sampler that can be tailored to customize text generation across various tasks. the results affirm these benefits, showcasing our approach's superior performance in generating high-quality, diverse text with enhanced efficiency.