Language style conversion method and device

Through word segmentation processing and word alignment model, word alignment sequence is generated, and non-autoregressive processing is performed in combination with the language style conversion model, the problems of information loss and inconsistency in language style conversion in the existing technology are solved, and efficient and accurate language style conversion is achieved.

CN113111640BActive Publication Date: 2024-11-01TSINGHUA UNIVERSITY
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110401970.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-14
Publication Date
2024-11-01
Estimated Expiration
2041-04-14

AI Technical Summary

Technical Problem

Existing language style conversion models are prone to losing information or adding irrelevant information during the conversion process, resulting in inconsistent text meaning.

Method used

Through word segmentation processing and word alignment model, word alignment sequence is generated, and non-autoregressive processing is performed in combination with the language style conversion model to ensure independent conversion of each word, reduce mutual interference, and improve information retention ability.

Benefits of technology

It realizes the consistency of text meaning before and after the conversion while fast language style conversion, and improves the efficiency and accuracy of language style conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113111640B_ABST
    Figure CN113111640B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for language style conversion, the method comprising: performing word segmentation processing on a text to be processed to obtain a word segmentation result; inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; inputting the word alignment sequence into a language style conversion model, and obtaining a target text corresponding to the text to be processed by a non-autoregressive processing method. The method and device for language style conversion provided by an embodiment of the present invention first obtain a word alignment sequence based on a word alignment model for the text to be processed, and then input the word alignment sequence into a language style conversion model to obtain a target text. Based on the above process, while satisfying the requirement of rapid language style conversion of the text to be processed, the consistency of the meaning of the text before and after the conversion is ensured, thereby achieving efficient and accurate processing of text language style conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text processing, and in particular to a language style conversion method and device. Background Art

[0002] With the rapid development of artificial intelligence technology, existing artificial intelligence models can already generate fluent natural language text in some tasks. However, current models generally lack the ability to control language style, which makes it difficult for designers to achieve emotional and anthropomorphic artificial intelligence, resulting in poor user satisfaction and low quality of human-computer communication.

[0003] In order to solve the above problems, language style conversion models were proposed. This type of model can convert input natural language text with a certain style or without style into text of another style. The definition of "style" is relatively broad. For example, whether the emotion contained in the text is positive or negative, whether it is written or spoken, or whether it imitates the writing style of a famous writer can all be considered as a type of "style".

[0004] The language style transfer model in the prior art has achieved certain results. Although it can convert text into a specified style, some information may be lost or irrelevant information may be added in the converted text, making it difficult to maintain the meaning of the text unchanged. Summary of the invention

[0005] The present invention provides a language style conversion method and device, which are used to solve the defect in the prior art that the meaning of the text is easily changed before and after the language style conversion, and achieve the goal of quickly converting the language style of the text to be processed while ensuring the consistency of the meaning of the text before and after the conversion.

[0006] The present invention provides a language style conversion method, comprising: performing word segmentation processing on a text to be processed to obtain a word segmentation result; inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; inputting the word alignment sequence into a language style conversion model to obtain a target text corresponding to the text to be processed by a non-autoregressive processing method.

[0007] According to a language style conversion method provided by the present invention, the word segmentation result is input into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed, specifically comprising: inputting the word segmentation result X=[x1, x2, ...x i …x N ] is input into the word alignment model, and the word alignment model is used to align the probability P G (T|X,S Y ) Generate a word alignment scheme T = [t1, t2, ... t i …t M], based on the word alignment scheme T = [t1, t2, ... t i …t M ]Generate word alignment sequence Wherein, X represents the text to be processed; S Y Indicates a language style; x i represents the i-th word of the word segmentation result; t i represents the i-th word alignment relationship in the word alignment scheme; x N Indicates the last word of the segmentation result; t M represents the last word alignment relationship in the word alignment scheme; represents the i-th word in the word alignment sequence; Indicates the last word in the word alignment sequence.

[0008] According to a language style conversion method provided by the present invention, the alignment probability is expressed as: when the alignment scheme is sequential alignment, then Where I[·] means that if the value in the bracket is true, it is 1, otherwise it is 0; when the alignment scheme is to use neural network prediction, then Wherein, M represents the number of word alignment relationships included in the word alignment scheme; N represents the number of words included in the word segmentation result; P G (t i |t <i ,X,S Y ) means that when t1, t2, …, t i-1 Under the condition of , the i-th alignment relationship in the word alignment scheme is based on the to-be-processed text X, the target text style S Y probability.

[0009] According to a language style conversion method provided by the present invention, the word alignment sequence is input into the language style conversion model, and a target text corresponding to the text to be processed is obtained by a non-autoregressive processing method, specifically comprising: inputting the word alignment sequence into the language style conversion model, encoding to obtain a feature vector sequence, and obtaining a feature vector sequence based on the feature vector sequence for each word in the target text based on the word alignment sequence X. T , target text style S Y The probability of each word in the target text based on the word alignment sequence X T , target text style S Y The probability of getting the target text;

[0010] P G (y i |X T ,S Y )=softmax(Whi +b)

[0011] Among them, P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , target text style S Y The probability of y i represents the i-th word in the target text; h i represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

[0012] According to a language style conversion method provided by the present invention, the method further includes:

[0013] The language style conversion model is obtained based on style discriminator training; wherein the style discriminator is obtained based on adversarial training with the language style conversion model;

[0014] Alternatively, the language style transfer model is obtained based on a separately trained stylized language model.

[0015] According to a language style conversion method provided by the present invention, the loss function of the language style conversion model during training is a linear weighted sum of an objective function L1, an objective function L2, and an objective function L3, wherein:

[0016]

[0017] L3=-f(G Y (X),S Y ),

