A text generation method, device, computer equipment and storage medium

By predicting label status and enhancing word vector processing, combined with the attention results of the keyword memory, the problem of low quality of keyword-to-text generation in the existing technology is solved, and the automatic generation of high-quality text is realized.

CN113297828BActive Publication Date: 2024-09-24阿里巴巴(上海)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010710329.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-22
Publication Date
2024-09-24
Estimated Expiration
2040-07-22

AI Technical Summary

Technical Problem

When the input content is keywords, the quality of the text generated by existing text generation technology needs to be improved, and it is difficult to automatically generate high-quality text.

Method used

By obtaining word vectors and tags, predict the tag status and enhance word vector processing, combined with the attention results of the keyword memory, predict the next word to improve the matching and quality of the generated text.

Benefits of technology

It achieves a high degree of matching between the generated text and the meaning of keywords and tags describing the object, improving the accuracy and quality of text generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113297828B
    Figure CN113297828B
Patent Text Reader

Abstract

The embodiment of the present application provides a text generation method, device, computer equipment and storage medium, wherein the method includes: obtaining the word vector of the tth word generated in the tth step, and the label of the tth word; predicting the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step; enhancing the word vector of the tth word according to the label state of the t+1th step; predicting the word state of the t+1th step according to the result after the enhanced processing; based on the label state of the tth step, obtaining the attention result of the data in the keyword memory in the t+1th step, the data stored in the keyword memory includes: keyword variables and label variables, wherein there is a corresponding relationship between the label variables and the keyword variables; predicting the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step. The embodiment of the present application can improve the quality of the generated text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of natural language processing technology, and specifically to a text generation method, apparatus, computer equipment and storage medium. Background Art

[0002] In the field of natural language processing, text generation technology is a technology that uses computer equipment to automatically write text. It is widely used in many scenarios such as news writing and promotional copy editing.

[0003] Text generation technology can automatically generate text based on input content. For the generated text, the degree of match between the content described in the text and the input content is an important indicator for measuring the quality (such as accuracy) of the generated text. However, when the input content is keywords, the quality of the text generated by the existing text generation technology needs to be further improved. Therefore, how to improve the text generation technology and automatically generate high-quality text has become a problem that technical personnel in this field need to solve urgently. Summary of the invention

[0004] In view of this, embodiments of the present application provide a text generation method, apparatus, computer device and storage medium to automatically generate high-quality text.

[0005] To achieve the above objectives, the present application provides the following technical solutions:

[0006] A text generation method, comprising:

[0007] Get the word vector of the t-th word generated in the t-th step, and the label of the t-th word;

[0008] Predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step;

[0009] Strengthening the word vector of the t-th word according to the label state of the t+1-th step;

[0010] According to the results of the enhanced processing, predict the word state of step t+1;

[0011] Based on the label state of the tth step, obtaining the attention result of the data in the keyword memory in the t+1th step; the data stored in the keyword memory includes: keyword variables of each keyword describing the object, and label variables of the label of each keyword, wherein there is a corresponding relationship between the label variable and the keyword variable;

[0012] According to the word state of the t+1th step and the attention result of the t+1th step, predict the t+1th word.

[0013] The present application also provides a text generation device, including:

[0014] An acquisition unit, used to acquire the word vector of the t-th word generated in the t-th step, and the label of the t-th word;

[0015] A label state prediction unit, configured to predict a label state at the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state at the tth step;

[0016] A strengthening processing unit, used for strengthening the word vector of the t-th word according to the label state of the t+1-th step;

[0017] A word state prediction unit, used to predict the word state of step t+1 according to the result after the enhancement processing;

[0018] An attention result acquisition unit, configured to acquire the attention result of the data in the keyword memory at the t+1th step based on the label state at the tth step; the data stored in the keyword memory includes: keyword variables of each keyword describing the object, and label variables of the label of each keyword, wherein the label variable and the keyword variable have a corresponding relationship;

[0019] A word prediction unit is used to predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0020] The present application also provides a text generation device, including:

[0021] A keyword encoder is used to obtain an object description data set, wherein the object description data set includes multiple keywords describing the object and labels of each keyword; determine a keyword variable of each keyword and a label variable of each label; and store each label variable and the corresponding keyword variable in a keyword memory;

[0022] A keyword memory, used to store keyword variables of each keyword and label variables of each keyword label, wherein there is a corresponding relationship between the label variable and the keyword variable;

[0023] A text generator is used to obtain the word vector of the tth word generated in the tth step and the label of the tth word; predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step; enhance the word vector of the tth word according to the label state of the t+1th step; predict the word state of the t+1th step according to the result of the enhanced processing; based on the label state of the tth step, obtain the attention result of the data in the keyword memory in the t+1th step; predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0024] An embodiment of the present application also provides a computer device, comprising: at least one memory and at least one processor; the memory stores one or more computer executable instructions, and the processor calls the one or more computer executable instructions to execute the text generation method as described above.

[0025] An embodiment of the present application also provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the text generation method as described above.

[0026] The text generation method provided in the embodiment of the present application can predict the label state of the t+1th step, thereby using the label state of the t+1th step to strengthen the word vector of the generated tth word, and then predict the word state of the t+1th step; at the same time, based on the label state of the tth step, the embodiment of the present application can determine the attention result of the data in the keyword memory at the t+1th step, thereby extracting information related to the t+1th word from the keyword memory, and then predicting the t+1th word through the word state of the t+1th step and the attention result. It can be seen that the embodiment of the present application can predict the t+1th word on the basis of determining the word state of the t+1th step based on the label, and determining the information related to the t+1th word in the keyword memory based on the label, so that the meaning expressed by the finally generated text can have a high degree of match with the meaning expressed by the keyword describing the object and the meaning of the label, thereby improving the quality of the generated text and realizing the automatic generation of high-quality text. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0028] Figure 1 A logical structure diagram of a text generation device provided in an embodiment of the present application;

[0029] Figure 2 Another logical structure diagram of the text generation device provided in the embodiment of the present application;

[0030] Figure 3 A flowchart for determining keyword variables provided in an embodiment of the present application;

[0031] Figure 4 A flowchart for determining keyword variables based on vector variables, key variables and value variables in latent space provided in an embodiment of the present application;

[0032] Figure 5 Another logical structure diagram of the text generation device provided in the embodiment of the present application;

[0033] Figure 6 A flowchart of a text generation method provided in an embodiment of the present application;

[0034] Figure 7 A logical structure diagram of a text generator provided in an embodiment of the present application;

[0035] Figure 8 A flowchart for predicting the word state at step t+1 provided in an embodiment of the present application;

[0036] Fig. 9 Another logical structure diagram of the text generation device provided in the embodiment of the present application;

[0037] Fig.10 A flowchart for predicting the t+1th word provided in an embodiment of the present application;

[0038] Fig.11 A flowchart for obtaining attention results provided in an embodiment of the present application;

[0039] Fig.12 A flowchart for determining the label of the t+1th word provided in an embodiment of the present application;

[0040] Fig.13 A functional module block diagram of a text generation device provided in an embodiment of the present application;

[0041] Fig.14 Another functional module block diagram of the text generation device provided in the embodiment of the present application;

[0042] Fig.15 A further functional module block diagram of the text generation device provided in an embodiment of the present application;

[0043] Fig.16 A block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] Discussing the case where the input content is text (Chinese characters or English and other texts), the usage scenarios of text generation technology can be mainly divided into: 1. Text-to-text generation scenario, that is, the input content is text and the output is also text. It is mainly used to generate summary text, sentence compression, text replication, sentence fusion and other fields; 2. Keyword-to-text generation scenario, that is, the input content is keywords (such as Chinese characters or English words and other keywords), and the output is text. It is mainly used for generating descriptive texts for objects such as products and creative scripts. For example, based on the keywords of objects such as products and creative scripts, texts describing objects such as products and creative scripts are generated.

