Text conversion method, device, medium and electronic device

By combining the encoding and decoding sub-model of the language model, the initial words are determined and text conversion is performed with them as the starting point, which solves the problems of overfitting and order differences between different languages ​​in the natural language model, and improves the efficiency and accuracy of text conversion. Improved user experience.

CN113947060BActive Publication Date: 2024-11-01BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111217727.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-19
Publication Date
2024-11-01
Estimated Expiration
2041-10-19

AI Technical Summary

Technical Problem

Natural language models are prone to overfitting during text generation, resulting in reduced efficiency and accuracy, and it is difficult to deal with differences in different languages ​​or writing orders during language models training.

Method used

The input text is encoded through the coding sub-model of the language model, the initial words are determined, and the feature vectors are decoded based on the decoding sub-model, word sequence splicing is performed in combination with the prediction direction, and converted text is generated, allowing it to be performed in any order Text conversion to avoid overfitting.

Benefits of technology

It improves the diversity and accuracy of text conversion, broadens the scope of application, improves user experience, and to a certain extent the training efficiency and accuracy of language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113947060B_ABST
    Figure CN113947060B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text conversion method, device, medium and electronic device. The method comprises: encoding an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text; determining an initial word for text conversion according to a prediction sub-model of the language model and the feature vector, wherein the initial word is any word in a converted text obtained by performing text conversion; decoding the feature vector based on a decoding sub-model of the language model with the initial word as a starting point to obtain a word sequence of a converted text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a predicted direction of the next predicted word of the predicted word, and the initial word is a predicted word in the first element in the word sequence; and concatenating the predicted words in each element based on the predicted direction in each element of the word sequence to obtain the converted text corresponding to the input text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of natural language, and in particular, to a text conversion method, device, medium and electronic device. Background Art

[0002] With the development of computer technology and language models, the application of natural language models is becoming more and more extensive. For example, based on language models, texts in different languages ​​can be translated and converted to facilitate user use.

[0003] In the related art, when text is generated based on a language model, since natural language sentences are usually written from left to right or from right to left, the word sequences generated in the language model are also constructed from left to right or from right to left, which leads to overfitting problems in the training process of the language model, reducing the efficiency and accuracy of text generation by the language model. Summary of the invention

[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0005] In a first aspect, the present disclosure provides a text conversion method, the method comprising:

[0006] Encode the input text according to the encoding sub-model of the language model to obtain a feature vector of the input text;

[0007] Determining an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing the text conversion;

[0008] Based on the decoding sub-model of the language model, the feature vector is decoded with the initial word as the starting point to obtain a word sequence of the conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of the next predicted word of the predicted word, and the initial word is the predicted word in the first element in the word sequence;

[0009] The predicted words in each element of the word sequence are concatenated based on the prediction direction in each element to obtain the converted text corresponding to the input text.

[0010] In a second aspect, the present disclosure provides a text conversion device, the device comprising:

[0011] A first encoding module, used for encoding an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text;

[0012] A first determination module is used to determine an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion;

[0013] a first decoding module, configured to decode the feature vector based on a decoding sub-model of the language model and taking the initial word as a starting point to obtain a word sequence of a conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of a next predicted word of the predicted word, and the initial word is a predicted word in the first element of the word sequence;

[0014] The concatenation module is used to concatenate the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text.

[0015] According to a third aspect, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processing device, the steps of the method described in the first aspect are implemented.

[0016] In a fourth aspect, an electronic device is provided, including:

[0017] a storage device having a computer program stored thereon;

[0018] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.

[0019] In the above technical solution, the input text can be encoded according to the encoding submodel of the language model to obtain the feature vector of the input text, and then the initial word for text conversion can be determined according to the prediction submodel of the language model and the feature vector, and then the feature vector can be decoded based on the decoding submodel of the language model with the initial word as the starting point to obtain the word sequence of the conversion text corresponding to the input text, so that the predicted words in each element can be spliced ​​based on the prediction direction in each element of the word sequence to obtain the conversion text corresponding to the input text. Therefore, through the above technical solution, any word can be used as the starting point for decoding in the process of text conversion generation, so that the diversity of text conversion can be improved and the application scope of the text conversion method can be broadened. And in the embodiment of the present disclosure, the language model can perform text conversion in any order, and can also effectively avoid the overfitting phenomenon of the language model in the training process, improve the accuracy and training efficiency of the language model, thereby improving the efficiency and accuracy of text conversion to a certain extent, and improving the user experience.

[0020] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0022] Figure 1 is a flowchart of a text conversion method provided according to an embodiment of the present disclosure;

[0023] Figure 2 is a schematic diagram of the structure of the language model provided for the present disclosure;

[0024] Figure 3 is a schematic diagram of the converted text obtained by decoding;

[0025] Figure 4 It is a schematic diagram of the structure of the encoding sub-model and the prediction sub-model provided for the present disclosure;

[0026] Figure 5 is a block diagram of a text conversion device provided according to an embodiment of the present disclosure;

[0027] Figure 6 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0028] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0030] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0031] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0032] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0033] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0034] Figure 1 As shown, it is a flowchart of a text conversion method provided according to an embodiment of the present disclosure, such as Figure 1 As shown, the method may include:

[0035] In step 11, the input text is encoded according to the encoding sub-model of the language model to obtain a feature vector of the input text. Figure 2 The structure diagram of the language model provided by the present disclosure is shown. The structure of the encoding sub-model can be implemented according to the encoder structure commonly used in the art, and the present disclosure does not limit this.

[0036] In step 12, an initial word for text conversion is determined based on the prediction sub-model and feature vector of the language model, wherein the initial word is any word in the converted text obtained by text conversion.