[0018] in, represents the noisy text obtained after adding noise to X, S X represents a language style of X, S Y Another language style for X, G Y (X) indicates that the text to be processed is converted into S by the language style conversion model Y Styled text, Represents the text with noise and the first optimal word alignment scheme between the text to be processed X, Represents G Y (X) and the second best word alignment scheme between the text to be processed X, Indicates the optimal word alignment scheme based on the first and the first optimal word alignment sequence obtained by the noisy text X, Represents the second optimal word alignment scheme The text to be processed is converted into S by the language style conversion model Y Styled text G Y (X) The second best word alignment sequence obtained, Represents the first optimal word alignment sequence Target text style S X Generate the probability that the converted text is the text to be processed X, Indicates that the text with noise Target text style S X Predict the first optimal word alignment solution to be The probability of Represents the second optimal word alignment sequence Target text style S X Generate the probability that the converted text is the text to be processed X, Indicates that based on G Y (X), target text style S X The second best word alignment solution is predicted to be The probability of f(G Y (X),S Y ) represents G Y (X) is S Y Style score.

[0019] According to a language style conversion method provided by the present invention, for the language style conversion model obtained by training based on the style discriminator, the loss function is expressed as:

[0020] L G =0.5L1+L2+1.5L3

[0021] For the language style conversion model obtained by training based on the separately trained stylized language model, the loss function is expressed as:

[0022] L G =L1+L2+0.3L3.

[0023] The present invention also provides a language style conversion device, comprising: a word segmentation module, used to perform word segmentation processing on a text to be processed to obtain a word segmentation result; an alignment module, used to input the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; a conversion module, used to input the word alignment sequence into a language style conversion model to obtain a target text corresponding to the text to be processed through a non-autoregressive processing method.

[0024] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned language style conversion methods are implemented.

[0025] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned language style conversion methods are implemented.

[0026] The present invention provides a language style conversion method and device. The method first obtains a word alignment sequence based on a word alignment model for a text to be processed, and then inputs the word alignment sequence into a language style conversion model to obtain a target text. When the language style conversion model is used to convert the text to be processed, each word is used as a processing unit for non-autoregressive processing. Based on the above process, the mutual interference between each word in the language style conversion process is reduced, which is beneficial to the independence of each word conversion process. At the same time, the processing efficiency of the language style conversion process is also improved to a certain extent. Therefore, while satisfying the requirement of fast language style conversion of the text to be processed, the consistency of the meaning of the text before and after the conversion is ensured, and efficient and accurate processing of text language style conversion is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 This is one of the flow charts of the language style conversion method provided by the present invention;

[0029] Figure 2 This is the second flow chart of the language style conversion method provided by the present invention;

[0030] Figure 3 is a structural schematic diagram of a language style conversion device provided by the present invention;

[0031] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] Figure 1 is one of the flow charts of the language style conversion method provided by the present invention, such as Figure 1 As shown, the method includes:

[0034] Step S110, performing word segmentation processing on the text to be processed to obtain a word segmentation result;

[0035] Step S120, inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed;

[0036] Step S130: input the word alignment sequence into a language style transfer model, and obtain a target text corresponding to the text to be processed by a non-autoregressive processing method.

[0037] It should be noted that, in step S110, a sentence is taken as the text to be processed, and then the sentence is processed by word segmentation to obtain individual words. For example, the text before conversion is "worst food and will never come back", and after word segmentation, it is obtained "worst food and will never come back", which is represented by a set as X=[x1,x2,x3,x4,x5,x6,x7], where x1 represents "worst", x2 represents "food", x3 represents "and", x4 represents "will", x5 represents "never", x6 represents "come", and x7 represents "back".

[0038] It should be noted that in step S120, the word segmentation result obtained by the processing of step S110 is input into the word alignment model to obtain a word alignment sequence corresponding to the word segmentation result. In combination with the above example, after the word segmentation result is processed by word alignment, the following word alignment sequence is obtained, specifically "worst [Mask] food and will come back", where [Mask] represents the newly inserted alignment word, which is not in the text to be processed.

[0039] It should be noted that after the word alignment sequence is obtained through word alignment, it can be processed in a non-autoregressive manner. In step S130, the word alignment sequence obtained through the processing in step S120 is input into the language style conversion model, and a text with the target language style is obtained through a non-autoregressive processing method. In combination with the above example, after the obtained word alignment sequence is processed through language style conversion, the following text with the target style is obtained, specifically "most delicious food and will come back".

[0040] Specifically, the language style conversion model in the language style conversion method provided by the present invention can learn and control the number and type of words that need to be modified during style conversion based on the obtained word alignment sequence, thereby improving the information retention ability of style conversion. For example, if a word in the word alignment sequence does not affect the language style, the model can choose not to modify the word and generate the same word in the same position; if the word in the word alignment sequence can affect the language style, the language style conversion model will choose to modify the word and generate words related to the word but can make the text reflect a different style.

[0041] In the prior art, when a neural network model performs language style conversion on a text, it processes the text as a whole sentence and then obtains a corresponding sentence after conversion. It is unable to obtain fine-grained control over the relationship between words before and after the style conversion, so its information retention capability is relatively poor, and it is easy for irrelevant information to be added or valid information to be lost.

[0042] The language style conversion method provided by the present invention first obtains a word alignment sequence based on a word alignment model for the processed text, and then inputs the word alignment sequence into a language style conversion model to obtain a target text. When the language style conversion model is used to convert the processed text into a language style, each word is used as a processing unit for non-autoregressive processing. Based on the above process, the mutual interference between each word in the language style conversion process is reduced, which is beneficial to the independence of each word conversion process. At the same time, the processing efficiency of the language style conversion process is also improved to a certain extent, so that while satisfying the rapid language style conversion of the processed text, the consistency of the text meaning before and after the conversion is ensured, and efficient and accurate processing of the text language style conversion is achieved.