[0045] In the text-to-text generation scenario, text generation technology mainly uses analysis tools to analyze important information in the input content, and then regenerates the text using the analyzed important information. For example, if the input content is input text, then meaningless words such as auxiliary words in the sentences of the input text can be removed to extract important information that expresses the meaning of the text from the input text, and then regenerate the text using the extracted important information.

[0046] For example, taking the input text "Xiao Ming is now addicted to games and doesn't love studying much", by analyzing the important information in the input text, we can get the important information: "Xiao Ming", "addicted to games", "not very interested in studying much"; these important information retain the meaning expressed by the input text to the greatest extent, so that the text can be regenerated using these important information.

[0047] However, in the keyword-to-text generation scenario, the input content is keywords, which are crucial for the description of objects such as products and creative scripts. The analysis tool cannot analyze the important or unimportant information. Therefore, in the keyword-to-text generation scenario, the above solution of generating text by analyzing the important information in the input content is not applicable.

[0048] Based on this, studying text generation solutions in the scenario of keyword-to-text generation to automatically generate high-quality text has become a hot topic of research for technical personnel in this field.

[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0050] In an optional implementation, the embodiment of the present application can use a text generation device (such as a text generation model) to realize the generation of keywords to text, such as Figure 1 As shown, the logical structure of the text generation device provided in the embodiment of the present application may include: a keyword encoder 10, a keyword memory 20, and a text generator 30.

[0051] In the embodiment of the present application, the input content of the text generation device may be an object description data set, which may include keywords describing the object (such as Chinese characters and / or English words describing the object) and labels of the keywords; taking the object as a commodity as an example, the object description data set may include keywords describing the commodity and labels of the keywords;

[0052] Optionally, the label of a keyword can represent the object attribute expressed by the keyword; taking a commodity as an example, the label can be the entity label of the commodity expressed by the keyword, such as the brand name, brand type, color, etc. of the commodity; of course, the label being an entity label is only an example, and the label corresponding to the keyword can also be the style label of the keyword (used in the field of text style conversion), the personalized label of the keyword (used in the field of personalized text generation), etc. These forms of labels can all represent the object attribute expressed by the keyword.

[0053] In an embodiment of the present application, the keyword encoder 10 can be used to encode the keywords and labels in the object description data set into a high-dimensional space respectively, so as to obtain keyword variables of each keyword and label variables of each keyword label; furthermore, the keyword encoder 10 can store each keyword variable and each label variable into a keyword memory.

[0054] As an optional implementation, since the data (keywords and labels) in the object description dataset generally have no order information, the keyword encoder 10 may consider using an encoder of the Transformer mechanism to encode the keywords and labels in the object description dataset separately, so that in the encoding process, the relationship between keywords in the object description dataset and the relationship between labels are considered; it should be noted that Transformer is an encoder based on the attention mechanism of deep learning, which can mine the relationship between data. The attention mechanism is an attention mechanism, which is to learn the importance of each element in the sequence and the attention input, and then connect the elements according to the importance, so as to obtain the Attention result.

[0055] In a more specific optional implementation, the keyword encoder 10 can be implemented based on SAM (self attention module), which is a mechanism for self-attention within the text, and the sequence it pays attention to is the sequence where the attention input is located. Figure 1 and Figure 2 As shown, the keyword encoder 10 may include: a keyword SAM 11 and a tag SAM 12; wherein the keyword SAM (i.e., the keyword self-attention module) may encode each keyword in the object description data set respectively, thereby obtaining a keyword variable of each keyword; the tag SAM (i.e., the tag self-attention module) may encode each tag in the object description data set respectively, thereby obtaining a tag variable of each tag.

[0056] Optional, Figure 3 An optional process for determining keyword variables is shown, which can be executed by the keyword SAM in the keyword encoder. By executing the process for each keyword in the object description data set, the keyword variables of each keyword in the object description data set can be obtained; optionally, taking the determination of keyword variables for the i-th keyword in the object description data set as an example, refer to Figure 3 , the process may include:

[0057] S10. Determine the vector variable, key variable and value variable of the i-th keyword in the object description data set in the latent space.

[0058] The vector (query) variable, key variable and value variable corresponding to a keyword in the object description dataset in the latent space are three variables generated for a keyword in the self-attention mechanism, which can be used for internal self-attention processing of subsequent keywords; since the keywords in the object description dataset generally have no sequential information, it is different from the traditional RNN (Recurrent Neural Network) method. In the embodiment of the present application, for the i-th keyword in the object description dataset, three linear layers (such as fully connected layers) can be used to encode the word embedding vector of the i-th keyword into three latent spaces, one linear layer corresponds to one latent space, thereby obtaining the vector variable, key variable and value variable of the i-th keyword in the latent space.

[0059] In an optional implementation, the embodiment of the present application can use the word embedding matrix to encode the one-hot encoding of the ith keyword into a set high-dimensional space to obtain the word embedding vector of the ith keyword. The word embedding vector of the ith keyword can be obtained using x iFurthermore, the present embodiment can use three fully connected layers to convert x i Encode into three latent spaces and get the vector variable F of the i-th keyword in the latent space q (x i ), key variable F k (x i ), value variable F v (x i ); In an optional specific implementation, the embodiment of the present application may use a vector connection layer to connect x i Encode into the vector latent space, so as to obtain the vector variable F of the i-th keyword in the vector latent space q (x i ), use the key connection layer to convert x i Encode into the key implicit space, so as to obtain the key variable F of the i-th keyword in the key implicit space k (x i ), use the value connection layer to connect x i Encode into the value hidden space, so as to obtain the value variable F of the i-th keyword in the value hidden space v (x i ).

[0060] It should be noted that one-hot encoding is also called one-bit effective encoding, which mainly uses a multi-bit state register to encode multiple states. Each state has an independent register bit, and only one bit is valid at any time.

[0061] Step S11, determining the keyword variable of the ith keyword according to the vector variable, key variable and value variable of the ith keyword in the latent space.

[0062] Based on step S10, each keyword in the object description data set is processed to obtain the vector variable, key variable and value variable of each keyword in the object description data set in the latent space. When determining the keyword variable for the i-th keyword, the vector variable F of the i-th keyword in the latent space q (x i ) can be considered as a variable in the self-attention mechanism, in which the i-th keyword and the keywords in the object description dataset perform internal self-attention processing, thereby using the vector variable F of the i-th keyword in the latent space q (x i ), the embodiment of the present application can be F q (x i ) interacts with the key variables and value variables of each keyword in the latent space in the object description dataset to obtain the keyword variable of the i-th keyword.

[0063] Assume that x. represents the word embedding vector of each keyword in the object description dataset, such as x iis the word embedding vector of the i-th keyword, x j is the word embedding vector of the jth keyword. The . in x. represents the possible subscripts of the keywords in the object description dataset. The keyword variable of the ith keyword can be expressed as:

[0064] SAM(F q (x i ), F k (x.), F v (x.));

[0065] Among them, F q (x i ) represents the vector variable of the i-th keyword in the latent space, F k (x.) represents the key variable of each keyword in the latent space in the object description dataset, F v (x.) represents the value variables of each keyword in the object description dataset in the latent space, that is, the vector variable of the i-th keyword in the latent space, which will perform a SAM calculation with the key variables and value variables of all keywords in the object description dataset (including the i-th keyword itself) in the latent space.

