Replacing Language Model for Style Transfer

Pengyu Cheng, Ruineng LiarXiv 2022 · DOI

Abstract

Text Style Transfer (TST) aims to alter the stylistic attributes of a sentence while preserving its core semantic content. Existing unsupervised methods often struggle with a trade-off between style accuracy and content preservation, typically falling into either sentence-level or word-level categories. We introduce the Replacing Language Model (RLM), a novel sequence-to-sequence framework that bridges this gap by autoregressively replacing source tokens with target-style spans. By utilizing a masked language model backbone and a Bayesian decomposition into prediction and reconstruction objectives, RLM achieves superior performance on standard benchmarks, offering a robust solution for high-fidelity style transfer without relying on manual heuristics.

Introduction

The primary challenge in Text Style Transfer (TST) is the lack of parallel training data, necessitating unsupervised approaches. Current methods generally follow two paradigms. Sentence-level methods attempt to map an entire sentence to a style-agnostic content vector, which often leads to "hallucinations" or loss of detail during generation. Conversely, word-level methods identify and replace specific "style words," but these often rely on rigid, hand-coded heuristics and produce repetitive, uninspired outputs.

The Replacing Language Model (RLM) addresses these issues by treating style transfer as a token-by-token editing process. Instead of generating a new sentence from scratch, RLM iterates through the source sentence and replaces each token with a new span that fits the target style and context perfectly.

Token-level replacement mapping from source to target style.

Methodology

The core of RLM is a BERT-based Masked Language Model (MLM) that integrates both "past" transferred tokens and "future" original tokens to maintain local coherence. The model's objective is derived from a Bayesian decomposition of the generation probability into two primary components:

  1. Prediction Term: This component suggests a replacement token $y_i$ that aligns with the target style $s$ and the surrounding context $c_i$.
  2. Reconstruction Term: To ensure semantic preservation, this term requires that the original token $x_i$ can be reconstructed from the content representation $c_i$ of the replacement.
The RLM architecture showing (a) the prediction term and (b) the reconstruction term.

Token-level Disentanglement

Unlike previous sentence-level disentanglement methods, RLM performs disentanglement at the token level. It employs Mutual Information (MI) minimization to strip style-specific information from each word's hidden representation, ensuring the model focuses on "pure" content during the replacement process.

Unequal-Length Adaptation

To accommodate cases where a single word must be replaced by multiple tokens or deleted entirely, RLM includes an "insertion head" and utilizes special padding tokens. This allows the sequence length to change dynamically while maintaining the autoregressive flow.

Experimental Results

RLM was evaluated on the Yelp and Amazon review datasets, which are standard benchmarks for sentiment transfer.

Automatic Metrics

RLM demonstrated a significant improvement in the balance between style and content. On the Yelp dataset, it achieved a Ref-BLEU score of 30.6, significantly higher than the previous best (26.4), while maintaining a high Style Accuracy of 91.0%. The Geometric Mean (GM) of these metrics confirmed that RLM provides a superior overall quality compared to baselines like RACoLN and CPVAE.

Human Evaluation

In blind human evaluations, RLM was rated higher than competing models in style accuracy (4.5/5) and was found to be highly competitive in terms of fluency and content preservation.

Conclusion

The Replacing Language Model offers a powerful framework for text style transfer by combining the strengths of word-level editing with the generative power of large-scale language models. While it excels at preserving the "backbone" of the original sentence, its primary limitation lies in tasks requiring massive structural changes, such as voice conversion. Future research will explore the application of RLM to other sequence-to-sequence tasks where structural preservation is paramount.

Summary updated

BibTeX
@misc{cheng2022replacing,
  author = {Pengyu Cheng and Ruineng Li},
  title = {{Replacing Language Model for Style Transfer}},
  year = {2022},
  eprint = {2211.07343},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.07343},
}
Figure