[0037] As described in the background technology, in the prior art, decoding is performed based on the same writing order as the input text, that is, decoding is performed in the same direction to generate text. In this embodiment, before decoding the feature vector, prediction can be performed based on the prediction sub-model, so that the initial word for text conversion can be determined, and text generation can be performed based on the initial word, which can be any word in the converted text. For example, Figure 3 As shown, it is a schematic diagram of the converted text obtained by decoding. It can be decoded from flash as the initial word, and it can also be decoded from language as the initial word. It can be spirally decoded starting from the word in the middle position, and the language model can be used as a spiral language model.

[0038] For example, in actual application, the expressions of different languages ​​or language modes for text conversion are different. For example, Chinese is written from left to right, while English is not consistent with the expression order in Chinese. Therefore, in the technical solution disclosed in the present invention, the corresponding initial word can be determined first, and then the text is generated based on the initial word. Compared with the order from left to right or from right to left in the prior art, while improving the decoding diversity, it can also make the decoding process more compatible with the expression of the converted text, thereby improving the accuracy of text conversion.

[0039] In step 13, based on the decoding sub-model of the language model, the feature vector is decoded starting from the initial word to obtain a word sequence of the converted text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of the next predicted word of the predicted word, and the initial word is the predicted word in the first element in the word sequence.

[0040] For example, each element in the word sequence can be a tuple, and the element (x t ,+) indicates that the current predicted word is x t , its prediction mode is right direction, that is, the next predicted word is x t+1 . Among them, “-” can be used to indicate that the prediction direction is the left direction, and “+” can be used to indicate that the prediction direction is the right direction. As another example, for [(x t ,-),(x t-1 ,-)], whose definition clause is [x t ,x t-1 ], the prediction direction "-" in the last element means that the next predicted word is placed on the left side of the clause, so the next predicted word in the word sequence is x t-2Similarly, for [(x t ,-),(x t-1 ,+)], and its definition clause is also [x t ,x t-1 ], the prediction direction "+" in the last element indicates that the next predicted word is placed on the right side of the clause, so the next predicted word in the word sequence is x t+1 .

[0041] Therefore, the feature vector can be decoded from the initial word, and the word sequence of the converted text can be obtained by combining the prediction direction, so that the decoded words are continuous, which is convenient for representing the decoding process, and text generation can be performed around the initial word, which is in line with the actual application scenario.

[0042] In step 14, the predicted words in each element of the word sequence are concatenated based on the prediction direction in each element to obtain a converted text corresponding to the input text.

[0043] As shown above, each element in the word sequence indicates the prediction direction of the next predicted word of the predicted word in the element, so that the predicted words can be spliced ​​and connected based on the prediction direction to obtain a complete and orderly converted text.

[0044] Therefore, in the above technical solution, the input text can be encoded according to the encoding submodel of the language model to obtain the feature vector of the input text, and then the initial word for text conversion can be determined according to the prediction submodel of the language model and the feature vector, and then the feature vector can be decoded based on the decoding submodel of the language model with the initial word as the starting point to obtain the word sequence of the conversion text corresponding to the input text, so that the predicted words in each element can be spliced ​​based on the prediction direction in each element of the word sequence to obtain the conversion text corresponding to the input text. Therefore, through the above technical solution, any word can be used as the starting point for decoding in the process of text conversion generation, so that the diversity of text conversion can be improved and the application scope of the text conversion method can be broadened. And in the embodiment of the present disclosure, the language model can perform text conversion in any order, and can also effectively avoid the overfitting phenomenon of the language model in the training process, improve the accuracy and training efficiency of the language model, thereby improving the efficiency and accuracy of text conversion to a certain extent, and improving the user experience.

[0045] In a possible embodiment, an exemplary implementation of determining the initial word for text conversion based on the prediction sub-model of the language model and the feature vector is as follows. This step may include:

[0046] The feature vector is linearly mapped based on a target vocabulary corresponding to the text conversion to obtain a linear vector corresponding to the feature vector and the target vocabulary.

[0047] For example, Figure 4 As shown, it is a schematic diagram of the structure of the encoding sub-model and the prediction sub-model provided by the present invention, wherein the prediction sub-model can be implemented by a linear mapping layer Linear and an attention mechanism attention to predict the initial word.

[0048] The target word list is the word list of the text corresponding to the target end after the input text is converted, which contains each word that can be converted. For example, the number of words in the target word list is n, and the feature vector of the input text is represented by H, then the linear vector v can be represented as:

[0049] v=Linear(H),H∈R m*h ,v∈R m*n , where m is the length of the input text.

[0050] Afterwards, the attention vector corresponding to the word in the target vocabulary is determined according to the linear vector, and the initial word is determined based on the probability corresponding to each word in the target vocabulary determined by the attention vector.

[0051] For example, the attention vector corresponding to a word in the target vocabulary can be determined by the following formula:

[0052]

[0053]

[0054] Among them, v k represents the attention vector of the kth word in the target vocabulary;

[0055] t is used to represent the tth time step of encoding the input text, t∈[1,m];

[0056] Used to represent the attention parameter corresponding to the kth word in the target vocabulary at the tth time step;

[0057] Used to represent the probability that the kth word in the target vocabulary is the initial word at the tth time step.

[0058] Therefore, after determining the attention vector of each word in the target vocabulary, the probability can be determined based on the activation function, that is:

[0059] p θ (v k |s)=sigmoid(v k)