[0066] It should be noted that the i-th keyword refers to any keyword in the object description data set, so that the keyword variables of each keyword can be obtained by performing the above processing on any keyword in the object description data set.

[0067] In an optional implementation, Figure 4 An optional implementation process of step S11 is shown, such as Figure 4 As shown, the process may include:

[0068] Step S20: interact the vector variable of the ith keyword with the key variables of each keyword in the object description data set to obtain the weight of the ith keyword and each keyword.

[0069] Optionally, the embodiment of the present application may combine the vector variable of the ith keyword with the key variable of each keyword in the object description data set to obtain the combination result of the vector variable of the ith keyword with the key variable of each keyword; assuming that the vector variable q of the ith keyword i =F q (x i ), the key variable is k i =F k (x i ), the value variable is v i =F v (x i ), then the combination of the vector variable of the i-th keyword and the key variable of the j-th keyword in the object description dataset can be expressed as exp(qi k j ), where exp() represents an exponential function with the natural constant e as the base; it can be understood that, for each keyword in the object description data set, the above-mentioned method is used to process each keyword, and the combination result of the vector variable of the i-th keyword and the key variable of each keyword can be determined;

[0070] Therefore, the embodiment of the present application can accumulate the vector variable of the i-th keyword and the combination result of the key variable of each keyword to obtain the accumulated result; assuming that the number of keywords in the object description data set is Tx, the accumulated result can be expressed as:

[0071]

[0072] Furthermore, for any keyword in the object description data set, the weight of the i-th keyword and the keyword can be obtained by combining the vector variable of the i-th keyword and the key variable of the keyword and dividing it by the accumulated result. Taking the weight of the i-th keyword and the j-th keyword as an example, α i,j represents the weight of the i-th keyword for the j-th keyword, then α i,j It can be expressed as:

[0073]

[0074] Step S21: Perform attention processing on the value variables of each keyword in the latent space according to the weight of the ith keyword and each keyword, so as to obtain the attention results of the ith keyword and each keyword; accumulate the attention results of the ith keyword and each keyword to obtain the attention accumulation result.

[0075] It should be noted that the weight of the ith keyword and the jth keyword can be considered as the similarity between the ith keyword and the jth keyword, that is, the degree of need of the ith keyword for the value of the jth keyword. The similarity between the ith keyword and the jth keyword can be between 0 and 1, which is equivalent to determining the keyword variable of the ith keyword in the process of determining the keyword variable of the ith keyword. The embodiment of the present application can use the weight of the ith keyword and the jth keyword, combined with a certain proportion of information in the jth keyword, to determine the keyword variable of the ith keyword. Based on this, the embodiment of the present application can use the weight of the ith keyword and each keyword to extract a certain proportion of information of each keyword from the value variable of each keyword in the latent space, so as to determine the keyword variable of the ith keyword.

[0076] In a specific optional implementation, for each keyword in the object description data set, the weight of the ith keyword and the keyword can be combined with the value variable of the keyword in the latent space, so as to obtain the attention result of the ith keyword and each keyword respectively; wherein the attention result of the ith keyword and a keyword can be considered as a certain proportion of information extracted from the value variable of the keyword in the latent space and used to determine the keyword variable of the ith keyword;

[0077] Furthermore, the embodiment of the present application can accumulate the attention results of the ith keyword and each keyword to obtain the attention accumulation result, so as to connect a certain proportion of information extracted from the value variable of each keyword in the latent space; let v j is the value variable of the jth keyword, then the attention accumulation result can be expressed as:

[0078]

[0079] Step S22: Connect the attention accumulation result with the word embedding vector of the i-th keyword to obtain the keyword variable of the i-th keyword.

[0080] Optionally, the keyword variable of the i-th keyword can be expressed as:

[0081] e(x i )+β i .

[0082] Similarly, when determining the label variables of each label in the object description data set, the embodiment of the present application can determine the vector variables, key variables and value variables of the label of the i-th keyword in the object description data set in the latent space; and then determine the label variables of the label of the i-th keyword based on the vector variables, key variables and value variables of the i-th keyword label in the latent space; for example, the vector variables of the i-th keyword label in the latent space will be combined with the key variables and value variables of all labels in the object description data set (including the i-th keyword label itself) in the latent space to perform a SAM calculation.

[0083] The keyword variables and label variables determined by the keyword encoder may be stored in the keyword memory 20; in an optional implementation, the label variables stored in the keyword memory may have a corresponding relationship with the keyword variables. Optionally, the data stored in the keyword memory 20 may be divided into two parts:

[0084] key: a label variable, which can be considered as the SAM result of the keyword label. Taking the object as a product, the key in the keyword memory can be a high-dimensional label variable such as "brand name" or "category".

[0085] value: keyword variable, which can be considered as the SAM result of the keyword's word embedding vector. Taking commodities as an example, such as keywords such as "brand A", "brand B", and "sports shoes", after SAM processing of the keyword's word embedding vector, the keyword variables of "brand A" and "brand B" will be placed in the value of the key "brand name", while the keyword variable of "sports shoes" will be placed in the value of the key "category".

[0086] The above describes the optional workflow of the keyword encoder, and the following describes the optional workflow of the text generator.

[0087] The text generator 30 is the main component for generating text in the embodiment of the present application. The text generator provided in the embodiment of the present application can generate words in the text based on label guidance, and because most of the keywords in the object description data set have meaningful labels, in order to ensure the quality (such as accuracy) of the generated text, the embodiment of the present application combines attention to the data stored in the keyword memory during the text generation process, so as to maximize the matching degree between the meaning expressed by the generated text and the meaning expressed by the keywords describing the object and the label meaning on the basis of label guidance, so that the generated text has higher quality.

[0088] In an optional implementation, the text generator 30 can be implemented based on LSTM (Long Short-Term Memory Networks). In the case where the object description dataset carries labels, the text generator 30 can be implemented based on a label-guided long short-term memory network; optionally, Figure 5 As shown, the text generator 30 may include: a memory network 301 and an output layer 33; wherein the memory network 301 may include a plurality of LSTM network structures for memorizing the word state and label state of each step in the text generation process, and the text generator may generate words step by step, and the memory network 301 memorizes the word state and label state of each step;

[0089] Further, if Figure 5 As shown, the memory network 301 may include: a word memory network 31 and a label memory network 32; the word memory network 31 is a memory network for memorizing word states, and the word memory network 31 may include one or more LSTM network structures; at the same time, based on the label-guided word generation, a label memory network for memorizing label states is also added to the memory network 301 (the label memory network may also be in the form of LSTM).

[0090] It can be understood that LSTM is a type of recurrent neural network (RNN). In the embodiment of the present application, the text generator generates words step by step, and the next word is generated based on the previous word. For example, the text generator has generated the tth word in the tth step. Figure 6 The optional process of the text generation method provided in the embodiment of the present application is shown. It should be noted that the first word generated by the text generator in the first step can be obtained based on the set initial state data. Figure 6 The process shown can be performed at least when the first word of the first step is generated, such as Figure 6 As shown, the process may include:

[0091] Step S30, obtaining the word vector of the t-th word generated in the t-th step and the label of the t-th word.

[0092] When generating the tth word, the embodiment of the present application can map the tth word to a high-dimensional space to obtain the word vector of the tth word. Correspondingly, the embodiment of the present application can also obtain the label of the tth word.

[0093] Step S31: predict the label state of the t+1th step based on the word vector of the tth word, the label of the tth word, and the label state of the tth step.

