Abstract
Text Style Transfer (TST) is a challenging task that requires modifying the stylistic attributes of a sentence while maintaining its original semantic meaning. A significant limitation of existing approaches is their inability to preserve complex syntactic structures, often leading to content loss or "hallucinations." We introduce OT4, a model that utilizes Optimal Transport (OT) to align sentences in both semantic and syntactic spaces. By employing a reward function based on the Wasserstein distance between word embeddings and dependency tree structures, OT4 ensures high-fidelity content preservation. Our experiments demonstrate that OT4 achieves state-of-the-art results across major benchmarks, including the GYAFC formality corpus and the Yelp/IMDB sentiment datasets, outperforming strong baselines in both automated metrics and human evaluations.
Introduction
Text Style Transfer (TST) involves the automatic transformation of text from a source style to a target style (e.g., informal to formal, or negative to positive sentiment) without altering the underlying factual content. While significant progress has been made using large-scale pre-trained language models, the core challenge remains content preservation.
Most current TST models rely on surface-level word overlap metrics or semantic similarity in embedding space. However, these methods frequently overlook syntax—the structural relationships between words. For instance, in a sentence like "The small dog barked at the big cat," the syntactic structure defines which adjective modifies which noun. Ignoring these relationships can lead to models that capture the general "vibe" of a sentence but scramble the specific details, a phenomenon known as content drift.
Methodology: The OT4 Framework
The proposed OT4 model addresses these challenges by integrating structural information into the training process via Reinforcement Learning.
The Generator and Reward System
OT4 uses a pre-trained GPT-2 model as its generator. To guide the generation process, the model is trained using the REINFORCE algorithm with a multi-faceted reward function:
- Style Reward: A BERT-based classifier provides a signal indicating how well the generated sentence matches the target style.
- Content Reward (Optimal Transport): This is the primary innovation of the paper. Instead of using traditional metrics like BLEU, which can be rigid, the authors use Optimal Transport to calculate the distance between the source and generated sentences.
Semantic and Syntactic Alignment
The OT content reward considers two dimensions:
- Semantics: Word meanings are represented by the hidden states of the GPT-2 model.
- Syntax: Structural importance is captured using a dependency parser. Each word is assigned a weight based on its "depth" in the dependency tree (using a softmax of the depth). This ensures that the "core" structural elements of the sentence are prioritized during alignment.
Optimal Transport finds the "cheapest" way to transform the source sentence's distribution into the target sentence's distribution. By minimizing the Wasserstein distance, the model learns to align words that are both semantically similar and occupy analogous structural positions.
Experimental Evaluation
The model was evaluated across two distinct settings:
- Supervised Learning: Using the GYAFC (Grammarly’s Yahoo Answers Formality Corpus), which provides parallel pairs of informal and formal sentences in the "Entertainment & Music" (E&M) and "Family & Relationships" (F&R) domains.
- Unsupervised Learning: Using the Yelp and IMDB datasets for sentiment transfer. In this setting, the model must learn to flip sentiment without direct parallel examples.
Results and Analysis
OT4 established new state-of-the-art (SOTA) performance across all tested benchmarks.
Supervised Performance on GYAFC
On the GYAFC dataset, OT4 consistently outperformed strong baselines such as BART and GPT-2 models augmented with BLEU rewards. As shown in the results, OT4 achieved superior scores in BLEU, BLEURT, and style accuracy (ACC), leading to the highest Harmonic Mean (HM) of these metrics.
Unsupervised Performance on Yelp and IMDB
In the unsupervised setting, the improvements were even more pronounced. On the Yelp dataset, OT4 achieved a significantly higher G-score (the geometric mean of style accuracy and content preservation). Specifically, it improved the BERT-F1 score by 6.2% and self-BLEU by 11.8% over previous SOTA models like RACoLN.
The Importance of Syntax
Ablation studies confirmed that both semantic and syntactic components are crucial. Removing structural information led to a noticeable drop in performance, suggesting that syntax acts as a necessary constraint that prevents the model from relying solely on keyword matching.
Conclusion and Future Work
OT4 demonstrates that Optimal Transport is a powerful tool for aligning complex linguistic structures in TST. By explicitly modeling syntax alongside semantics, the framework achieves a better balance between style transformation and content preservation than previous methods.
Future research could address the computational overhead associated with solving the OT problem during training. Additionally, exploring the model's performance on more nuanced styles, such as author-specific imitation or persona-shifting, remains an open area for investigation.
Summary updated