[0060] Among them, p θ (v k |s) is used to represent the probability that the kth word in the target vocabulary is the initial word corresponding to the input text s; the sigmoid() function has the properties of monotonically increasing and inverse monotonically increasing, which can map the variable to between 0 and 1, thereby realizing the normalization of the probability, so as to determine the initial word based on the probability of each word.

[0061] As an example, if there is only one initial word, the word with the highest corresponding probability in the target word list can be determined as the initial word. As another example, in order to expand the search space of the optimal sequence during decoding, the initial word can be multiple, and the words in the target word list can be sorted in descending order according to their probability of being the initial word, so as to select in sequence according to the preset number of initial words.

[0062] Therefore, through the above technical scheme, the target vocabulary can be mapped through the prediction sub-model, and the probability of each word in the target vocabulary as the initial word can be determined based on the attention mechanism, so that the initial word can be determined from the target vocabulary, ensuring the accuracy of the initial word, providing reliable data support for decoding by the decoding sub-model, and ensuring the accuracy of the converted text obtained by decoding.

[0063] In a possible embodiment, the decoding sub-model based on the language model decodes the feature vector starting from the initial word to obtain a word sequence of the converted text corresponding to the input text. The exemplary implementation method is as follows. This step may include:

[0064] The feature vector is decoded from a target direction with the predicted word in the target element as a starting point to obtain a predicted word corresponding to the target direction, wherein the target element is initially an element including the initial word, and the target direction includes a left direction and a right direction.

[0065] For example, Figure 3 As shown, the determined initial word is flash, and it can be further decoded from the left direction to obtain the predicted word "a", and decoded from the right direction to obtain the predicted word "of".

[0066] For each predicted word, a prediction parameter of a predicted clause formed by the predicted word and a decoded clause is determined, wherein the decoded clause is a sentence formed based on the decoded target element.

[0067] Among them, the sentence formed by the decoded target element can be a sentence obtained by splicing the predicted word in the decoded target element according to the prediction direction, and its initial situation is the initial word. The predicted clause formed by the predicted word and the decoding clause can be a clause obtained by splicing the predicted word with the decoding clause according to the target direction corresponding to the predicted word. Then in this step, the predicted word "a" can be spliced ​​with the decoding clause according to its corresponding target direction to obtain the predicted clause "aflash", and the predicted word "of" can be spliced ​​with the decoding clause according to its corresponding target direction to obtain the predicted clause "flash of". Afterwards, the prediction parameters corresponding to the predicted clause "a flash" and the predicted clause "flash of" can be determined according to the model parameters in the decoding sub-model.

[0068] Determining a candidate clause according to the prediction parameters of the prediction clause;

[0069] The target direction corresponding to the predicted word in the candidate clause is determined as the predicted direction in the target element, and the target element is added to the word sequence corresponding to the candidate clause.

[0070] For example, if the determined candidate clause is "a flash", the target direction corresponding to the predicted word "a" in the candidate clause can be determined as the predicted direction in the target element, that is, the left direction "-" is used as the predicted direction in the target element "flash", and the element (flash,-) is added to the word sequence corresponding to the candidate clause. At this time, the word sequence is expressed as {(flash,-)}.

[0071] Afterwards, the element corresponding to the predicted word corresponding to the candidate clause is taken as the new target element, and the step of decoding the feature vector from the target direction with the predicted word in the target element as the starting point to obtain the predicted word corresponding to the target direction is re-executed until the left terminator and the right terminator are decoded.

[0072] That is, further, the element corresponding to the predicted word "a" is used as a new target element, so that it can be further decoded from the left direction to obtain the predicted word "is", and decoded from the right direction to obtain the predicted word "of". At this time, the decoding clause becomes "a flash", and the predicted word "is" can be spliced ​​with the decoding clause according to its corresponding target direction to obtain the predicted clause "is a flash", and the predicted word "of" can be spliced ​​with the decoding clause according to its corresponding target direction to obtain the predicted clause "a flash of", and then the prediction parameters of each predicted clause are determined to further determine the candidate clause. For example, if the determined candidate clause is "is a flash", the target direction corresponding to the predicted word "is" in the candidate clause can be determined as the predicted direction in the target element, that is, the left direction "-" is used as the predicted direction in the target element "a", and the element (a,-) is added to the word sequence corresponding to the candidate clause. At this time, the word sequence is represented as {(flash,-), (a,-)}.

[0073] After that, further decoding is performed based on the above method until the decoding is completed. The specific method is similar to that described above and will not be repeated here. The final decoded word sequence can be expressed as:

[0074] {(flash,-),(a,-),(is,+),(of,-),(language,+),(the,-),(A,+),(human,-),([EOL],+),(spirit,+),(.,+),([EOR],+)}

[0075] [EOL] is used to represent the left terminator, and [EOR] is used to represent the right terminator.

[0076] In the prior art, when using a language model to generate sentences, the length of the generated sentence is unknown. A special marker [EOS] is introduced to indicate the end of sentence generation. When [EOS] is generated, it means that the sentence is over and no further generation is required. t , we need to know all the words x before t <t For example, when generating word x5, you need to know [x1,x2,x3,x4]. If you only know [x1,x2,x3], you can only generate word x4. Based on the above technical solution, more generation order candidates can be provided based on the initial word. Combined with the prediction direction, the remaining words can be generated from any word to the left or right until the left terminator [EOL] and the right terminator [EOR] are generated.

[0077] Therefore, through the above technical solution, in the process of decoding the feature vector based on the initial word, it is possible to try to decode to the left or right, and determine a more accurate candidate clause based on the prediction parameters, thereby determining the corresponding prediction direction and the predicted word for the next decoding, while ensuring the decoding diversity, the accuracy of the decoding process can be further improved, the matching of the word sequence obtained by decoding with the actual application scenario can be ensured, and the accuracy of the converted text obtained by decoding can be improved.

