Objective In recent years,numerous style transfer methods in the text style transfer(TST)have relied on semi-supervised and unsupervised learn-ing.The central concept of these methods involves mapping the text into a latent space,enabling the separation of content and style representa-tions and facilitating style transfer.Text style transfer focuses on converting text attributes or styles while preserving the semantic content of the source sentences.Existing methods achieve significant progress in addressing the challenges associated with traditional TST tasks.However,these methods continue to face common limitations,including mismatches between the content and style of the transferred text and difficulties in maintaining the core semantics of the original text.Minimizing textual information loss during the transfer process remains critical to resolving content-style matching issues and preserving core semantics.Method This study introduces a flow-based text style transfer model.It adopts neural spline flows(NSF)as the foundational flow model for the text transfer task using the potential of flows in style transfer tasks.Flows employing affine coupling or autoregressive transformations provide ac-curate density assessment and sampling.The model comprises a conditional encoder,a series of invertible flows,a style discriminator,and two conditional decoders.The encoder(X→Z)transforms input sentences into the latent space.The forward process of the flow model is represented as f:Z→(Z),abstracts the latent space encoding to a higher dimension,separates content and style,and reconstructs them.The inverse process,denoted as f-1:(Z)→Z,returns to the latent space.The conditional decoder(Z→X)interprets the latent space's hidden state into the target sen-tence required for the TST task.Initially,non-parallel datasets of various styles are partitioned into two domains,labeled as'a'and'b'represent-ing opposing styles to illustrate the task of transferring a sentence from style'a'to style'b'.Input sentences xsrca and xsrcb,belonging to different style domains,exhibit non-parallel text content.This research derives their initial latent state space encodings,za and zb,respectively by input-ting xsrca and xsrcb into the encoder.za is the hidden state sequence obtained by xsrca through the encoder,and likewise for zb corresponding to xsrcb.Then,using the flow,za and zb are remapped to another distribution space,yielding encodings(z)a and(z)b.In the(Z)space,which is the latent space mapped by the flow,(z)a is retained to reconstruct content while separating style.This study extends neural spline flows to further process the en-coded latent variable(z).Coupling transformations divide the input(z)into two parts,and compute θ=NN(z1:n-1),and(z)i=fθi(zi).Then,set(z)*b,1:n-1=(z)a,1:n-1 and return(z)*b=[(z)a,1:n-1,(z)b,n:d].This transformation finalizes the conversion from(z)a to(z)*b.NSF proposes monotonic rational-quadratic transforms as an alternative to coupling layers or additive/affine transformations in autoregressive layers.This approach enhances flex-ibility while preserving precise reversibility.The study employs monotonic rational-quadratic splines and their inverses as building blocks to im-plement functions fi and f-1i,where a monotonically increasing rational quadratic function defines each interval.Subsequently,the reverse pro-cess through the flow is applied to restore z*b to the Z space.In addition,a pre-trained discriminator is employed in the model training process to compare reconstructed stylized z*b with its original content source za The results are utilized to optimize the decoder.Finally,the conditional de-coder pa→b(x|z)is employed to obtain the transferred text xrecb.Similarly,for the task of transferring a style'b'sentence to style'a',the recon-struction object is(z)b,resulting in z*a.Another decoder,pb→a(x|z),is utilized to decode and obtain xreca.Results and Discussion The automatic evaluation metrics results indicated that the proposed method achieves the highest scores in terms of trans-fer accuracy(ACC)and ref-BLEU compared to the baseline models in both sentiment transfer and stance transfer tasks.In the instance analysis,several example sentences are extracted from the outputs of the sentiment transfer task for further comparison.The proposed method outperforms the selected baseline model when processing text containing multiple key pieces of information.The human evaluation results demonstrated that the proposed method performs better overall in text-style transfer tasks than the baseline.In addition,each model performs better in the sentiment transfer task than in the political stance transfer task.This difference is attributed to the subtle and implicit nature of the style information in polit-ical stance texts compared to sentiment texts.Effectively extracting these features remains an important research focus for future work.This sec-tion introduces a new metric for evaluating content preservation(CP)more comprehensively during the style transfer process to intuitively ex-press the comprehensive performance of the models.The experiment modifies the criteria proposed by Krishna et al.and combines these three scores into a single sum.This combination method supports the evaluation of content preservation by considering the similarity between the refer-ence text and the original text.Hence,a more comprehensive understanding of how well the model preserves the essential content during the text style transfer process is obtained.The proposed method achieves a 3%higher comprehensive score than the suboptimal model in sentiment trans-fer and a 5%higher score in political stance transfer.These results suggest that employing neural spline flows to handle latent space sequences not only improves content preservation but also balances transfer accuracy on this basis.Conclusion This study proposes a flow-based text style transfer model.It constructs a transformation function based on neural spline flows to ad-dress the issue of preserving text content during the TST task.It aims to reduce content and style mismatches after the TST task by jointly train-ing the decoder with recomposed hidden state sequences derived from variations in the initial hidden state sequences.The neural spline flow-based model manipulates latent text sequences with high preservation by adjusting the number of stacked flows to achieve disentanglement ef-fects on different text styles and contents.The flexibility and analytic reversibility of autoregressive transformations in neural spline flows reduce the loss of original content and semantic damage when encoding latent space hidden states.
text generationtext style transferneural networkneural spline flows