[0043] Furthermore, in the present invention, the word segmentation result is input into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed, which specifically includes: the word segmentation result X = [x1, x2, ... x i …x N ] is input into the word alignment model, and the word alignment model is used to align the probability P G (T|X,SY ) Generate a word alignment scheme T = [t1, t2, ... t i …t M ], generate word alignment sequences based on word alignment scheme Wherein, X represents the text to be processed; S Y Indicates a language style; x i represents the i-th word of the word segmentation result; t i represents the i-th alignment relationship in the word alignment scheme; x N Indicates the last word of the word alignment result; t M represents the last word alignment relationship in the word alignment scheme; represents the i-th word in the word alignment sequence; Represents the last word in the S-word alignment sequence.

[0044] It should be noted that in the process of using the word alignment model to process the word segmentation results to obtain the word alignment sequence, the generation basis of each word in the word alignment sequence is the word alignment scheme, and the word alignment scheme is not unique. Multiple word alignment schemes have their corresponding occurrence probabilities, which are called alignment probabilities P. G (T|X,S Y ), and the meaning of the alignment probability expression is “based on the to-be-processed text X and the target style S Y , the probability of occurrence of the alignment scheme T is "that is, the size of the alignment probability is determined by the to-be-processed text X and the target style S Y to decide together.

[0045] The language style conversion method provided by the present invention is based on the to-be-processed text X and the target style S Y Generate an alignment probability, then generate a word alignment scheme based on the alignment probability, and finally realize the process of converting the to-be-processed text into a word alignment sequence based on the word alignment scheme. That is, in the process of word alignment, the target style S Y As a basis for generating an alignment scheme, the correlation between the word alignment process and the subsequent language style conversion process is enhanced, thereby laying the foundation for the subsequent language style conversion process.

[0046] Furthermore, in the present invention, the alignment probability is expressed as: when the alignment scheme is sequential alignment, then Where I[·] means that if the value in the bracket is true, it is 1, otherwise it is 0; when the alignment scheme is to use neural network prediction, then Wherein, M represents the number of word alignment relationships included in the word alignment scheme; N represents the number of words included in the word segmentation result; P G (t i |t <i ,X,SY ) means that when t1, t2, …, t i-1 Under the condition that the i-th alignment relationship in the word alignment scheme is based on the text to be processed and the target text style is S Y probability.

[0047] It should be noted that in the actual word alignment process, different texts to be processed have different requirements for word alignment schemes. For most texts, a single alignment scheme can meet the requirements. This single alignment scheme is a sequential alignment method. At this time, the alignment probability can be Where I[·] means that when the value in the bracket is true, it takes 1, otherwise it takes 0. The alignment scheme obtained based on the alignment probability acquisition method is unique, that is, the alignment scheme of sequential alignment; however, when a part of the text is processed for word alignment, a single sequential alignment cannot meet the usage requirements. In this case, it is necessary to use the neural network prediction method to obtain the alignment scheme. In this case, the alignment probability is There are multiple alignment schemes obtained based on the alignment probability acquisition method; wherein M represents the number of word alignment relationships included in the word alignment scheme; N represents the number of words included in the word segmentation result; P G (t i |t <i ,X,S Y ) means that when t1, t2, …, t i-1 Under the condition that the i-th alignment relationship in the word alignment scheme is based on the text to be processed and the target text style is S Y probability.

[0048] It should be noted that the word alignment model does not have the ability to select the above two different word alignment probability acquisition methods by itself. The specific alignment probability acquisition method needs to be manually pre-set according to the characteristics of the text to be processed before training the word alignment model.

[0049] The language style conversion method provided by the present invention makes the method of obtaining the alignment probability optional, so that the word alignment model can perform a word alignment process on the specific text to be processed based on different methods of obtaining the alignment probability, thereby effectively improving the pertinence of the word alignment process and obtaining the best word alignment processing result.

[0050] Further, in the present invention, the word alignment sequence is input into the language style transfer model, and the target text corresponding to the to-be-processed text is obtained by a non-autoregressive processing method, specifically comprising: after the word alignment sequence is input into the language style transfer model, a feature vector sequence is obtained through encoding, and each word in the target text is obtained based on the word alignment sequence X based on the feature vector sequence.T , the target text style is S Y The probability of each word in the target text based on the word alignment sequence X T , the target text style is S Y The probability of getting the target text; P G (y i |X T ,S Y )=softmax(Wh i +b) where P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , the target text style is S Y The probability of y i represents the i-th word in the target text; h i represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

[0051] It should be noted that the word alignment sequence After inputting into the language style transfer model, first, the word alignment sequence After encoding, the feature vector sequence [h1,h2,…,h M ], with the help of the normalization function softmax function, the feature vector sequence is converted into probability. The specific conversion formula is: P G (y i |X T ,S Y )=softmax(Wh i +b), and for each probability P G (y i |X T ,S Y ) will predict a word accordingly. In the above process, because each probability P G (y i |X T ,S Y ) are all transformed from the corresponding feature vectors, so based on the above, each feature vector will be independently predicted to generate a word, and the prediction probability corresponding to each word does not interfere with each other, where P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , the target text style is S Y The probability of y i represents the i-th word in the target text; hi represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

[0052] It should be noted that, from the above, the probability of generating the corresponding target word for each feature vector is P G (y i |X T ,S Y ), so the probability of generating the corresponding target text from the feature vector sequence can be obtained based on the following probability model, specifically:

[0053] The language style conversion method provided by the present invention converts each feature vector into a probability P through a normalization function softmax function G (y i |X T ,S Y ), and based on the probability P in a non-autoregressive way G (y i |X T ,S Y ) predicts the word corresponding to each feature vector, avoiding the interference between the prediction probabilities in the word prediction process, improving the independence of word prediction, and ensuring the consistency of text meaning before and after language style conversion. At the same time, multiple feature vectors can be processed at the same time, which improves the processing efficiency of the language style conversion process.