[0078] In a possible embodiment, the initial words are multiple, for example, the determined initial words are "flash" and "language", then decoding can be attempted based on the multiple initial words based on the above method, so as to obtain the predicted clause corresponding to each initial word. In the embodiment of the present disclosure, beam search can be used to search in the process of decoding the remaining words. Accordingly, according to the prediction parameters of the predicted clause, the exemplary implementation method of determining the candidate clause is as follows, and this step may include:

[0079] The prediction clauses corresponding to the top N parameters ranked from high to low among the multiple prediction parameters are determined as the candidate clauses, wherein N is an integer greater than 1.

[0080] For example, the beam size is 2, that is, N is 2. Continuing with the above example, flash can be decoded from both the left and right directions, and language can be decoded from the left and right directions, that is, [(flash,-),(flash,+),(language,-),(language,+)] can be used for decoding. For example, the predicted clauses obtained by decoding flash from the left and right directions are "aflash" and "flash of", and the predicted clauses obtained by decoding language from the left and right directions are "A language" and "language is", respectively. Then, the prediction parameters of the four prediction clauses can be determined. Since N is 2, the top two prediction clauses ranked from large to small in prediction parameters can be used as the candidate clauses. For example, the prediction parameters corresponding to the prediction clauses "a flash", "flash of", "A language" and "language is" are 0.8, 0.5, 0.4 and 0.6, respectively, and the prediction clauses "a flash" and "language is" can be selected as the candidate clauses. is" is taken as the candidate clause, so that for each predicted clause, subsequent decoding can be performed in the manner described above. In each decoding process, multiple candidate clauses can be considered, thereby increasing the possibility of searching for the optimal sequence, reducing the cumulative error to a certain extent, and improving the accuracy of the converted text.

[0081] In a possible embodiment, the step of splicing the predicted words in each element of the word sequence based on the prediction direction to obtain the converted text corresponding to the input text may include:

[0082] According to the order of the elements in the word sequence, each element is obtained in turn. For example, in the example described above, the word sequence is:

[0083] {(flash,-),(a,-),(is,+),(of,-),(language,+),(the,-),(A,+),(human,-),([EOL],+),(spirit,+),(.,+),([EOR],+)};

[0084] Then you can get each element in sequence according to the decoding order.

[0085] For the current element, concatenate the predicted word in the next element of the current element with the concatenated sequence according to the prediction direction in the current element to obtain a new concatenated text, wherein the concatenated text is initially the initial word;

[0086] The concatenated text obtained by concatenating the predicted words in each element is determined as the converted text.

[0087] For example, the current element is "flash" and the predicted word in its next element is "a". Then the predicted word "a" can be spliced ​​with the spliced ​​sequence according to the prediction direction in the current element, that is, the left direction, to obtain the spliced ​​text "a flash". Afterwards, the current element is "a" and the predicted word in its next element is "is". Then the predicted word "is" can be spliced ​​with the spliced ​​sequence according to the prediction direction in the current element, that is, the left direction, to obtain the spliced ​​text "isa flash". Afterwards, the current element is "is" and the predicted word in its next element is "of". Then the predicted word "of" can be spliced ​​with the spliced ​​sequence according to the prediction direction in the current element, that is, the right direction, to obtain the spliced ​​text "isa flash of", and so on to further obtain the spliced ​​text

[0088] "language is a flash of",

[0089] "language is a flash of the",

[0090] "A language is a flash of the",

[0091] "A language is a flash of the human",

[0092] "[EOL]A language is a flash of the human"

[0093] "[EOL]A language is a flash of the human spirit"

[0094] "[EOL]A language is a flash of the human spirit."

[0095] "[EOL]A language is a flash of the human spirit.[EOR]";

[0096] Thus, the predicted words in each element are spliced ​​together, and the spliced ​​text finally obtained is used as the converted text. Therefore, through the above technical solution, the decoded predicted words can be spliced ​​together in combination with the prediction direction, which can not only support the diversity of decoding, but also ensure the accuracy of the converted text obtained by decoding, meet the user's usage needs, and improve the accuracy of text conversion.

[0097] In a possible embodiment, the language model can be trained in the following manner:

[0098] Training samples are obtained, wherein each of the training samples includes a training text, a target text corresponding to the training text, and a target generation order, and different training samples including the same training text have different target texts and target generation orders.

[0099] For example, the training text is: Language is the shining point of human spirit, and its corresponding target text and target generation order can be:

[0100] {(flash,-),(a,-),(is,+),(of,-),(language,+),(the,-),(A,+),(human,-),([EOL],+),(spirit,+),(.,+),([EOR],+)};

[0101] The target text and target generation order can also be expressed separately:

[0102] {flash,a,is,of,language,the,A,human,[EOL],spirit,.,[EOR]};

[0103] {-,-,+,-,+,-,+,-,+,+,+,+}.

[0104] Similarly, its target text and target generation order can also be expressed as follows:

[0105] {(flash,+),(of,-),(a,-),(is,-),(language,+),(the,-),(A,+),(human,-),([EOL],+),(spirit,+),(.,+),([EOR],+)}.

[0106] Therefore, in this embodiment, the conversion text corresponding to the training text can be represented in different generation orders, so that a variety of different training samples can be generated for one training text, providing rich data support for subsequent training of the language model.

[0107] Afterwards, the training sample is input into the encoding sub-model of the language model to obtain a prediction feature vector corresponding to the training text in the training sample;

