Abstract
We introduce a language generative model framework for generating a styled paragraph based on a context sentence and a style reference example. The framework consists of a style encoder and a text decoder. The style encoder extracts a style code from the reference example, and the text decoder generates texts based on the style code and the context. We propose a novel objective function to train our framework and investigate different network design choices. We conduct extensive experimental validation with comparison to strong baselines to validate the effectiveness of the proposed framework using a newly collected dataset with diverse text styles.
Introduction
Most state-of-the-art language models are stylistically rigid, typically generating text that reflects the specific domain of their training data. While some models utilize categorical "control codes" to influence output, these methods are limited to predefined categories and lack the fluidity of human expression. Humans can adapt the same factual information into various styles—from formal reports to casual prose—simply by observing examples. This paper addresses the challenge of example-guided generation, creating a system that mimics the stylistic essence of a specific reference text provided at runtime.
Architecture and Methodology
The proposed framework, Generative Adversarial Transformers, consists of two primary components: a Style Encoder ($F_s$) and a Text Decoder ($F_g$). The Style Encoder extracts a latent "style code" from a reference paragraph, while the Text Decoder utilizes a context sentence (the content) and this style code (the form) to generate the final output.
Adaptive Layer Normalization (AdaLN)
A critical contribution of this work is the investigation of style injection methods. The researchers evaluated four distinct architectures for integrating the style code into the decoder:
- Model A: Injection at the input embedding layer.
- Model B: Injection via attention mechanisms.
- Model C: Injection using gated attention biases.
- Model D (AdaLN): Modulation of the scale and bias of normalization layers.
Inspired by the success of StyleGAN in image synthesis, Model D (Adaptive Layer Normalization) proved most effective. By modulating the normalization layers within the Transformer, the style code permeates every layer of the generation process, allowing for more nuanced and consistent stylistic control compared to simple initial "hints."
Training Strategy
The model is trained using a dual-stream approach to balance content preservation and style accuracy:
- Reconstruction Stream: The model learns to reconstruct a paragraph using a different paragraph of the same style as a reference.
- Cross-style Generation Stream: The model generates text using a context from one style and a reference from a different style.
To ensure high-quality output, the framework employs a GAN-based discriminator and a pre-trained style comparator. Furthermore, Knowledge Distillation is used to align the model's probability distributions with a pre-trained GPT-2 model, maintaining linguistic fluency while the adversarial components push for stylistic adherence.
Experimental Results
The framework was evaluated on two large-scale datasets: a 3-Style Dataset (News, Books, Reviews) and a more granular 21-Style Dataset (including Science, Romance, Poetry, and Business).
Performance Comparison
Quantitative analysis demonstrated that Model D (AdaLN) consistently achieved the best balance between style accuracy and fluency. As shown in the performance plot, Model D occupies the upper-right quadrant, indicating high scores in both metrics compared to baselines like the Style Code (SC) method or standard GPT-2 variants.
Human Evaluation
In human preference studies, the model's output was found to be nearly as fluent as human-written text, scoring 56-57% in "Turing-style" indistinguishability tests (where 50% is the baseline). On the challenging 21-style dataset, human evaluators correctly identified the target style 69% of the time, significantly outperforming previous state-of-the-art methods.
Conclusion
By treating style as a global characteristic that can be modulated through normalization—much like in computer vision—this framework enables highly flexible, example-guided text generation. While the computational cost of training remains high and the current focus is on paragraph-level generation, the success of the AdaLN-based Transformer suggests a promising path forward for more controllable and expressive AI writing tools.
Summary updated