[0054] Furthermore, in the present invention, the language style conversion method also includes: obtaining the language style conversion model based on style discriminator training; wherein the style discriminator is obtained based on adversarial training with the language style conversion model; or, obtaining the language style conversion model based on a separately trained stylized language model training.

[0055] The language style conversion method provided by the present invention provides two different training methods for language style conversion models, specifically obtaining the language style conversion model based on style discriminator training or obtaining the language style conversion model based on a separately trained stylized language model training. Based on the above process, the training method for the language style conversion model is enriched, which is conducive to selecting the language style conversion model obtained by different training methods as needed, and then the best language style conversion effect can be achieved for the specific text to be processed.

[0056] Furthermore, in the present invention, the loss function of the language style conversion model during training is the linear weighted sum of the objective function L1, the objective function L2 and the objective function L3, where:

[0057]

[0058] L3=-f(G Y (X),S Y ),

[0059] in, represents the noisy text obtained after adding noise to X, S X Indicates the language style of X, S Y Indicates another language style, G Y (X) indicates that the text to be processed is converted into S by the language style conversion model Y Styled text, Represents the text with noise and the first optimal word alignment scheme between the text to be processed X, Represents G Y (X) and the second best word alignment scheme between the text to be processed X, Indicates the optimal word alignment scheme based on the first and the first optimal word alignment sequence obtained by the noisy text X, Represents the second optimal word alignment scheme The text to be processed is converted into S by the language style conversion model Y Styled text G Y (X) The second best word alignment sequence obtained, Represents the first optimal word alignment sequence Target text style S X The probability that the generated converted text is the to-be-processed text X, Indicates that the text with noise Target text style S X Predict the first optimal word alignment solution to be The probability of Represents the second optimal word alignment sequence Target text style S X Generate the probability that the converted text is the text to be processed X, Indicates that based on G Y (X), target text style S X The second best word alignment solution is predicted to be The probability of f(G Y (X),S Y ) represents G Y (X) is S Y It should be noted that L1 and L2 in the objective function are the first optimal word alignment solution. and the second best word alignment solution Substituting into the existing objective function expression, we finally get the new objective function. The specific process is as follows:

[0060]

[0061] in, Represents the text based on the noise Target text style S X , generate the probability that the converted text is the text to be processed X; P(X|G Y (X),S X ) represents the text based on G Y (X), target text style S X , generating the probability that the converted text is the text to be processed X.

[0062] The language style conversion method provided by the present invention is to and the second best word alignment solution Substituting the objective function expression into the loss function, a new objective function expression is obtained, so that the loss function obtained based on the above objective function can achieve a good correspondence with the language style transfer model based on word alignment, thereby realizing accurate training of the conversion model.

[0063] Furthermore, in the present invention, for the language style conversion model obtained by training based on the style discriminator, the loss function is expressed as: L G =0.5L1+L2+1.5L3, for the language style conversion model obtained by training the stylized language model based on separate training, the loss function is expressed as: L G =L1+L2+0.3L3.

[0064] The language style conversion method provided by the present invention obtains different loss functions corresponding to the language style conversion model through different training methods. The common feature is that the proportions of the objective functions L1, L2 and L3 in the loss function are differentiated. When training the language style conversion model based on this type of loss function, a certain emphasis can be placed on the three objectives, so that the loss function can converge faster, thereby improving the training efficiency and training results of the model.

[0065] Based on the above, we can know that there are two different training methods when training the language style transfer model. The following is a detailed description of these two training methods:

[0066] A. Language style transfer model based on style discriminator training

[0067] A.1 Model structure

[0068] A.1.1 Embedding layer

[0069] Word embedding layer: input a single word and output a 256-dimensional vector.

[0070] Target style embedding layer: inputs the target style category and outputs a 256-dimensional vector.

[0071] The embedding layer is shared by Encoder and Decoder.

[0072] A.1.2Encoder

[0073] The Encoder consists of a Transformer network with 4 Transformer Layers. Each layer contains a multi-head self-attention layer and a single hidden layer MLP, and the hidden state dimension is 256. The multi-head self-attention layer contains 4 attention heads.

[0074] When the alignment scheme is sequential alignment, the Encoder inputs the sentence and the target style, which are converted into N 256-dimensional vectors (the sum of the word embedding and the target style embedding, where N is the length of the sentence) by the embedding layer. The Transformer network then encodes the input vector and outputs N 256-dimensional vectors (representing the encoded features of the input text).

[0075] When the alignment scheme is predicted using a neural network, the Encoder also contains another Transformer network for predicting the alignment scheme. The network has 1 Transformer Layer, a multi-head self-attention layer in each layer, a multi-head attention layer pointing to the Encoder output, and a single hidden layer MLP, with a hidden state dimension of 256. Both attention layers contain 4 attention heads. The Transformer network uses the prediction form of the Pointer Network, which is an autoregressive generator. Each step inputs a 256-dimensional vector (the sum of the word embedding predicted in the previous step and the target style embedding) and outputs a pointing position (or an empty position).

[0076] A.1.3Decoder

[0077] The decoder contains a Transformer network with 4 Transformer Layers, each of which contains a multi-head self-attention layer, a multi-head attention layer pointing to the encoder output, and a single hidden layer MLP with a hidden state dimension of 256. Both attention layers contain 4 attention heads.

[0078] The decoder also contains a linear classifier that converts the 256-dimensional vector into a word probability distribution. The decoder inputs the aligned sentence X T The embedding layer converts the word embedding and the target style embedding into M 256-dimensional vectors (the sum of the word embedding and the target style embedding, M is the length of the aligned sentence). The Transformer network then encodes the input vector and outputs M 256-dimensional vectors (representing the encoded features of the input text). The M 256-dimensional vectors are passed through the linear classifier to predict the converted words. In order to ensure that the gradient can be back-propagated during model training, the linear classifier uses Gumbel-Softmax Tricks.