[0094] It should be noted that when the text generator generates a word at each step, the word memory network has a corresponding word state, and the label memory network has a corresponding label state; when generating the t-th word in the t-th step, the word memory network has the word state of the t-th step, which corresponds to the generated t-th word, and the label memory network has the label state of the t-th step, which corresponds to the label of the t-th word.

[0095] When the t-th word has been generated, in order to predict the t+1-th word, the embodiment of the present application needs to determine the word state of the word memory network at the t+1-th step, so as to predict the corresponding t+1-th word based on the word state of the word memory network at the t+1-th step; and the embodiment of the present application, considering the idea of ​​generating words based on labels, can predict the label state of the label memory network at the t+1-th step, so as to determine the word state of the word memory network at the t+1-th step through the label state of the label memory network, thereby improving the prediction accuracy of the word state at the t+1-th step, and then improving the accuracy of the generated t+1-th word.

[0096] In an embodiment of the present application, the embodiment of the present application can predict the label state of the label memory network at the t+1th step based on the word vector of the tth word, the label of the tth word, and the label state of the tth step of the label memory network.

[0097] Step S32: Strengthen the word vector of the tth word according to the label state of the t+1th step.

[0098] Based on the predicted label state of the t+1th step, the embodiment of the present application can strengthen the word vector of the generated tth word. Optionally, the embodiment of the present application can add the label state of the t+1th step to the word vector of the tth word, thereby strengthening the word vector of the tth word.

[0099] Step S33: predict the word state of step t+1 according to the result after the enhancement processing.

[0100] Based on the enhanced processing of the word vector of the t-th word, the embodiment of the present application can use the result after the enhanced processing to determine the word state of the t+1-th step of the word memory network, wherein the word state of the t+1-th step of the word memory network corresponds to the t+1-th word to be predicted.

[0101] Step S34: Determine the attention result of the data in the keyword memory at the t+1th step according to the tag state at the tth step.

[0102] It can be understood that the keyword memory stores keyword variables of each keyword describing the object and label variables of each keyword label, and there is a corresponding relationship between the label variables and the keyword variables. In order to use the information related to the t+1th word in the keyword memory during the generation process of the t+1th word, so that the meaning of the text expression finally generated has a high degree of match with the meaning of the keyword expression and the label meaning of the describing object, the embodiment of the present application can pay attention to the data in the keyword memory according to the label state of the tth step of the label memory network, thereby extracting information related to the t+1th word (such as keyword variables and label variables related to the t+1th word, etc.) from the keyword memory, and the extracted information is the attention result of the data in the keyword memory at the t+1th step.

[0103] Step S35: predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0104] The embodiment of the present application can predict the t+1th word based on determining the word state of the t+1th step of the word memory network based on label guidance, and determining the information related to the t+1th word in the keyword memory based on label guidance, so that the predicted t+1th word has higher accuracy.

[0105] Optionally, steps S30 to S33 may be implemented by a memory network in the text generator; steps S34 and S35 may be implemented by an output layer in the text generator.

[0106] The text generation method provided in the embodiment of the present application can predict the label state of the t+1th step, thereby using the label state of the t+1th step to strengthen the word vector of the generated tth word, and then predict the word state of the t+1th step; at the same time, based on the label state of the tth step, the embodiment of the present application can determine the attention result of the data in the keyword memory at the t+1th step, thereby extracting information related to the t+1th word from the keyword memory, and then predicting the t+1th word through the word state of the t+1th step and the attention result. It can be seen that the embodiment of the present application can predict the t+1th word on the basis of determining the word state of the t+1th step based on the label, and determining the information related to the t+1th word in the keyword memory based on the label, so that the meaning expressed by the finally generated text can have a high degree of match with the meaning expressed by the keyword describing the object and the meaning of the label, thereby improving the quality of the generated text and realizing the automatic generation of high-quality text.

[0107] As an optional implementation, Figure 7 Another optional structure of the text generator is shown, combining Figure 5 and Figure 7 As shown, the word memory network 31 may include a zeroth word memory network 311 and a first word memory network 312; it should be noted that the zeroth word memory network 311, the label memory network 32 and the first word memory network 312 may all be in the form of LSTM, and it can be seen that the text generator may be composed of at least three LSTMs, wherein the zeroth word memory network 311 and the first word memory network 312 constitute the word memory network 31 in the text generator, which is used to memorize word states, and the label memory network 32 memorizes label states; specifically, the word state of the word memory network 31 is obtained by integrating the zeroth word state of the zeroth word memory network 311 and the first word state of the first word memory network 312. For ease of explanation, the word state of the zeroth word memory network 311 may be referred to as the zeroth word state, and the word state of the first word memory network 312 may be referred to as the first word state.

[0108] In an optional implementation, Figure 8 shows an optional process for predicting the word state of the word memory network at step t+1, combined with Figure 7 and Figure 8 As shown, the process may include:

[0109] Step S40, determine the zeroth word state at the t+1th step based on the word vector of the tth word and the word state at the tth step.

[0110] Combination Figure 7 As shown, it can be understood that the text generator generates the tth word y in the tth step t , in the t+1th step, generate the t+1th word y t+1 , then the word state of the text generator at the tth step (that is, the word state of the word memory network at the tth step) can be: the integration result of the zeroth word state of the tth step of the zeroth word memory network and the first word state of the tth step of the first word memory network.

[0111] In an optional implementation, combined with Figure 7 As shown, y t Indicates the tth word currently generated by the text generator, e(y t ) is y t The word vector converted by mapping to high-dimensional space; the zeroth word memory network is e(y t ) as input, As output, represents the zeroth word state of the t+1th step of the zeroth word memory network; let represents the word state of the t-th step of the word memory network, then the zeroth word memory network can be based on e(y t )and Sure The zeroth word memory network is in LSTM form, and the zeroth word memory network is represented as Word-LSTM0, then The determination process can be expressed as:

[0112]

[0113] Step S41, determining the label state of the t+1th step according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step.

[0114] In an optional implementation, combining Figure 7 As shown, the label memory network is and m t The combined result of is taken as input, As output; where m t represents the label of the tth word, Represents the label state of the label memory network at step t+1, such as Figure 7 As shown, in an optional implementation, and m t can be added by an adder to obtain and m t The combined result, accordingly, and m t The combined result can be expressed as

[0115] set up represents the label state of the tth step of the label memory network, then the label memory network can be based on and m t The combined results and Sure The label memory network is in the form of LSTM, and the label memory network is represented as Entity-Label-LSTM, then The determination process can be expressed as:

[0116]

[0117] It should be noted that the above process is to determine the label state of the label memory network at step t+1 An optional method, in order to improve the prediction accuracy of the label state of the t+1th step, the embodiment of the present application provides another implementation method for determining the label state of the t+1th step; in this implementation method, the embodiment of the present application can be based on and m t The combined result and the label state of step t Determine the initial label state of step t+1, so as to combine the initial label state of step t+1 with the variable calculated by the attention mechanism Combined to determine the label state of step t+1;

[0118] In this implementation, It can be considered as the label attention result of the label state of step t in the label variable stored in the keyword memory; the initial label state of step t+1 can be used Indicates, optional, It can be expressed as Furthermore, the label state at step t+1 is It can be expressed as:

[0119] Among them, FC() can represent full connection processing.

[0120] Optionally, steps S40 to S41 may be considered as Figure 6 An optional implementation of step S31 is shown.

[0121] Step S42: Strengthen the word vector of the tth word according to the label state of the t+1th step.

[0122] Combination Figure 7 As shown, the label state at step t+1 The word vector e(y t ) is added, so e(y t) is enhanced, and accordingly, the result after the enhanced processing can be expressed as

[0123] Step S43: Determine the first word state of step t+1 according to the result after the enhancement processing and the word state of step t.

