Prompt-Based Editing for Text Style Transfer

Guoqing Luo, Yu Tong Han, Lili Mou, Mauajama Firdaus

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 (TST) is the task of rewriting a sentence to alter its style (e.g., sentiment or formality) while preserving its underlying semantic meaning. While current state-of-the-art methods leverage Large Language Models (LLMs) via autoregressive prompting, these approaches often suffer from error accumulation and a lack of precise control over content preservation. If a model makes an initial error in a generated sequence, the mistake often cascades, leading to hallucinations or loss of the original message.

To address these challenges, we introduce Prompt-Based Editing. This framework treats TST as an iterative search problem rather than a one-shot generation task. By utilizing a Pretrained Language Model (PLM) as a style classifier to guide local word-level edits, our method achieves superior performance and tighter control over semantic integrity.

Methodology

Comparison of traditional Prompt-Based Generation (a) and the proposed Prompt-Based Editing approach (b).

Instead of generating a new sentence from scratch, our approach begins with the original input and iteratively refines it using Steepest-Ascent Hill Climbing (SAHC). At each step, the algorithm evaluates potential word-level edits (insertion, deletion, or replacement) against a comprehensive scoring function $f(y; x)$:

  1. Style Score ($f_{sty}$): The PLM is prompted for classification (e.g., "The sentiment of the text {sentence} is :"). We use the ratio of the target style probability to the source style probability to ensure robust style guidance.
  2. Language Fluency ($f_{flu}$): A GPT-2 model evaluates the naturalness of the candidate edit.
  3. Semantic Similarity ($f_{sem}$): A RoBERTa-based scorer ensures the core meaning remains consistent with the original input.

By pivoting from generation to classification, we leverage the PLM's ability to accurately identify style, which is inherently more stable than generating long-form stylistic text.

Experimental Evaluation

We evaluated our approach on three benchmark datasets: Yelp (restaurant reviews), Amazon (product reviews), and GYAFC (formality transfer). We compared our 6-billion parameter model (GPT-J) against significantly larger models, including GPT-3 (175B parameters).

Results

Automatic evaluation results on Yelp and Amazon datasets, showing the proposed approach outperforming larger models in zero-shot and few-shot settings.

Our Prompt-Based Editing approach demonstrated substantial improvements over standard "Prompt & Rerank" baselines. On the Yelp dataset in a zero-shot setting, our method achieved a Geometric Mean (GM) of 54.1, significantly higher than the 35.2 achieved by the baseline. Notably, our 6B parameter model outperformed the 175B parameter GPT-3 davinci in several key metrics, including GM and Harmonic Mean (HM) on the Yelp few-shot task.

Human evaluation further confirmed these findings. Our approach was rated significantly higher for content preservation (4.24 vs. 3.55 on Yelp) compared to generative baselines, which frequently suffered from hallucinations or unrelated content generation.

Discussion and Conclusion

The effectiveness of Prompt-Based Editing stems from its conservative nature; since most style transfers only require 3–5 word changes, an editing approach is naturally better at preserving content than rewriting from scratch. While the discrete search process is computationally more intensive than single-pass generation, the gains in controllability and accuracy are substantial. Future work will explore parallelizing the search process and utilizing automated prompt tuning to further enhance performance. In summary, transforming the style transfer problem into a classification-guided search allows smaller models to punch well above their weight class, delivering more reliable and stylistically accurate results.

Summary updated

BibTeX
@inproceedings{luo2023prompt,
  author = {Guoqing Luo and Yu Tong Han and Lili Mou and Mauajama Firdaus},
  title = {{Prompt-Based Editing for Text Style Transfer}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=fNi7eet4Qc},
}
Figure