[0079] A.1.4 Style Discriminator

[0080] The style discriminator consists of a single 256-dimensional word embedding layer.

[0081] The style discriminator contains a Transformer network with 4 Transformer Layers. Each layer contains a multi-head self-attention layer and a single hidden layer MLP, and the hidden state dimension is 256. The multi-head self-attention layer contains 4 attention heads. The style discriminator also contains a linear classifier that can convert the 256-dimensional vector into a probability distribution of style categories.

[0082] The style discriminator inputs a sentence, which is converted into N 256-dimensional vectors by the embedding layer, where N is the length of the sentence. The Transformer network will encode N 256-dimensional vectors and output N 256-dimensional vectors (representing the encoded features of the input text). The N 256-dimensional vector features are passed through max pooling and then through a linear classifier to predict the style category. If the input is X, its predicted category can be expressed as P D (S X |X).

[0083] A.2 Model training method

[0084] The training is divided into several iterations, each of which contains 10 style discriminator trainings and 5 style transfer model trainings. The following parameter updates all use the Adam optimizer, with a learning rate of 1e-4 and 64 samples per update.

[0085] A.2.1 A training run of the style discriminator is defined as follows:

[0086] Take sample X from the dataset, whose style is S X , choose any style S Y (S Y ≠S X ). Use the style transfer model to convert sample X into style S Y(See A.3 for the method), we get Use the style transfer model to convert sample X to style S X (See A.3 for the method), we get

[0087] X, Send it to the style discriminator and get P D (S X |X), The objective function is Finally, the Adam optimizer is used to train the style discriminator; where P D (S X |X) indicates that the style discriminator considers the style of X to be S X The probability of The style discriminator believes The style is S X The probability of The style discriminator believes The style is S Y probability.

[0088] A.2.2 A training of the style transfer model is defined as follows:

[0089] Randomly select a sample X from the data, whose style is S X , choose any style S Y (S Y ≠S X ).

[0090] Note that X can take any style of data, S X Determined by the selected sample, for example: S X The language style that expresses positive emotions, S Y A language style that expresses negative emotions.

[0091] A.2.2.1 Obtain L1, which is defined as follows:

[0092] A small amount of word addition or deletion operations are performed on sample X to obtain a noisy sample.

[0093] When the alignment scheme is sequential alignment, due to but Will and S X Send it to Encoder, then to Decoder, and you can get

[0094] When the alignment scheme is to use neural network prediction, Obtained by optimizing the following formula where for all i < j, there is t i < t j or t j = 0 holds; where represents the t i -th word of. e(·) represents word vector embedding. Sending and S X into the Encoder, we can get Then sending and S X into the Decoder, we can get

[0095] A.2.2.2 Obtain L2, which is defined as follows:

[0096] where the sample X is converted to the style S using the style conversion model Y (see A.3 for the method), and we can get

[0097] When the alignment scheme is sequential alignment, since then Sending and S X into the Encoder and then into the Decoder, we can get where represents the second-best word alignment sequence obtained based on the second-best word alignment scheme and , represents the probability of predicting that the second-best word alignment scheme is the target text style S X and is represents the probability that the target text style S X generates the converted text as the text to be processed X based on the second-best word alignment sequence.

[0098] When the alignment scheme is predicted by the neural network, it is obtained by optimizing the following formula: where represents the t i -th word of. Sending and S X into the Encoder, we can get Sending and S XSend it to Decoder and you can get

[0099] A.2.2.3 Obtain L3, which is defined as follows:

[0100] in Obtained from A.2.2.2. Send it to the style discriminator and you can get in The style discriminator believes The style is S Y probability.

[0101] A.2.2.4 Obtaining the final loss function L G , which is defined as follows:

[0102] L G =0.5L1+L2+1.5L3. This function is used as the objective function to train the style transfer model.

[0103] A.3 Model evaluation results

[0104] Taking the alignment scheme as an example, the model is trained and tested on the Yelp dataset, and the model can convert positive text into negative text, or negative text into positive text. Compared with similar models that do not use the method of the present invention, the semantic preservation ability is greatly improved. At the same time, the model training speed and the speed of using the model for language style conversion are significantly improved.

[0105] B. Based on the trained stylized language model, a language style transfer model is obtained

[0106] B.1 Model Structure

[0107] B.1.1 Embedding Layer

[0108] Word embedding layer: input a single word and output a 256-dimensional vector.

[0109] Target style embedding layer: inputs the target style category and outputs a 256-dimensional vector.

[0110] The embedding layer is shared by Encoder and Decoder.

[0111] B.1.2Encoder

[0112] The Encoder consists of a Transformer network with 4 Transformer Layers. Each layer contains a multi-head self-attention layer and a single hidden layer MLP, and the hidden state dimension is 256. The multi-head self-attention layer contains 4 attention heads.

[0113] When the alignment scheme is sequential alignment, the Encoder inputs the sentence and the target style, which are converted into N 256-dimensional vectors (the sum of the word embedding and the target style embedding, where N is the length of the sentence) by the embedding layer. The Transformer network then encodes the input vector and outputs N 256-dimensional vectors (representing the encoded features of the input text).

[0114] When the alignment scheme is predicted using a neural network, the Encoder also contains another Transformer network for predicting the alignment scheme. The network has 1 Transformer Layer, a multi-head self-attention layer in each layer, a multi-head attention layer pointing to the Encoder output, and a single hidden layer MLP, with a hidden state dimension of 256. Both attention layers contain 4 attention heads. The Transformer network uses the prediction form of the Pointer Network, which is an autoregressive generator. Each step inputs a 256-dimensional vector (the sum of the word embedding predicted in the previous step and the target style embedding) and outputs a pointing position (or an empty position).