[0108] Inputting the predicted feature vector into the prediction sub-model of the language model to determine the predicted initial word for text conversion;

[0109] Based on the decoding sub-model of the language model, the prediction feature vector is decoded with the prediction initial word as the starting point to obtain a prediction word sequence of the prediction text corresponding to the training text.

[0110] The method of generating the predicted initial word and the predicted word sequence in this process is the same as the implementation method of determining the initial word and the word sequence described above, and will not be repeated here.

[0111] A loss is calculated based on the predicted word sequence and the target text in the training sample to obtain a target loss of the language model, and parameters of the language model are adjusted based on the target loss to obtain a trained language model.

[0112] In this embodiment, for a training text, it may correspond to a plurality of training samples with different generation orders. In the process of training the language model based on the training samples, the language model may learn different generation orders, so that the text may be converted in the most recent generation order as much as possible, thereby improving the usage scenarios of the language model and avoiding the problem of overfitting to a certain extent, thereby improving the accuracy and training efficiency of the language model and saving user operations.

[0113] In a possible embodiment, the loss calculation is performed according to the predicted word sequence and the target text in the training sample to obtain the target loss of the language model, and the parameters of the language model are adjusted according to the target loss. An exemplary implementation method for obtaining the trained language model is as follows. This step may include:

[0114] Loss calculation is performed according to the predicted word sequence corresponding to the training sample, the target text in the training sample, and the target generation sequence to obtain the prediction loss corresponding to the training sample.

[0115] Among them, the loss can be calculated based on the distance between the predicted word sequence and the predicted probability between the target text and the target generation order. For example, if the initial word in the predicted word sequence is flash, the corresponding probability is 0.7, and the first word in the target text is flash, then the distance between the corresponding predicted probabilities is 0.3. Similarly, if the initial word in the next predicted word sequence is a, the corresponding probability is 0.8, and the next word in the target text is a, then the distance between the corresponding predicted probabilities is 0.2. The rest is inferred accordingly and will not be repeated.

[0116] For example, the sum of the absolute values ​​of the distances between the prediction probabilities of each predicted word corresponding to the predicted word sequence can be used as the prediction loss, or the sum of the squares of the distances between the prediction probabilities of each predicted word corresponding to the predicted word sequence can be used as the prediction loss, or the prediction loss can be determined by the loss calculation method commonly used in the art, which is not limited in the present disclosure.

[0117] A first prediction loss is determined according to prediction losses corresponding to multiple groups of training samples containing the same training text, and parameters of the encoding sub-model and the decoding sub-model are adjusted according to the first prediction loss.

[0118] In this step, the prediction losses corresponding to multiple groups of training samples corresponding to the same training text can be used to determine the comprehensive loss corresponding to the training text. For example, it can be the average value of the prediction losses corresponding to the multiple groups of training samples, or the weighted sum of the prediction losses corresponding to the multiple groups of training samples. The weights of the prediction losses corresponding to the multiple groups of training samples can be pre-set according to the order of annotation generation. Afterwards, the sum of the comprehensive losses corresponding to each training text in the current batch can be determined as the first prediction loss, so that in the process of adjusting the parameters of the encoding sub-model and the decoding sub-model based on the first prediction loss, the expectation of all generation orders can be maximized:

[0119] Among them, z gis the set of all possible generated sentences, θ represents the parameters in the encoding sub-model and the decoding sub-model of the language model, thereby, the optimal generation order can be found in the process of applying the language generation model.

[0120] As an example, the parameters of the encoding sub-model and the decoding sub-model are adjusted according to the first prediction loss. When the first prediction loss is greater than a first threshold, that is, when the prediction accuracy of the language model is insufficient, the parameters of the encoding sub-model and the decoding sub-model can be adjusted based on the gradient descent method to improve their prediction accuracy. Alternatively, when the number of training iterations is less than the training threshold, the parameters of the encoding sub-model and the decoding sub-model can be adjusted based on the gradient descent method to improve their prediction accuracy.

[0121] The predicted feature vector is linearly mapped based on the target vocabulary to obtain a predicted vocabulary vector corresponding to the predicted feature vector and the target vocabulary. Similarly, the method for determining the predicted vocabulary vector is the same as the specific method for generating the linear vector described above, which will not be repeated here.

[0122] Based on the predicted linear vector and the vocabulary vector corresponding to the target text, a second prediction loss is determined, and the parameters of the prediction sub-model are adjusted according to the second prediction loss.

[0123] The target text can be mapped based on the target vocabulary, where if a word in the target vocabulary appears in the target text, its mapped label is 1, and if a word in the target vocabulary does not appear in the target text, its mapped label is 0, thereby forming a vocabulary vector corresponding to the target text. Then, a loss calculation can be performed based on the predicted linear vector and the vocabulary vector based on binary classification cross entropy to obtain a second prediction loss.

[0124] As an example, the parameters of the prediction sub-model are adjusted according to the second prediction loss. When the second prediction loss is greater than a second threshold, that is, when the prediction accuracy of the prediction sub-model is insufficient, the parameters of the prediction sub-model can be adjusted based on the gradient descent method to improve its prediction accuracy. Alternatively, when the number of training iterations is less than the training threshold, the parameters of the prediction sub-model can be adjusted based on the gradient descent method to improve its prediction accuracy.

[0125] Therefore, through the above technical solution, parameters of different sub-models in the language model can be adjusted separately to ensure the rationality of the loss calculation of each sub-model, thereby providing accurate data support for parameter adjustment of the sub-model, improving the prediction accuracy of the language model and the training efficiency of the language model, and enhancing the user experience.

[0126] The present disclosure also provides a text conversion device, such as Figure 5As shown, the device 10 comprises:

[0127] A first encoding module 100, configured to encode an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text;

[0128] A first determination module 200 is used to determine an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion;

[0129] A first decoding module 300 is configured to decode the feature vector based on a decoding sub-model of the language model and take the initial word as a starting point to obtain a word sequence of a conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of a next predicted word of the predicted word, and the initial word is a predicted word in the first element of the word sequence;

[0130] The concatenation module 400 is configured to concatenate the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text.

[0131] Optionally, the first determining module includes:

[0132] A mapping submodule, configured to perform linear mapping on the feature vector based on a target vocabulary corresponding to the text conversion, to obtain a linear vector corresponding to the feature vector and the target vocabulary;

[0133] The first determination submodule is used to determine the attention vector corresponding to the word in the target vocabulary according to the linear vector, and determine the initial word based on the probability corresponding to each word in the target vocabulary determined by the attention vector.

[0134] Optionally, the first decoding module includes:

[0135] A decoding submodule, configured to decode the feature vector from a target direction with the predicted word in the target element as a starting point to obtain a predicted word corresponding to the target direction, wherein the target element is initially an element including the initial word, and the target direction includes a left direction and a right direction;

[0136] A second determination submodule is used to determine, for each predicted word, a prediction parameter of a predicted clause formed by the predicted word and a decoding clause, wherein the decoding clause is a sentence formed based on a decoded target element;

[0137] A third determination submodule, configured to determine a candidate clause according to the prediction parameters of the prediction clause;

[0138] The fourth determination submodule is used to determine the target direction corresponding to the predicted word in the candidate clause as the predicted direction in the target element, and add the target element to the word sequence corresponding to the candidate clause; and use the element corresponding to the predicted word corresponding to the candidate clause as a new target element, and re-execute the decoding submodule to decode the feature vector from the target direction with the predicted word in the target element as the starting point to obtain the predicted word corresponding to the target direction, until the left terminator and the right terminator are decoded.

[0139] Optionally, there are multiple initial words, and the third determination submodule is used to:

[0140] The prediction clauses corresponding to the top N parameters ranked from high to low among the multiple prediction parameters are determined as the candidate clauses, wherein N is an integer greater than 1.

[0141] Optionally, the splicing module includes:

[0142] An acquisition submodule, used to sequentially acquire each element in the word sequence according to the order of each element in the word sequence;

[0143] A splicing submodule, for splicing the predicted word in the next element of the current element with the spliced ​​sequence according to the prediction direction in the current element, to obtain a new spliced ​​text, wherein the spliced ​​text is initially the initial word;

[0144] The fifth determining submodule is used to determine the concatenated text obtained by concatenating the predicted words in each element as the converted text.

[0145] Optionally, the language model is trained by a training device, and the training device includes:

[0146] A first acquisition module is used to acquire training samples, wherein each of the training samples includes a training text, a target text corresponding to the training text, and a target generation order, and different training samples including the same training text have different target texts and target generation orders;

[0147] A second encoding module, used for inputting the training sample into the encoding sub-model of the language model to obtain a prediction feature vector corresponding to the training text in the training sample;

[0148] A second determination module, configured to input the predicted feature vector into a prediction sub-model of the language model to determine a predicted initial word for text conversion;

[0149] A second decoding module, based on a decoding sub-model of the language model, decodes the predicted feature vector with the predicted initial word as a starting point to obtain a predicted word sequence of the predicted text corresponding to the training text;

[0150] The adjustment module is used to calculate the loss according to the predicted word sequence and the target text in the training sample to obtain the target loss of the language model, and adjust the parameters of the language model according to the target loss to obtain the trained language model.

[0151] Optionally, the adjustment module includes:

[0152] A first calculation submodule is used to perform loss calculation according to the predicted word sequence corresponding to the training sample, the target text in the training sample, and the target generation sequence to obtain the prediction loss corresponding to the training sample;

[0153] A first adjustment submodule, configured to determine a first prediction loss according to prediction losses corresponding to a plurality of groups of training samples containing the same training text, and to adjust parameters of the encoding submodel and the decoding submodel according to the first prediction loss;

[0154] A second calculation submodule is used to perform linear mapping on the predicted feature vector based on a target vocabulary to obtain a predicted vocabulary vector corresponding to the predicted feature vector and the target vocabulary;

[0155] The second adjustment submodule is used to determine a second prediction loss based on the predicted linear vector and the vocabulary vector corresponding to the target text, and adjust the parameters of the prediction submodel according to the second prediction loss.

[0156] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0157] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0158] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0159] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0160] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0161] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0162] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0163] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: encodes the input text according to the encoding submodel of the language model to obtain the feature vector of the input text; determines the initial word for text conversion according to the prediction submodel of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by text conversion; decodes the feature vector based on the decoding submodel of the language model with the initial word as the starting point to obtain a word sequence of the converted text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a predicted direction of the next predicted word of the predicted word, and the initial word is the predicted word in the first element in the word sequence; splices the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text.

[0164] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0165] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0166] The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of a module does not limit the module itself in some cases. For example, the first encoding module may also be described as "a module for encoding an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text".

[0167] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0168] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0169] According to one or more embodiments of the present disclosure, Example 1 provides a text conversion method, wherein the method includes:

[0170] Encode the input text according to the encoding sub-model of the language model to obtain a feature vector of the input text;

[0171] Determining an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion;

[0172] Based on the decoding sub-model of the language model, the feature vector is decoded with the initial word as the starting point to obtain a word sequence of the conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of the next predicted word of the predicted word, and the initial word is the predicted word in the first element in the word sequence;