[0124] Combination Figure 7 As shown, the first word memory network is based on the label state of the t+1th step and the word vector e(y t ) as input, and then the first word memory network is based on the combination result and the word state of the tth step of the word memory network. Output in, represents the first word state of the first word memory network at step t+1. If the first word memory network is in LSTM form and the first word memory network is represented as Word-LSTM1, then The determination process can be expressed as:

[0125]

[0126] Step S44, combining the zeroth word state of the t+1th step and the first word state of the t+1th step to obtain the word state of the t+1th step.

[0127] In order to improve the accuracy of the predicted word state of the t+1th step of the word memory network, the embodiment of the present application can be designed to change the zeroth word state of the t+1th step of the zeroth word memory network to and the first word state of the first word memory network at step t+1 Combined with, we get the word state of the word memory network at step t+1

[0128] In an optional implementation, the embodiment of the present application may be based on and The full connection result of , determines the standard deviation; thus based on the standard deviation, and Combined, we get the word state of step t+1 Optional, The determination process can be expressed as:

[0129] Among them, σ() represents standard deviation processing;

[0130]

[0131] It can be seen that the word state of the t+1th step of the above-mentioned word memory network is determined In the process of , the zeroth word memory network can first predict the next zeroth word state (i.e. ); thus, the label memory network can predict the next label state (i.e. ); then use the label state of the next step to strengthen the word vector of the tth word, and then the first word memory network predicts the first word state of the next step based on the strengthening result (i.e. ); Then, using the prediction result of the first word memory network as the posterior information, combined with the prediction result of the zeroth word memory network, the next word state of the word memory network as a whole can be determined (i.e. ), so that the predicted With high accuracy, subsequent use Determining the next word can effectively improve the accuracy of the generated text.

[0132] After determining the word state of the word memory network at step t+1, the output layer can predict the t+1th word based on the attention result of the data in the keyword memory at step t+1 and the word state of step t+1. In an optional implementation, Fig. 9 Another optional structure of the text generator is shown, such as Fig. 9 As shown, the output layer can obtain the word state of the t+1th step output by the memory network At the same time, based on the data in the keyword memory, the attention result o at step t+1 t+1 ', determine the t+1th word y t+1 ; In a more specific implementation, such as Fig. 9 As shown, t+1 'Can be combined with the word context vector of step t+1 Combined to obtain the target attention result o t+1 , so that the output layer is based on o t+1 and Predict the t+1th word y t+1 ; optional, Fig.10 An optional process for predicting the t+1th word is shown, such as Fig.10 As shown, the process may include:

[0133] Step S50: determine the word context vector of step t+1.

[0134] The word context vector of step t+1 can be expressed as The embodiment of the present application can be based on the word state of the t+1th step of the word memory network Attention is performed on each keyword variable in the keyword memory to obtain the word context vector of step t+1 The attention mechanism is to learn the importance of each element in the sequence and the attention input, and then connect the elements according to the importance. In the embodiment of the present application, the embodiment of the present application can be used Determine the importance (i.e. weight, also called similarity) of the keyword variables in the keyword memory, and then connect each keyword variable based on the importance to obtain the word context vector of step t+1

[0135] Step S51: Combine the attention result of the keyword memory in step t+1 with the word context vector in step t+1 to determine the target attention result.

[0136] Suppose the attention result of the data in the keyword memory at step t+1 is o t+1 ', then the embodiment of the present application can be o t+1 'and Add together to get the target attention result, which can be used to obtain the target attention result. t+1 express.

[0137] Step S52: predict the t+1th word according to the target attention result and the word state of the t+1th step of the word memory network.

[0138] Optional, Fig.11 Figure 1 shows an optional process for obtaining the attention result of the data in the keyword memory at step t+1 based on the tag state at step t, as shown in Fig.11 As shown, the process may include:

[0139] Step S60: interact the label state of the t-th step with each label variable in the keyword memory to obtain the label state of the t-th step and the weight of each label variable.

[0140] The weights of the label state at the tth step and each label variable in the keyword memory can represent the similarity between the label state at the tth step and each label variable, and can reflect the importance of each label variable.

[0141] Step S61: According to the label status of the t-th step and the weight of each label variable, attention processing is performed on the keyword variables corresponding to each label variable to obtain the attention results of the label status of the t-th step and the keyword variables corresponding to each label variable.

[0142] Based on the label status of the tth step and the weights of each label variable in the keyword memory, the embodiment of the present application can select and adopt information from the keyword variables corresponding to each label variable. The greater the weight, the greater the proportion of adopted information. Therefore, based on the label status of the tth step and the weights of each label variable, the embodiment of the present application can determine the extraction information of the keyword variables corresponding to each label variable, and obtain the label status of the tth step and the attention results of the keyword variables corresponding to each label variable.

[0143] Step S62: accumulate the label status of the tth step and the attention results of the keyword variables corresponding to each label variable, and determine the attention results of the data in the keyword memory at the t+1th step according to the accumulation results.

[0144] In the embodiment of the present application, the tag state of the tth step and the attention result of the keyword variable corresponding to each tag variable can be accumulated, so as to determine the attention result of the keyword memory at the t+1th step based on the accumulated result. t+1 '.

[0145] Optional, based on the target attention result o t+1 , and the word state of the word memory network at step t+1 The embodiment of the present application can predict the word distribution data of the t+1th word, thereby determining the t+1th word; optionally, the embodiment of the present application can determine the word distribution data of the t+1th word according to the target attention result and the word state of the t+1th step, and the word distribution data can represent the distribution probability of each word in a preset word list, so according to the word distribution data, the embodiment of the present application can determine the t+1th word, such as determining that the word with the largest distribution probability in the word list is the t+1th word;

[0146] Optionally, an optional implementation of determining the word distribution data of the t+1th word can be expressed as:

[0147]

[0148] Among them, w v Indicates the preset vocabulary, b v To set the parameters; it should be noted that the Softmax function is a normalization function that combines the preset vocabulary, t+1 and After normalization, the distribution probability of the t+1th word in the vocabulary can be determined. For example, if the vocabulary has 50,000 dimensions, then the variable has 50,000 dimensions. After being processed by the softmax function, these dimensions become numbers from 0 to 1, and the sum of the values ​​of the 50,000 dimensions is 1. The embodiment of the present application can determine that the word corresponding to the dimension with the largest value is the t+1th word, and the word corresponding to the dimension with the largest value is the word with the largest distribution probability. For example, assuming that the vocabulary is 3-dimensional, after softmax processing, the distribution probability will be obtained: [0.1, 0.1, 0.8], then the word corresponding to the probability of 0.8 is the generated t+1th word. Optionally, the vocabulary can be understood as a mathematical representation of a word. For example, the word "my" corresponds to a digital expression in the vocabulary, and the word "haha" corresponds to a digital expression in the vocabulary.

[0149] Optionally, further, the embodiment of the present application may also determine the label state of the t+1th step based on the memory network Determine the label m of the t+1th word t+1 ; This process can be implemented by the output layer, optionally, Fig.12 The optional process of determining the label of the t+1th word provided in the embodiment of the present application is shown, such as Fig.12 As shown, the process may include:

[0150] Step S70: Determine the label vector of step t+1.

[0151] Optionally, the embodiment of the present application may perform attention on the label variable stored in the keyword memory based on the label state of the t+1th step, thereby obtaining the label vector of the t+1th step. The label vector of the t+1th step can be expressed as The implementation process of step S70 may be similar to the implementation process of step S50.

[0152] Step S71, determining the label distribution data of the label of the t+1th word according to the initial label state of the t+1th step and the label vector of the t+1th step.