[0115] B.1.3Decoder

[0116] The decoder contains a Transformer network with 4 Transformer Layers, each of which contains a multi-head self-attention layer, a multi-head attention layer pointing to the encoder output, and a single hidden layer MLP with a hidden state dimension of 256. Both attention layers contain 4 attention heads.

[0117] The decoder also contains a linear classifier that converts the 256-dimensional vector into a word probability distribution. The decoder inputs the aligned sentence X T The embedding layer converts the word embedding and the target style embedding into M 256-dimensional vectors (the sum of the word embedding and the target style embedding, M is the length of the aligned sentence). The Transformer network then encodes the input vector and outputs M 256-dimensional vectors (representing the encoded features of the input text). The M 256-dimensional vectors are passed through the linear classifier to predict the converted words. In order to ensure that the gradient can be back-propagated during model training, the linear classifier uses Gumbel-Softmax Tricks.

[0118] B.1.4 Trained Stylized Language Model

[0119] The styled language model consists of a separate word embedding layer and a target style embedding layer. The word embedding layer inputs a single word and outputs a 256-dimensional vector; the target style embedding layer inputs the target style category and outputs a 256-dimensional vector.

[0120] The styled language model consists of an LSTM network with a hidden state dimension of 512, which is an autoregressive language model. Its input is a 256-dimensional vector, which is the sum of the word embedding and the target style embedding. Its output is connected to a linear classifier to predict the next word. The generation probability of this model can be defined as Where P LM (X|S X ) represents the value based on the previous (i-1) words and the target style S X , the probability of generating the text to be processed X, P(x i |x <i ,S X ) represents the word based on the previous (i-1) word and the target style S X , generate the i-th word x in the text to be processed X i probability.

[0121] B.2 Model training method

[0122] The model first trains the stylized language model and then the style transfer model. The following parameter updates all use the Adam optimizer, with a learning rate of 1e-3 and 64 samples per update.

[0123] B.2.1 A training of the stylized language model is defined as follows:

[0124] Take sample X from the dataset, whose style is S X .

[0125] X, S X Send it to the style discriminator and get P LM (X|S X ). The training objective function is L LM = -logP LM (X|S X ). Use the Adam optimizer to train the stylized language model.

[0126] B.2.2 A training of the style transfer model is defined as follows:

[0127] Randomly select sample X from the data, whose style is S X , choose any style S Y (S Y ≠S X ).

[0128] B.2.2.1 Obtain L1, which is defined as follows:

[0129] Among them, by performing a small amount of word addition or deletion operations on the sample X, a noisy sample can be obtained

[0130] When the alignment scheme is sequential alignment, since then Send and S X into the Encoder, and then into the Decoder, and the following can be obtained

[0131] When the alignment scheme is to use a neural network for prediction, It is obtained by optimizing the following formula Among them, for all i < j, there is t i < t j or t j = 0 holds; among them represents the t i th word of. e(·) represents word vector embedding. Send and S X into the Encoder, and the following can be obtained Then send and S X into the Decoder, and the following can be obtained

[0132] B.2.2.2 Obtain L2, and its definition is as follows:

[0133] Among them, using the style conversion model to convert the sample X into the style S Y (see B.3 for the method), the following can be obtained

[0134] When the alignment scheme is sequential alignment, since then Send and S X into the Encoder, and then into the Decoder, and the following can be obtained Among them represents the second-optimal word alignment sequence obtained based on the second-optimal word alignment scheme and represents based on the target text style S X <000080>predicting that the second-optimal word alignment scheme is the probability of represents based on the second-optimal word alignment sequence the target text style SX Generate a probability that the converted text is the text to be processed X.

[0135] When the alignment scheme is predicted by neural network, It is obtained by optimizing the following formula: in express The tth i words. and S X Send it to Encoder and you can get Will and S X Send it to Decoder and you can get

[0136] B.2.2.3 Obtain L3, which is defined as follows:

[0137] beg in Obtained from B.2.2.2. Send it into the stylized language model and you can get in Indicates that when the target style is known to be S Y Under the premise of probability.

[0138] B.2.2.4 Obtaining the final loss function L G , which is defined as follows:

[0139] L G =L1+L2+0.3L3. This function is used as the objective function to train the style transfer model.

[0140] B.3 Model evaluation results

[0141] Taking the alignment scheme as the prediction by neural network as an example, the model is trained and tested on the GYAFC dataset. The model can convert written language into spoken language, or convert spoken language into written language. Compared with similar models that do not use the method of the present invention, the semantic preservation ability of the conversion is greatly improved, and the speed of model training and the speed of language style conversion using the model are significantly improved.

[0142] After the word alignment model and the language style transfer model are trained, the word segmentation results obtained based on the text to be processed are input into the word alignment model and the language style transfer model in turn, and finally the target text corresponding to the text to be processed is output. Figure 2 This is the second flow chart of the language style conversion method provided by the present invention. Figure 2 As shown, the specific process of the language style conversion method is:

[0143] For input sample X and target style S Y The generated result can be recorded as G Y (X) is obtained as follows:

[0144] When the alignment scheme is sequential alignment, X and S X Send to Encoder for encoding. The matching scheme of aligned words in order is T = [1, 2, ..., N]. Then X T and S X Send it to Decoder and get For each position i, we take P G (y i |X T ,S Y ) maximum probability y i Y=[y1,y2,…,y M ] is the generated result.

[0145] When the alignment scheme is predicted by neural network, X and S X Send to Encoder, predict the word matching probability P G (T|X,S Y ), from which random sampling can obtain the word matching scheme T. Then X T and S X Send it to Decoder and get For each position i, we take P G (y i |X T ,S Y )The y with the highest probability i Y=[y1,y2,…,y M ] is the generated result.