[0173] The predicted words in each element of the word sequence are concatenated based on the prediction direction in each element to obtain the converted text corresponding to the input text.

[0174] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein determining the initial word for text conversion according to the prediction sub-model of the language model and the feature vector includes:

[0175] Performing linear mapping on the feature vector based on a target vocabulary corresponding to the text conversion to obtain a linear vector corresponding to the feature vector and the target vocabulary;

[0176] An attention vector corresponding to a word in the target vocabulary is determined according to the linear vector, and the initial word is determined based on the probability corresponding to each word in the target vocabulary determined by the attention vector.

[0177] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 1, wherein the decoding sub-model based on the language model decodes the feature vector starting from the initial word to obtain a word sequence of the converted text corresponding to the input text, including:

[0178] Taking the predicted word in the target element as a starting point, the feature vector is decoded from a target direction to obtain a predicted word corresponding to the target direction, wherein the target element is initially an element including the initial word, and the target direction includes a left direction and a right direction;

[0179] For each predicted word, determining a prediction parameter of a predicted clause formed by the predicted word and a decoding clause, wherein the decoding clause is a sentence formed based on the decoded target element;

[0180] Determining a candidate clause according to the prediction parameters of the prediction clause;

[0181] Determine the target direction corresponding to the predicted word in the candidate clause as the predicted direction in the target element, and add the target element to the word sequence corresponding to the candidate clause;

[0182] The element corresponding to the predicted word corresponding to the candidate clause is taken as a new target element, and the step of decoding the feature vector from a target direction starting from the predicted word in the target element is re-executed to obtain the predicted word corresponding to the target direction until the left terminator and the right terminator are decoded.

[0183] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein the initial word is multiple, and determining a candidate clause according to the prediction parameter of the predicted clause includes:

[0184] The prediction clauses corresponding to the top N parameters ranked from high to low among the multiple prediction parameters are determined as the candidate clauses, wherein N is an integer greater than 1.

[0185] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, wherein the step of splicing the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text includes:

[0186] Obtaining each element in turn according to the order of each element in the word sequence;

[0187] For the current element, concatenate the predicted word in the next element of the current element with the concatenated sequence according to the prediction direction in the current element to obtain a new concatenated text, wherein the concatenated text is initially the initial word;

[0188] The concatenated text obtained by concatenating the predicted words in each element is determined as the converted text.

[0189] According to one or more embodiments of the present disclosure, Example 6 provides the method of any one of Examples 1-5, wherein the language model is trained in the following manner:

[0190] Acquire training samples, wherein each of the training samples includes a training text, a target text corresponding to the training text, and a target generation order, and different training samples including the same training text have different target texts and target generation orders;

[0191] Inputting the training sample into the encoding sub-model of the language model to obtain a prediction feature vector corresponding to the training text in the training sample;

[0192] Inputting the predicted feature vector into the prediction sub-model of the language model to determine the predicted initial word for text conversion;

[0193] Based on the decoding sub-model of the language model, the prediction feature vector is decoded with the prediction initial word as the starting point to obtain a prediction word sequence of the prediction text corresponding to the training text;

[0194] A loss is calculated based on the predicted word sequence and the target text in the training sample to obtain a target loss of the language model, and parameters of the language model are adjusted based on the target loss to obtain a trained language model.

[0195] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein the step of performing loss calculation according to the predicted word sequence and the target text in the training sample to obtain the target loss of the language model, and adjusting the parameters of the language model according to the target loss to obtain the trained language model includes:

[0196] Calculate the loss according to the predicted word sequence corresponding to the training sample, the target text in the training sample, and the target generation order to obtain the prediction loss corresponding to the training sample;

[0197] Determine a first prediction loss according to prediction losses corresponding to multiple groups of training samples containing the same training text, and adjust parameters of the encoding sub-model and the decoding sub-model according to the first prediction loss;

[0198] Performing linear mapping on the predicted feature vector based on the target vocabulary to obtain a predicted vocabulary vector corresponding to the predicted feature vector and the target vocabulary;

[0199] Based on the predicted linear vector and the vocabulary vector corresponding to the target text, a second prediction loss is determined, and the parameters of the prediction sub-model are adjusted according to the second prediction loss.

[0200] According to one or more embodiments of the present disclosure, Example 8 provides a text conversion device, wherein the device includes:

[0201] A first encoding module, used for encoding an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text;

[0202] A first determination module is used to determine an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion;

[0203] a first decoding module, configured to decode the feature vector based on a decoding sub-model of the language model and taking the initial word as a starting point to obtain a word sequence of a conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of a next predicted word of the predicted word, and the initial word is a predicted word in the first element of the word sequence;

[0204] The concatenation module is used to concatenate the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text.

[0205] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-7 when executed by a processing device.

[0206] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, including:

[0207] a storage device having a computer program stored thereon;

[0208] A processing device is used to execute the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-7.

[0209] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0210] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0211] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A text conversion method, characterized in that: The method comprises: Encode the input text according to the encoding sub-model of the language model to obtain a feature vector of the input text; Determining an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion; Based on the decoding sub-model of the language model, the feature vector is decoded with the initial word as the starting point to obtain a word sequence of the conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of the next predicted word of the predicted word, and the initial word is the predicted word in the first element in the word sequence; splicing the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text; The decoding sub-model based on the language model decodes the feature vector starting from the initial word to obtain a word sequence of the converted text corresponding to the input text, including: Taking the predicted word in the target element as a starting point, the feature vector is decoded from a target direction to obtain a predicted word corresponding to the target direction, wherein the target element is initially an element including the initial word, and the target direction includes a left direction and a right direction; For each predicted word, determining a prediction parameter of a predicted clause formed by the predicted word and a decoding clause, wherein the decoding clause is a sentence formed based on the decoded target element; Determining a candidate clause according to the prediction parameters of the prediction clause; Determine the target direction corresponding to the predicted word in the candidate clause as the predicted direction in the target element, and add the target element to the word sequence corresponding to the candidate clause; The element corresponding to the predicted word corresponding to the candidate clause is taken as a new target element, and the step of decoding the feature vector from a target direction starting from the predicted word in the target element is re-executed to obtain the predicted word corresponding to the target direction until the left terminator and the right terminator are decoded.