[0153] Optionally, based on the step S41 The embodiments of the present application can be based on and Determine the label distribution data of the label of the t+1th word; the label distribution data can be expressed as the distribution probability of the label of the t+1th word in the label vocabulary; its optional representation can be:

[0154] Among them, w e represents the preset tag vocabulary, b e To set parameters.

[0155] Step S72: Determine the label of the t+1th word according to the label distribution data.

[0156] The label distribution data may represent the distribution probability of labels. The embodiment of the present application may determine that the label with the largest distribution probability is the label of the t+1th word.

[0157] Based on the text generation method provided by the embodiment of the present application, after determining the generated text and the labels in the text, the embodiment of the present application can also update the text parameters of the text generation model based on the negative log-likelihood function to minimize the text generation error; optionally, the embodiment of the present application can determine the generated text and the labels in the text, thereby determining the negative log-likelihood function based on the generated text and the labels in the text, and optimizing the text generation parameters based on the negative log-likelihood function;

[0158] Optionally, when generating multiple texts, the embodiments of the present application can determine the errors between the words in each text and the real text, and the errors between the labels of each text and the labels of the real text, thereby accumulating the word errors and label errors of each text to obtain a negative log-likelihood function, and then use the gradient backpropagation method to minimize the negative log-likelihood function, optimize the text generation parameters of the text generation model, and improve the accuracy of the text generation model.

[0159] The text generation solution provided in the embodiment of the present application can predict the t+1th word based on determining the word state of the t+1th step of the word memory network based on label guidance, and determining the information related to the t+1th word in the keyword memory based on label guidance, so that the meaning expressed by the final generated text can have a high degree of match with the meaning expressed by the keywords describing the object and the label meaning, thereby improving the accuracy of the generated text.

[0160] An optional application scenario of the text generation method provided in the embodiment of the present application is to automatically generate text based on keywords and tags that describe the product; specifically, the keyword encoder can determine the keyword variables of the keyword and the label variables of the label based on the keywords and tags that describe the product, and store them in the keyword memory; then, the text generator can generate the next word based on the previous word that has been generated through label guidance and the attention result of the data in the keyword memory, so that the meaning expressed by the generated text can have a high degree of match with the meaning expressed by the keywords of the product and the meaning of the label, and can improve the accuracy of the generated text.

[0161] The functional modules of the text generation device provided in the embodiment of the present application are introduced below. The contents described below can be referenced to the contents of the text generation method described above.

[0162] In an optional implementation, Fig.13The functional module block diagram of the text generation device provided by the embodiment of the present application is shown as follows: Fig.13 As shown, the text generation device may include:

[0163] An acquisition unit 100 is used to acquire the word vector of the t-th word generated in the t-th step and the label of the t-th word;

[0164] A label state prediction unit 110, configured to predict a label state at the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state at the tth step;

[0165] A strengthening processing unit 120, configured to perform strengthening processing on the word vector of the t-th word according to the label state of the t+1-th step;

[0166] A word state prediction unit 130, used to predict the word state of the t+1th step according to the result after the enhancement processing;

[0167] An attention result acquisition unit 140 is used to acquire the attention result of the data in the keyword memory at the t+1 step based on the label state of the t step; the data stored in the keyword memory includes: keyword variables of each keyword describing the object, and label variables of the label of each keyword, wherein the label variable and the keyword variable have a corresponding relationship;

[0168] The word prediction unit 150 is used to predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0169] Optionally, the word memory network includes: a zeroth word memory network and a first word memory network; wherein the word state of the word memory network is obtained by integrating the zeroth word state of the zeroth word memory network and the first word state of the first word memory network.

[0170] Optionally, the label state prediction unit 110 is used to predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step, specifically including:

[0171] Determine the zeroth word state at step t+1 according to the word vector of the tth word and the word state at step t;

[0172] The label state of the t+1th step is determined according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step.

[0173] Optionally, the label state prediction unit 110 is used to determine the label state of the t+1th step according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step, specifically including:

[0174] Determine the combination result of the zeroth word state of the t+1th step and the label of the tth word;

[0175] Determine the initial label state of step t+1 according to the combination result and the label state of step t;

[0176] Determine the label attention result of the label state of the tth step in the label variable stored in the keyword memory, combine the initial label state of the t+1th step with the label attention result, and obtain the label state of the t+1th step.

[0177] Optionally, the word state prediction unit 130 is used to predict the word state of the t+1th step according to the result after the enhancement processing, specifically including:

[0178] Determine the first word state of step t+1 according to the result after the enhancement processing and the word state of step t;

[0179] The word state of the t+1th step is obtained by combining the zeroth word state of the t+1th step and the first word state of the t+1th step.

[0180] Optionally, the word state prediction unit 130 is configured to combine the zeroth word state of the t+1th step and the first word state of the t+1th step to obtain the word state of the t+1th step, specifically including:

[0181] Determine a standard deviation based on the full connection result of the zeroth word state of the t+1th step and the first word state of the t+1th step;

[0182] Based on the standard deviation, the zeroth word state of the t+1th step and the first word state of the t+1th step are combined to obtain the word state of the t+1th step.

[0183] Optionally, the enhancement processing unit 120 is used to enhance the word vector of the t-th word according to the label state of the t+1-th step, specifically including:

[0184] Add the label state of the t+1th step to the word vector of the tth word.

[0185] Optional, Fig.14 Another functional module block diagram of the text generation device provided by the embodiment of the present application is shown as follows: Fig.13 and Fig.14 As shown, the text generation device may also include:

[0186] The variable determination unit 160 is used to obtain an object description data set, which includes multiple keywords describing the object and a label for each keyword; determine the keyword variable of each keyword and the label variable of each label, and store each label variable and the keyword variable corresponding to each label variable in the keyword memory.

[0187] Optionally, the variable determination unit 160 is used to determine the keyword variable of each keyword, specifically including:

[0188] Determine the vector variable, key variable and value variable of the i-th keyword in the object description data set in the latent space; the i-th keyword is any keyword in the object description data set;

[0189] The keyword variable of the ith keyword is determined according to the vector variable, key variable and value variable of the ith keyword in the latent space.

[0190] Optionally, the variable determination unit 160 is used to determine the keyword variable of the i-th keyword according to the vector variable, key variable and value variable of the i-th keyword in the latent space, specifically including:

[0191] Interact the vector variable of the ith keyword with the key variables of each keyword in the object description dataset to obtain the weight of the ith keyword and each keyword;

[0192] According to the weights of the ith keyword and each keyword, the value variables of each keyword in the latent space are subjected to attention processing to obtain the attention results of the ith keyword and each keyword; the attention results of the ith keyword and each keyword are accumulated to obtain the attention accumulation result;

[0193] Connect the attention accumulation result with the word embedding vector of the i-th keyword to obtain the keyword variable of the i-th keyword.

[0194] Optionally, the variable determination unit 160 is used to determine the vector variable, key variable and value variable of the i-th keyword in the object description data set in the latent space, specifically including:

[0195] Determine the word embedding vector of the i-th keyword;

[0196] Use a vector connection layer to encode the word embedding vector into a vector latent space to obtain a vector variable of the i-th keyword in the vector latent space, and use a key connection layer to encode the word embedding vector into a key latent space to obtain a key variable of the i-th keyword in the key latent space, and use a value connection layer to encode the word embedding vector into a value latent space to obtain a value variable of the i-th keyword in the value latent space.

[0197] Optionally, the variable determination unit 160 is used to determine the tag variable of each tag, specifically including:

[0198] Determine the vector variable, key variable, and value variable of the label of the i-th keyword in the object description dataset in the latent space;