[0146] Figure 3 Schematic diagram of the structure of the language style conversion device provided by the present invention. Figure 3 As shown, the device includes a word segmentation module 310, an alignment module 320 and a conversion module 330, wherein:

[0147] The word segmentation module 310 is used to perform word segmentation on the text to be processed and obtain a word segmentation result;

[0148] An alignment module 320 is used to input the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed;

[0149] The conversion module 330 is used to input the word alignment sequence into a language style conversion model, and obtain a target text corresponding to the text to be processed by a non-autoregressive processing method.

[0150] The present invention provides a language style conversion device. The device obtains a word alignment sequence based on a word alignment model for a text to be processed, and then inputs the word alignment sequence into a language style conversion model to obtain a target text. When the language style conversion model is used to convert the text to be processed, each word is used as a processing unit for non-autoregressive processing. Based on the above process, the mutual interference between each word in the language style conversion process is reduced, which is beneficial to the independence of each word conversion process. At the same time, the processing efficiency of the language style conversion process is also improved to a certain extent. Therefore, while satisfying the requirement of fast language style conversion of the text to be processed, the consistency of the meaning of the text before and after the conversion is ensured, and efficient and accurate processing of text language style conversion is achieved.

[0151] According to a language style conversion device provided by the present invention, the alignment module 320 is specifically used to convert the word segmentation result X=[x1, x2, ...x i …x N ] is input into the word alignment model, and the word alignment model is used to align the probability P G (T|X,S Y ) Generate a word alignment scheme T = [t1, t2, ... t i …t M ], generate word alignment sequences based on word alignment scheme Wherein, X represents the text to be processed; S Y Indicates a language style; x i represents the i-th word of the word segmentation result; t i represents the i-th alignment relationship in the word alignment scheme; x N Indicates the last word of the word alignment result; t M represents the last word alignment relationship in the word alignment scheme; represents the i-th word in the word alignment sequence; Indicates the last word in the word alignment sequence.

[0152] The present invention provides a language style conversion device, which is based on the to-be-processed text X and the target style S Y Generate an alignment probability, then generate a word alignment scheme based on the alignment probability, and finally realize the process of converting the to-be-processed text into a word alignment sequence based on the word alignment scheme. That is, in the process of word alignment, the target style S Y As a basis for generating an alignment scheme, the correlation between the word alignment process and the subsequent language style conversion process is enhanced, thereby laying the foundation for the subsequent language style conversion process.

[0153] According to a language style conversion device provided by the present invention, the conversion module 330 is specifically used to input the word alignment sequence into the language style conversion model, obtain a feature vector sequence after encoding, and obtain each word in the target text based on the word alignment sequence X based on the feature vector sequence. T , the target text style is S Y The probability of each word in the target text based on the word alignment sequence X T , the target text style is S Y The probability of getting the target text; P G (y i |X T ,S Y )=softmax(Wh i +b), where P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , the target text style is S Y The probability of y i represents the i-th word in the target text; h i represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

[0154] The present invention provides a language style conversion device, which converts each feature vector into a probability P through a normalization function softmax function G (y i |X T ,S Y ), and based on the probability P in a non-autoregressive way G (y i |X T ,S Y ) predicts the words corresponding to each feature vector, avoiding the interference between the feature vectors in the word prediction process, improving the independence of word prediction, ensuring the consistency of text meaning before and after language style conversion, and multiple feature vectors can be processed at the same time, improving the processing efficiency of the language style conversion process.

[0155] According to a language style conversion device provided by the present invention, the language style conversion device is also used to obtain the language style conversion model based on style discriminator training; wherein the style discriminator is obtained based on adversarial training with the language style conversion model; or, the language style conversion model is obtained based on training of a separately trained stylized language model.

[0156] The present invention provides a language style conversion device, which provides two different training methods for language style conversion models, specifically obtaining the language style conversion model based on style discriminator training or obtaining the language style conversion model based on a separately trained stylized language model training. Based on the above process, the training method for the language style conversion model is enriched, which is conducive to selecting the language style conversion model obtained by different training methods as needed, and then the best language style conversion effect can be achieved for the specific text to be processed.

[0157] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute a language style conversion method, which includes: performing word segmentation processing on the text to be processed to obtain a word segmentation result; inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; inputting the word alignment sequence into the language style conversion model to obtain a target text corresponding to the text to be processed by a non-autoregressive processing method.

[0158] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0159] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the language style conversion method provided by the above methods, and the method includes: performing word segmentation processing on the text to be processed to obtain a word segmentation result; inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; inputting the word alignment sequence into the language style conversion model, and obtaining a target text corresponding to the text to be processed through a non-autoregressive processing method.

[0160] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned language style conversion methods, the methods comprising: performing word segmentation processing on a text to be processed to obtain a word segmentation result; inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; inputting the word alignment sequence into a language style conversion model to obtain a target text corresponding to the text to be processed through a non-autoregressive processing method.