2. The method according to claim 1, characterized in that The step of determining an initial word for text conversion based on the prediction sub-model of the language model and the feature vector comprises: Performing linear mapping on the feature vector based on a target vocabulary corresponding to the text conversion to obtain a linear vector corresponding to the feature vector and the target vocabulary; An attention vector corresponding to a word in the target vocabulary is determined according to the linear vector, and the initial word is determined based on the probability corresponding to each word in the target vocabulary determined by the attention vector.

3. The method according to claim 1, characterized in that: The initial word is multiple, and the candidate clause is determined according to the prediction parameter of the prediction clause, including: The prediction clauses corresponding to the top N parameters ranked from high to low among the multiple prediction parameters are determined as the candidate clauses, wherein N is an integer greater than 1.

4. The method according to claim 1, characterized in that: The step of concatenating the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text includes: Obtaining each element in turn according to the order of each element in the word sequence; For the current element, concatenate the predicted word in the next element of the current element with the concatenated sequence according to the prediction direction in the current element to obtain a new concatenated text, wherein the concatenated text is initially the initial word; The concatenated text obtained by concatenating the predicted words in each element is determined as the converted text.

5. The method according to any one of claims 1 to 4, characterized in that The language model is trained in the following way: Acquire training samples, wherein each of the training samples includes a training text, a target text corresponding to the training text, and a target generation order, and different training samples including the same training text have different target texts and target generation orders; Inputting the training sample into the encoding sub-model of the language model to obtain a prediction feature vector corresponding to the training text in the training sample; Inputting the predicted feature vector into the prediction sub-model of the language model to determine the predicted initial word for text conversion; Based on the decoding sub-model of the language model, the prediction feature vector is decoded with the prediction initial word as the starting point to obtain a prediction word sequence of the prediction text corresponding to the training text; A loss calculation is performed according to the predicted word sequence and the target text in the training sample to obtain a target loss of the language model, and parameters of the language model are adjusted according to the target loss to obtain a trained language model.

6. The method according to claim 5, characterized in that The step of performing loss calculation according to the predicted word sequence and the target text in the training sample to obtain the target loss of the language model, and adjusting the parameters of the language model according to the target loss to obtain the trained language model includes: Calculate the loss according to the predicted word sequence corresponding to the training sample, the target text in the training sample, and the target generation order to obtain the prediction loss corresponding to the training sample; Determine a first prediction loss according to prediction losses corresponding to multiple groups of training samples containing the same training text, and adjust parameters of the encoding sub-model and the decoding sub-model according to the first prediction loss; Performing linear mapping on the predicted feature vector based on the target vocabulary to obtain a predicted vocabulary vector corresponding to the predicted feature vector and the target vocabulary; Based on the predicted linear vector and the vocabulary vector corresponding to the target text, a second prediction loss is determined, and the parameters of the prediction sub-model are adjusted according to the second prediction loss.

7. A text conversion device, characterized in that: The device comprises: A first encoding module, used for encoding an input text according to an encoding sub-model of a language model to obtain a feature vector of the input text; A first determination module is used to determine an initial word for text conversion according to the prediction sub-model of the language model and the feature vector, wherein the initial word is any word in the converted text obtained by performing text conversion; a first decoding module, configured to decode the feature vector based on a decoding sub-model of the language model and taking the initial word as a starting point to obtain a word sequence of a conversion text corresponding to the input text, wherein each element in the word sequence includes a predicted word and a prediction direction of a next predicted word of the predicted word, and the initial word is a predicted word in the first element of the word sequence; A splicing module, configured to splice the predicted words in each element based on the prediction direction in each element of the word sequence to obtain the converted text corresponding to the input text; The first decoding module comprises: A decoding submodule, configured to decode the feature vector from a target direction with the predicted word in the target element as a starting point to obtain a predicted word corresponding to the target direction, wherein the target element is initially an element including the initial word, and the target direction includes a left direction and a right direction; A second determination submodule is used to determine, for each predicted word, a prediction parameter of a predicted clause formed by the predicted word and a decoding clause, wherein the decoding clause is a sentence formed based on a decoded target element; A third determination submodule, configured to determine a candidate clause according to the prediction parameters of the prediction clause; The fourth determination submodule is used to determine the target direction corresponding to the predicted word in the candidate clause as the predicted direction in the target element, and add the target element to the word sequence corresponding to the candidate clause; and use the element corresponding to the predicted word corresponding to the candidate clause as a new target element, and re-execute the decoding submodule to decode the feature vector from the target direction with the predicted word in the target element as the starting point to obtain the predicted word corresponding to the target direction, until the left terminator and the right terminator are decoded.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Translation method and device, computer equipment and storage medium

    CN110263348A

  • Message generation method, device and equipment

    CN111507726A

  • Non-autoregressive Mongolian-Chinese machine translation method based on round-robin decoding and vocabulary attention

    CN112417901A

  • Ancient poem generation method and apparatus based on artificial intelligence, and device and storage medium

    WO2021051516A1