[0199] The label variable of the label of the i-th keyword is determined according to the vector variable, the key variable and the value variable of the label of the i-th keyword in the latent space.

[0200] Optionally, the attention result acquisition unit 140 is used to acquire the attention result of the data in the keyword memory at the t+1 step based on the tag state at the t step, specifically including:

[0201] The label state of the t-th step interacts with each label variable in the keyword memory to obtain the label state of the t-th step and the weight of each label variable;

[0202] According to the label state of the t-th step and the weight of each label variable, attention processing is performed on the keyword variables corresponding to each label variable to obtain the attention results of the label state of the t-th step and the keyword variables corresponding to each label variable;

[0203] Accumulate the label state of the tth step and the attention results of the keyword variables corresponding to each label variable, and determine the attention results of the data in the keyword memory in the t+1th step according to the accumulation results.

[0204] Optionally, the word prediction unit 150 is configured to predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step, specifically including:

[0205] Determine the word context vector of step t+1;

[0206] Combine the attention result of the step t+1 with the word context vector of the step t+1 to obtain the target attention result;

[0207] Determine the word distribution data of the t+1th word according to the target attention result and the word state of the t+1th step;

[0208] The t+1th word is determined according to the word distribution data.

[0209] Optionally, the word distribution data includes the distribution probability of each word in a preset word list; the word prediction unit 150 is used to determine the t+1th word according to the word distribution data, specifically including:

[0210] It is determined that the word with the largest distribution probability in the word list is the t+1th word.

[0211] Optional, Fig.15 Another functional module block diagram of the text generation device provided in the embodiment of the present application is shown. Fig.14 and Fig.15 As shown, the text generation device may also include:

[0212] The label determination unit 170 is used to determine the label vector of the t+1th step; determine the label distribution data of the label of the t+1th word according to the initial label state of the t+1th step and the label vector of the t+1th step; determine the label of the t+1th word according to the label distribution data;

[0213] The optimization unit 180 is used to determine the generated text and the labels in the text; determine the negative log-likelihood function according to the generated text and the labels in the text; and optimize the text generation parameters according to the negative log-likelihood function.

[0214] The text generation device provided in the embodiment of the present application can ensure that the meaning expressed by the finally generated text has a high degree of match with the meaning expressed by the keywords describing the object and the meaning of the label, thereby improving the quality of the generated text.

[0215] The logical structure of the text generation device (such as the text generation model) provided in the embodiment of the present application can be combined with Figure 1 With reference to the accompanying drawings, the invention comprises: a keyword encoder, a keyword memory, and a text generator;

[0216] The keyword encoder is used to obtain an object description data set, wherein the object description data set includes multiple keywords describing the object and labels of each keyword; determine a keyword variable of each keyword and a label variable of each label, and store each label variable and a keyword variable corresponding to each label variable in the keyword memory;

[0217] The keyword memory is used to store keyword variables of each keyword and label variables of each keyword label, wherein there is a corresponding relationship between the label variable and the keyword variable;

[0218] A text generator is used to obtain the word vector of the tth word generated in the tth step and the label of the tth word; predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step; enhance the word vector of the tth word according to the label state of the t+1th step; predict the word state of the t+1th step according to the result of the enhanced processing; based on the label state of the tth step, obtain the attention result of the data in the keyword memory in the t+1th step; predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0219] Optionally, further, the text generator may include: a word memory network, a label memory network and an output layer; the word memory network includes: a zeroth word memory network and a first word memory network; wherein the word state of the word memory network is obtained by integrating the zeroth word state of the zeroth word memory network and the first word state of the first word memory network.

[0220] Optionally, the zeroth word memory network is used to determine the zeroth word state of the t+1th step of the zeroth word memory network according to the word vector of the tth word and the word state of the tth step of the word memory network;

[0221] A label memory network, used to determine the label state of the label memory network at the t+1th step according to the zeroth word state at the t+1th step, the label of the tth word, and the label state of the label memory network at the tth step;

[0222] A first word memory network is used to obtain the result of strengthening the word vector of the t-th word by the label state of the t+1-th step, determine the first word state of the t+1-th step of the first word memory network according to the result of the strengthening process and the word state of the t-th step; and obtain the word state of the t+1-th step of the word memory network by combining the zeroth word state of the t+1-th step and the first word state of the t+1-th step;

[0223] The output layer is used to obtain the attention result of the data in the keyword memory at the t+1th step based on the label state of the tth step, and predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

[0224] Optionally, the keyword encoder may include: a keyword SAM and a tag SAM;

[0225] Among them, the keyword SAM is used to determine the keyword variable of each keyword in the object description data set;

[0226] Label SAM is a label variable used to determine the label of each keyword in the object description dataset.

[0227] For further information on the functions and implementation of the above components, please refer to the method content section above, which will not be repeated here.

[0228] The embodiment of the present application also provides a computer device, which can be loaded with the text generation device provided in the embodiment of the present application to generate text based on the object description data set; the computer device can be a server on the network side, or it can be a terminal device on the user side; optionally, the optional structure of the computer device can be as follows Fig.16 As shown, it includes: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;

[0229] Optionally, the communication interface 2 may be an interface of a communication module for performing network communication;

[0230] Optionally, processor 1 may be a CPU (central processing unit), a GPU (Graphics Processing Unit), an NPU (embedded neural network processor), an FPGA (Field Programmable Gate Array), a TPU (tensor processing unit), an AI chip, an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present application.

[0231] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0232] Among them, the memory 3 stores one or more computer-executable instructions, and the processor 1 calls the one or more computer-executable instructions to execute the text generation method provided in the embodiment of the present application.

[0233] An embodiment of the present application also provides a storage medium, which can store one or more computer-executable instructions, and the one or more computer-executable instructions can be used to execute the text generation method provided in the embodiment of the present application.

[0234] The above describes multiple implementation schemes provided by the embodiments of the present application. The various optional methods introduced in each implementation scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible implementation schemes, which can all be considered as implementation schemes disclosed and open in the embodiments of the present application.

[0235] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be subject to the scope defined by the claims.

Claims

1. A text generation method, wherein: include: Get the word vector of the t-th word generated in the t-th step, and the label of the t-th word; Predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step; Strengthening the word vector of the t-th word according to the label state of the t+1-th step; According to the results of the enhanced processing, predict the word state of step t+1; Based on the label state of the tth step, obtain the attention result of the data in the keyword memory at the t+1th step; The data stored in the keyword memory includes: keyword variables of each keyword describing the object, and label variables of the label of each keyword, wherein there is a corresponding relationship between the label variable and the keyword variable; According to the word state of the t+1th step and the attention result of the t+1th step, predict the t+1th word.

2. The text generation method according to claim 1, wherein: The step of predicting the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step includes: Determine the zeroth word state at step t+1 according to the word vector of the tth word and the word state at step t; The label state of the t+1th step is determined according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step.

3. The text generation method according to claim 2, wherein: Determining the label state of the t+1th step according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step includes: Determine the combination result of the zeroth word state of the t+1th step and the label of the tth word; Determine the initial label state of step t+1 according to the combination result and the label state of step t; Determine the label attention result of the label state of the tth step in the label variable stored in the keyword memory, combine the initial label state of the t+1th step with the label attention result, and obtain the label state of the t+1th step.

4. The text generation method according to claim 2, wherein: The prediction of the word state at step t+1 according to the result after the enhanced processing includes: Determine the first word state of step t+1 according to the result after the enhancement processing and the word state of step t; The word state of the t+1th step is obtained by combining the zeroth word state of the t+1th step and the first word state of the t+1th step.