[0161] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A language style conversion method, characterized in that: include: Perform word segmentation on the text to be processed to obtain the word segmentation result; Inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; Inputting the word alignment sequence into a language style transfer model, and obtaining a target text corresponding to the text to be processed by a non-autoregressive processing method; The step of inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed specifically includes: The word segmentation result X = [x1, x2, ... x i …x N ] is input into the word alignment model, and the word alignment model is used to align the probability P G (T|X,S Y ) Generate a word alignment scheme T = [t1, t2, ... t i …t M ], based on the word alignment scheme T = [t1, t2, ... t i …t M ]Generate word alignment sequence Wherein, X represents the text to be processed; S Y Indicates a language style; x i represents the i-th word of the word segmentation result; t i represents the i-th word alignment relationship in the word alignment scheme; x N Indicates the last word of the segmentation result; t M represents the last word alignment relationship in the word alignment scheme; represents the i-th word in the word alignment sequence; Indicates the last word in the word alignment sequence; The step of inputting the word alignment sequence into the language style transfer model and obtaining the target text corresponding to the to-be-processed text by a non-autoregressive processing method specifically includes: inputting the word alignment sequence into the language style transfer model, encoding to obtain a feature vector sequence, and obtaining a feature vector sequence based on the feature vector sequence for each word in the target text. T , target text style S Y The probability of each word in the target text based on the word alignment sequence X T , target text style S Y The probability of getting the target text; P G (y i |X T ,S Y )=softmax(Wh i +b) Among them, P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , target text style S Y The probability of y i represents the i-th word in the target text; h i represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

2. The language style conversion method according to claim 1, characterized in that: The alignment probability is expressed as: When the alignment scheme is sequential alignment, Where I[·] means that if the value in the brackets is true, it takes 1, otherwise it takes 0; When the alignment scheme is to use neural network prediction, then Wherein, M represents the number of word alignment relationships included in the word alignment scheme; N represents the number of words included in the word segmentation result; P G (t i |t <i ,X,S Y ) means that when t1, t2, …, t i-1 Under the condition of , the i-th alignment relationship in the word alignment scheme is based on the to-be-processed text X, the target text style S Y probability.

3. The language style conversion method according to claim 1, characterized in that: The method further comprises: The language style conversion model is obtained based on style discriminator training; wherein the style discriminator is obtained based on adversarial training with the language style conversion model; Alternatively, the language style transfer model is obtained based on a separately trained stylized language model.

4. The language style conversion method according to claim 3, characterized in that: The loss function of the language style conversion model during training is the linear weighted sum of the objective function L1, the objective function L2, and the objective function L3, where: L3=-f(G Y (X),S Y ), in, represents the noisy text obtained after adding noise to X, S X represents a language style of X, S Y Indicates another language style, G Y (X) indicates that the text to be processed is converted into S by the language style conversion model Y Styled text, Represents the text with noise and the first optimal word alignment scheme between the text to be processed X, Represents G Y (X) and the second best word alignment scheme between the text to be processed X, Indicates the optimal word alignment scheme based on the first and the first optimal word alignment sequence obtained by the noisy text X, Represents the second optimal word alignment scheme The text to be processed is converted into S by the language style conversion model Y Styled text G Y (X) The second best word alignment sequence obtained, Represents the first optimal word alignment sequence Target text style S X The probability that the generated converted text is the to-be-processed text X, Indicates that the text with noise Target text style S X Predict the first optimal word alignment solution to be The probability of Represents the second optimal word alignment sequence Target text style S X Generate the probability that the converted text is the text to be processed X, Indicates that based on G Y (X), target text style S X The second best word alignment solution is predicted to be The probability of f(G Y (X),S Y ) represents G Y (X) is S Y Style score.

5. The language style conversion method according to claim 4, characterized in that: For the language style conversion model obtained by training based on the style discriminator, the loss function is expressed as: <h2 style=";text-align:left;direction:ltr">L<h2 style=";text-align:left;direction:ltr"> G <h2 style=";text-align:left;direction:ltr"> = 0.5L1+L2+1.5L3 For the language style conversion model obtained by training based on the separately trained stylized language model, the loss function is expressed as: <h2 style=";text-align:left;direction:ltr">L<h2 style=";text-align:left;direction:ltr"> G <h2 style=";text-align:left;direction:ltr"> =L1+L2+0.3L3.

6. A language style conversion device, characterized in that: include: The word segmentation module is used to perform word segmentation on the text to be processed and obtain the word segmentation result; An alignment module, used for inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed; A conversion module, used for inputting the word alignment sequence into a language style conversion model, and obtaining a target text corresponding to the text to be processed by a non-autoregressive processing method; The step of inputting the word segmentation result into a word alignment model to obtain a word alignment sequence corresponding to the text to be processed specifically includes: The word segmentation result X = [x1, x2, ... x i …x N ] is input into the word alignment model, and the word alignment model is used to align the probability P G (T|X,S Y ) Generate a word alignment scheme T = [t1, t2, ... t i …t M ], based on the word alignment scheme T = [t1, t2, ... t i …t M ]Generate word alignment sequence Wherein, X represents the text to be processed; S Y Indicates a language style; x i represents the i-th word of the word segmentation result; t i represents the i-th word alignment relationship in the word alignment scheme; x N Indicates the last word of the segmentation result; t M represents the last word alignment relationship in the word alignment scheme; represents the i-th word in the word alignment sequence; Indicates the last word in the word alignment sequence; The step of inputting the word alignment sequence into the language style transfer model and obtaining the target text corresponding to the to-be-processed text by a non-autoregressive processing method specifically includes: inputting the word alignment sequence into the language style transfer model, encoding to obtain a feature vector sequence, and obtaining a feature vector sequence based on the feature vector sequence for each word in the target text. T , target text style S Y The probability of each word in the target text based on the word alignment sequence X T , target text style S Y The probability of getting the target text; P G (y i |X T ,S Y )=softmax(Wh i +b) Among them, P G (y i |X T ,S Y ) represents the i-th word in the target text based on the word alignment sequence X T , target text style S Y The probability of y i represents the i-th word in the target text; h i represents the i-th feature vector in the feature vector sequence; W and b are learnable network parameters.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Old-Chinese bilingual alignment method based on Transformer model

    CN110083826A

  • Method and device for generating audio, equipment and medium

    CN111899720A

  • Language style conversion model training method and text processing method and device

    CN112016271A

  • Controllable Style-Based Text Transformation

    US20200311195A1