5. The text generation method according to claim 4, wherein: The combining the zeroth word state of the t+1th step and the first word state of the t+1th step to obtain the word state of the t+1th step includes: Determine a standard deviation based on the full connection result of the zeroth word state of the t+1th step and the first word state of the t+1th step; Based on the standard deviation, the zeroth word state of the t+1th step and the first word state of the t+1th step are combined to obtain the word state of the t+1th step.

6. The text generation method according to any one of claims 1 to 5, wherein: The step of enhancing the word vector of the tth word according to the label state of the t+1th step includes: Add the label state of the t+1th step to the word vector of the tth word.

7. The text generation method according to claim 1, wherein: Also includes: Acquire an object description data set, wherein the object description data set includes multiple keywords describing the object and a label of each keyword; The keyword variable of each keyword and the tag variable of each tag are determined, and each tag variable and the corresponding keyword variable are stored in the keyword memory.

8. The text generation method according to claim 7, wherein: The keyword variables for determining each keyword include: Determine the vector variable, key variable and value variable of the i-th keyword in the object description data set in the latent space; the i-th keyword is any keyword in the object description data set; The keyword variable of the ith keyword is determined according to the vector variable, key variable and value variable of the ith keyword in the latent space.

9. The text generation method according to claim 8, wherein: The step of determining the keyword variable of the ith keyword according to the vector variable, key variable and value variable of the ith keyword in the latent space includes: Interact the vector variable of the ith keyword with the key variables of each keyword in the object description dataset to obtain the weight of the ith keyword and each keyword; According to the weights of the ith keyword and each keyword, the value variables of each keyword in the latent space are subjected to attention processing to obtain the attention results of the ith keyword and each keyword; the attention results of the ith keyword and each keyword are accumulated to obtain the attention accumulation result; Connect the attention accumulation result with the word embedding vector of the i-th keyword to obtain the keyword variable of the i-th keyword.

10. The text generation method according to claim 8, wherein: The vector variable, key variable and value variable of the i-th keyword in the object description data set in the latent space are determined as follows: Determine the word embedding vector of the i-th keyword; Use a vector connection layer to encode the word embedding vector into a vector latent space to obtain a vector variable of the i-th keyword in the vector latent space, and use a key connection layer to encode the word embedding vector into a key latent space to obtain a key variable of the i-th keyword in the key latent space, and use a value connection layer to encode the word embedding vector into a value latent space to obtain a value variable of the i-th keyword in the value latent space.

11. The text generation method according to claim 7, wherein: Determining the label variables of each label includes: Determine the vector variable, key variable, and value variable of the label of the i-th keyword in the object description dataset in the latent space; The label variable of the label of the i-th keyword is determined according to the vector variable, the key variable and the value variable of the label of the i-th keyword in the latent space.

12. The text generation method according to claim 1, wherein: The step of obtaining the attention result of the data in the keyword memory at the step t+1 based on the tag state at the step t includes: The label state of the tth step interacts with each label variable in the keyword memory to obtain the label state of the tth step and the weight of each label variable; According to the label state of the t-th step and the weight of each label variable, attention processing is performed on the keyword variables corresponding to each label variable to obtain the attention results of the label state of the t-th step and the keyword variables corresponding to each label variable; Accumulate the label state of the tth step and the attention results of the keyword variables corresponding to each label variable, and determine the attention results of the data in the keyword memory in the t+1th step according to the accumulation results.

13. The text generation method according to claim 1, wherein: The step of predicting the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step includes: Determine the word context vector of step t+1; Combine the attention result of the step t+1 with the word context vector of the step t+1 to obtain the target attention result; Determine the word distribution data of the t+1th word according to the target attention result and the word state of the t+1th step; The t+1th word is determined according to the word distribution data.

14. The text generation method according to claim 13, wherein: The word distribution data includes the distribution probability of each word in a preset word list; and determining the t+1th word according to the word distribution data includes: It is determined that the word with the largest distribution probability in the word list is the t+1th word.

15. The text generation method according to claim 3, wherein: Also includes: Determine the label vector for step t+1; Determine the label distribution data of the label of the t+1th word according to the initial label state of the t+1th step and the label vector of the t+1th step; According to the label distribution data, the label of the t+1th word is determined.

16. The text generation method according to claim 1, wherein: Also includes: Determine the generated text and tags in the text; Determining a negative log-likelihood function based on the generated text and labels in the text; Text generation parameters are optimized according to the negative log-likelihood function.

17. A text generation device, wherein: include: An acquisition unit, used to acquire the word vector of the t-th word generated in the t-th step, and the label of the t-th word; A label state prediction unit, configured to predict a label state at the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state at the tth step; A strengthening processing unit, used for strengthening the word vector of the t-th word according to the label state of the t+1-th step; A word state prediction unit, used to predict the word state of the t+1th step according to the result after the enhancement processing; An attention result acquisition unit is used to acquire the attention result of the data in the keyword memory at the t+1 step based on the label state of the t step; The data stored in the keyword memory includes: keyword variables of each keyword describing the object, and label variables of the label of each keyword, wherein there is a corresponding relationship between the label variable and the keyword variable; A word prediction unit is used to predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

18. A text generation device, wherein: include: A keyword encoder, used to obtain an object description dataset, wherein the object description dataset includes multiple keywords describing the object and labels of each keyword; Determine the keyword variable of each keyword and the label variable of each label; store each label variable and the corresponding keyword variable in the keyword memory; A keyword memory, used to store keyword variables of each keyword and label variables of each keyword label, wherein there is a corresponding relationship between the label variable and the keyword variable; A text generator is used to obtain the word vector of the tth word generated in the tth step and the label of the tth word; predict the label state of the t+1th step according to the word vector of the tth word, the label of the tth word, and the label state of the tth step; enhance the word vector of the tth word according to the label state of the t+1th step; predict the word state of the t+1th step according to the result of the enhanced processing; based on the label state of the tth step, obtain the attention result of the data in the keyword memory in the t+1th step; predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

19. The text generation device according to claim 18, wherein: The text generator includes: a word memory network for determining word states, a label memory network for determining label states, and an output layer; the word memory network includes: a zeroth word memory network and a first word memory network; wherein the word state of the word memory network is obtained by integrating the zeroth word state of the zeroth word memory network and the first word state of the first word memory network.

20. The text generation device according to claim 19, wherein: The zeroth word memory network is used to determine the zeroth word state at the t+1th step according to the word vector of the tth word and the word state at the tth step; The label memory network is used to determine the label state of the t+1th step according to the zeroth word state of the t+1th step, the label of the tth word, and the label state of the tth step; The first word memory network is used to obtain the result of the label state of the t+1th step to enhance the word vector of the tth word, determine the first word state of the t+1th step according to the result of the enhanced processing and the word state of the tth step; combine the zeroth word state of the t+1th step and the first word state of the t+1th step to obtain the word state of the t+1th step of the word memory network; The output layer is used to obtain the attention result of the data in the keyword memory at the t+1th step based on the label state of the tth step; and predict the t+1th word according to the word state of the t+1th step and the attention result of the t+1th step.

21. The text generation device according to claim 18, wherein: The keyword encoder comprises: The keyword self-attention module SAM is used to determine the keyword variable of each keyword in the object description dataset; Label SAM is a label variable used to determine the label of each keyword in the object description dataset.

22. A computer device, wherein: include: at least one memory and at least one processor; The memory stores one or more computer-executable instructions, and the processor calls the one or more computer-executable instructions to execute the text generation method according to any one of claims 1-16.

23. A storage medium, wherein: The storage medium stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the text generation method as described in any one of claims 1-16.