Text generation method, device, computer equipment and medium based on artificial intelligence
By extracting structural information and keywords from the reference text to generate text, the problem of low text generation accuracy in traditional methods is solved, and structural diversity and security are improved.
Patent Information
- Application Number
- CN202010548649.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-16
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-06-16
AI Technical Summary
Traditional neural network methods have greater randomness in text generation, resulting in lower accuracy of generated text content.
By extracting text structure information from the reference text content, including grammatical structure and word structure, combined with text keywords, new text content is generated to ensure that the generated text meets the structural requirements of the reference text, and the data is stored through the blockchain to improve Security.
It improves the accuracy and structural diversity of text generation, ensures that the generated text content meets the structural requirements of the reference text, and improves data security through blockchain storage of data.
Smart Images

Figure CN111709229B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to an artificial intelligence-based text generation method, apparatus, computer equipment and medium. Background Art
[0002] Text generation is widely used in various natural language processing tasks today, such as speech recognition, machine translation, document classification, human-computer dialogue, etc.
[0003] In the traditional method, a neural network is used to learn the statistical associations between characters or words, and then predictions are made based on the learning results to obtain prediction results.
[0004] However, in this manner, the generation of text content is relatively random, resulting in low accuracy of the generated text content. Summary of the invention
[0005] Based on this, it is necessary to provide an artificial intelligence-based text generation method, device, computer equipment and medium that can improve the accuracy of text content generation in response to the above technical problems.
[0006] A text generation method based on artificial intelligence, the method comprising:
[0007] Obtain a text generation request, which carries text keywords and reference text content;
[0008] Extracting text structure information from the reference text content, where the text structure information is used to control the text structure of the text content to be generated;
[0009] Generate new text content based on the extracted text structure information and text keywords.
[0010] In one embodiment, extracting text structure information from reference text content includes:
[0011] Extracting the grammatical structure of the reference text content to obtain grammatical structure information of the reference text content;
[0012] Splitting the reference text content to obtain word structure information of each text position in the reference text content;
[0013] The grammatical structure information and word structure information are used as text structure information of the reference text content.
[0014] In one embodiment, the reference text content is split to obtain word structure information of each text position in the reference text content, including:
[0015] Splitting the reference text content into words to obtain each text word in the reference text content, part-of-speech information of each text word, and word position information of each text word in the reference text content;
[0016] Splitting each text word into text characters to obtain text character information of each text character and character position information of each text character in the text word;
[0017] Each part of speech information, word position information, text word information and position information is used as word structure information of each word in the reference text content.
[0018] In one embodiment, new text content is generated based on the extracted text structure information and text keywords, including:
[0019] According to the text keywords, determine the part of speech information of the text keywords;
[0020] Determine the part-of-speech information of each to-be-predicted text word according to the part-of-speech information of the text keyword and the word structure information of each text position in the text structure information;
[0021] Predicting text words based on text keywords, part-of-speech information of each to-be-predicted text word, and text structure information to obtain each predicted text word;
[0022] New text content is generated based on each predicted text word.
[0023] In one embodiment, text word prediction is performed based on text keywords, part-of-speech information of each to-be-predicted text word, and text structure information, including:
[0024] Taking the text keyword as the current predicted word, and predicting the text word according to the part-of-speech information and text structure information of each text word to be predicted, to obtain the predicted text word;
[0025] The obtained predicted text words and text keywords are used as current predicted words, and the prediction of text words is continued according to the part-of-speech information and text structure information of the remaining text words to be predicted, until the prediction of all the text words to be predicted is completed.
[0026] In one embodiment, the method further comprises:
[0027] At least one of the text keywords, the reference text content, the text structure information, and the new text content is uploaded to the blockchain and stored in a node of the blockchain.
[0028] A text generation device based on artificial intelligence, the device comprising:
[0029] A text generation request acquisition module is used to acquire a text generation request, where the text generation request carries text keywords and reference text content;
[0030] A text structure information extraction module is used to extract text structure information from the reference text content, and the text structure information is used to control the text structure of the text content to be generated;
[0031] The text content generation module is used to generate new text content based on the extracted text structure information and text keywords.
[0032] In one embodiment, the text structure information extraction module includes:
[0033] The grammatical structure information extraction submodule is used to extract the grammatical structure of the reference text content to obtain the grammatical structure information of the reference text content;
[0034] The word structure information generation submodule is used to split the reference text content to obtain the word structure information of each text position in the reference text content;
[0035] The text structure information generation submodule is used to use the grammatical structure information and word structure information as the text structure information of the reference text content.
[0036] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
[0037] A computer-readable storage medium stores a computer program, which implements the steps of any of the above methods when executed by a processor.
[0038] The above-mentioned artificial intelligence-based text generation method, device, computer equipment and medium obtain a text generation request, which carries text keywords and reference text content, and then extracts text structure information from the reference text content. The text structure information is used to control the text structure of the text content to be generated, and further generates new text content based on the extracted text structure information and text keywords. Therefore, by extracting the text structure information of the reference text content and generating text content corresponding to the text structure information, the text content generation can meet the text structure requirements of the reference text content, thereby improving the accuracy of text generation. In addition, by extracting different text structure information, text content corresponding to different text structures can be generated, so that the text structure of the generated text content is controllable, and the diversity of the text structure of the generated text content is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1This is an application scenario diagram of a text generation method based on artificial intelligence in one embodiment;
[0040] Figure 2 A flowchart of a method for generating text based on artificial intelligence in one embodiment;
[0041] Figure 3 is a flowchart of a text generation method based on artificial intelligence in another embodiment;
[0042] Figure 4 is a structural block diagram of a text generation device based on artificial intelligence in one embodiment;
[0043] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] The text generation method based on artificial intelligence provided in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. Specifically, the terminal 102 receives user input, generates a text generation request, and sends the generated text generation request to the server 104, and the text generation request carries text keywords and reference text content. After obtaining the text generation request, the server 104 extracts the text structure information from the reference text content carried by the text generation request. Then the server 104 generates new text content based on the extracted text structure information and text keywords. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0046] In one embodiment, Figure 2 As shown, a text generation method based on artificial intelligence is provided, and the method is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0047] Step S202: obtaining a text generation request, where the text generation request carries text keywords and reference text content.
[0048] The text generation request refers to a request sent by the terminal for generating text content, and the text generation request carries text keywords of the text content to be generated and reference text content.
[0049] Reference text content refers to text content used for reference, or can also be called a text template.
[0050] In this embodiment, the user can select corresponding reference text content through the terminal according to the text to be generated, generate a text generation request and send it to the server.
[0051] In this embodiment, after receiving the text generation request, the server may obtain the text keywords and reference text content carried in the text generation request, and perform subsequent processing.
[0052] Step S204: extracting text structure information from the reference text content, where the text structure information is used to control the text structure of the text content to be generated.
[0053] The text structure information refers to the structural information of the text content, which may include grammatical structure information and word structure information. The text structure information is used to control the text structure of the text content to be generated.
[0054] Specifically, text grammar information refers to information such as the subject-predicate-object structure of a text sentence, the main structure of a text sentence, and the modified structure. Word structure information refers to structural information of each word in the text content.
[0055] In this embodiment, after the server obtains the text reference request, it can extract the text structure information based on the reference text content in the text reference request. For example, the text structure information can be extracted by extracting the text structure information of the reference text content through a deep network model and one or more of various grammatical tools to obtain the text structure information of the reference text content.
[0056] In this embodiment, according to the different reference text contents carried in the text reference request, the server can extract text structure information corresponding to different reference text contents. For example, for request 1, its reference text content is text content with a subject-predicate-object structure, such as "He plays basketball", then the extracted text structure information may include subject-predicate-object structure information. For text 2, its reference text content is text content with a subject-complement-predicate structure, such as "The beautiful sky is always fascinating", then the extracted text structure information may include subject-complement-predicate structure information.
[0057] Step S206: Generate new text content based on the extracted text structure information and text keywords.
[0058] Specifically, the server may predict text words according to the extracted text structure information and text keywords, and generate new text content based on the predicted text words and text keywords.
[0059] In this embodiment, based on different text keywords and / or different text structure information, the generated new text content is different. For example, for the text structure information of the subject-predicate-object structure, the generated new text content is also a subject-predicate-object structure; for the text structure information of the definite subject-complement-predicate structure, the generated new text content is also a definite subject-complement-predicate structure.
[0060] In the above-mentioned text generation method based on artificial intelligence, a text generation request is obtained, the text generation request carries text keywords and reference text content, and then text structure information is extracted from the reference text content. The text structure information is used to control the text structure of the text content to be generated, and further new text content is generated according to the extracted text structure information and text keywords. Thus, by extracting the text structure information of the reference text content and generating text content corresponding to the text structure information, the text content generation can meet the text structure requirements of the reference text content, thereby improving the accuracy of text generation. Moreover, by extracting different text structure information, text content corresponding to different text structures can be generated, so that the text structure of the generated text content is controllable, and the diversity of the text structure of the generated text content is improved.
[0061] In one embodiment, extracting text structure information from reference text content may include: extracting the grammatical structure of the reference text content to obtain grammatical structure information of the reference text content; splitting the reference text content to obtain word structure information of each text position in the reference text content; and using the grammatical structure information and word structure information as the text structure information of the reference text content.
[0062] The grammatical structure information refers to the main structure information of the text sentence, which may include the subject-predicate-object structure, the main structure of the text sentence, the modifying structure and other information mentioned above.
[0063] Word structure information refers to the position structure information of each character or word in a text sentence and the part of speech information of each word.
[0064] In this embodiment, reference Figure 3, the server can extract the grammatical structure information of the reference text content through the neural network model. For example, the server inputs the reference text content into the ON-LSTM model to output the grammatical structure information of the reference text content, that is, to obtain the sentence level structure. For example, if the reference text content is "I am an employee of Ping An", the server can extract the grammatical structure information of the reference text content as the subject-predicate-object structure + attributive modifier structure through the model, and determine that the main structure of the text sentence is "I am an employee" and the modification structure is "Ping An's".
[0065] In this embodiment, the model for extracting grammatical structure information may be a pre-trained model. The server trains and tests the model using a large amount of training set data to obtain a trained model.
[0066] Furthermore, the server may split the reference text content by using a grammar tool, such as Thulac, etc., to obtain word structure information of text words at each text position in the reference text content.
[0067] In one of the embodiments, the reference text content is split to obtain word structure information of each text position in the reference text content, which may include: splitting the reference text content into text words to obtain each text word in the reference text content, the part-of-speech information of each text word, and the word position information of each text word in the reference text content; splitting each text word into text characters to obtain text character information of each text character and the character position information of each text character in the text word; using each part-of-speech information, word position information, text character information, and position information as the word structure information of each word in the reference text content.
[0068] Among them, text words refer to the words that make up the text content, which can be a single word or a multiple word. For example, for the reference text content "I am an employee of Ping An", the text words "I" and "is" are words that make up the text content, and "employee", "Ping An" and so on are also words that make up the text content.
[0069] Part-of-speech information refers to information indicating the part of speech of each text word, such as noun, verb, pronoun, adjective, etc. For example, "I" is a pronoun, "is" is a verb, "employee" is a noun, and "safe" is an adjective.
[0070] Word position information refers to the position information of each text word in the text content. For example, continuing to quote the previous example, "I" is the word in the first text position in the reference text content, so its position information is the first position word in the text content. Similarly, "is" and "safe" are the middle position words in the reference text content, and their position information are middle position word 1 and middle position word 2 respectively, and "employee" is the end word of the sentence.
[0071] The text character information refers to the information of each text character in each text word, and the character position information refers to the position information of each text character in the text word. For example, for the text word "safe", "平" is the first character in the middle position word 2, "安" is the second character in the middle position word 2, and "的" is the third character in the middle position word 2.
[0072] In this embodiment, continue to refer to Figure 3 , the server uses a syntax tool to split the reference text content into text words, and then split the text words into text characters to obtain the word structure information at each text position in the reference text content.
[0073] In this embodiment, the word structure information at each text position can be determined in the following way, that is, first determine whether each word is a single-character word. If the word is a single-character word, it is represented by the letter S, where S is the abbreviation of single. If the word is not a single-character word, each character can be represented according to its position in the word plus the part of speech of the word. For example, for the reference text content "我是平安的员工" (I am an employee of Ping An), "我" is a single-character word and can be represented as S, "平安的" is not a single-character word, and since "平安的" is an adjective, "平" can be represented as "B+adj", "安" can be represented as "M+adj", and "的" can be represented as "E+adj". Here, B is the abbreviation of begin, representing the starting position, M is the abbreviation of middle, representing the middle position, E is the abbreviation of End, representing the ending position, and adj represents adjective.
[0074] In the above embodiment, by separately extracting the syntactic structure information and the word structure information, the generated text structure information contains both the main structure information of the reference text content and the word structure information of each word, making the expression of the text structure information for the structure of each text word more accurate and ensuring the integrity of the information.
[0075] In one of the embodiments, according to the extracted text structure information and text keywords, generating new text content may include: determining the part-of-speech information of the text keywords according to the text keywords; determining the part-of-speech information of each text word to be predicted according to the part-of-speech information of the text keywords and the word structure information at each text position in the text structure information; performing text word prediction according to the text keywords, the part-of-speech information of each text word to be predicted, and the text structure information to obtain each predicted text word; and generating new text content according to each predicted text word.
[0076] Specifically, the server can determine the part-of-speech information of the text keywords according to the text keywords carried in the text generation request. For example, for the text keyword "客户" (customer), its part-of-speech can be determined as a noun.
[0077] Furthermore, the server can determine the part of speech information of the text words to be predicted based on the word structure information of each text position in the text structure information. For example, if the text keyword "customer" is determined to be a noun, then based on each word structure information, it can be determined that the text words to be predicted are pronouns, verbs, adjectives, etc. The server can also determine the number of characters of each text word to be predicted, the position information in the text sentence, etc. based on the text word information and word position information in the text word information.
[0078] Furthermore, the server predicts each text word with predicted text words according to the text keywords, the part-of-speech information of each text word to be predicted, and the obtained text structure information of the reference text content to obtain each predicted text word.
[0079] Furthermore, the server generates new text content according to the obtained predicted text words, text keywords and text structure information. For example, if the predicted text words are "you", "yes", "Ping An", the text keyword is "customer", and the text structure information of each word, the new text content "You are Ping An's customer" can be obtained.
[0080] In this embodiment, for the same predicted text words and text keywords, different text structure information will result in different new text contents. For example, for the same text words such as "you", "is", "Ping An's" and "customer", if the reference text content is "Ping An's employee is you", the new text content generated based on the extracted text structure information is "Ping An's customer is you".
[0081] Optionally, the text keyword may also be multiple words. For example, if the text keywords are "I" and "customer", the generated new text content may be "I am a customer of Ping An".
[0082] In this embodiment, when the number of text keywords carried in the text generation request is more, the generated text content is more in line with the text generation request, and the generated text content is more accurate. For example, if the text keywords are "he", "the company's", and "colleague", the generated new text content may be "he is a colleague of the company".
[0083] In the above embodiment, the word structure information of the text keywords and the word structure information of each text word to be predicted are determined according to the text keywords and the text structure information, and then the text words are predicted. Therefore, each text word to be predicted can be accurately predicted according to the word structure information of each text word to be predicted, thereby improving the accuracy of the prediction. Moreover, each text word is predicted by the word structure information of each text word to be predicted and the grammatical structure information of the reference text content, so that the text structure of the generated text content can be controlled, and the structural diversity of the generated text content can be improved.
[0084] In one of the embodiments, text word prediction is performed based on text keywords, part-of-speech information of each text word to be predicted, and text structure information, which can include: taking the text keyword as the current predicted word, and predicting the text word based on the part-of-speech information and text structure information of each text word to be predicted to obtain a predicted text word; taking the obtained predicted text word and text keyword as the current predicted word, and continuing to predict the text word based on the part-of-speech information and text structure information of the remaining text words to be predicted, until the prediction of all text words to be predicted is completed.
[0085] In this embodiment, when the server predicts a text word, it first uses the text keyword as the current predicted word to predict the text word, and then continues to predict the text word to be predicted that has not yet been predicted based on the obtained predicted text word and the text keyword. For example, if the text keyword is "client", the server may first obtain the predicted text word "is", and then continue to predict based on the keyword "client", the predicted text word "is" and the text structure information, such as obtaining the predicted word "he". This is repeated until the prediction of all the text words to be predicted determined by the text structure information is completed.
[0086] In this embodiment, the server predicts the remaining text words to be predicted by predicting the probabilities of the unpredicted text words to be predicted based on the probabilities of the predicted text words and keywords that have been obtained, and then continues to predict the unpredicted text words to be predicted based on the obtained prediction results. For example, according to the keyword "client", the probability of the predicted text word "yes" is 80%, and the probability of "no" is 20%, and then the subsequent prediction of the text words to be predicted is performed. For example, according to "client" and "yes", the probability of "he" is 50%, the probability of "you" is 30%, and the probability of "I" is 20%, etc. According to "client" and "no", the probability of "he" is 80%, the probability of "you" is 25%, and the probability of "I" is 5%, etc., and according to "client" and "no", the probability of "he" is 80%, the probability of "you" is 25%, and the probability of "I" is 5%, etc. And so on, until the prediction of all the text words to be predicted is completed.
[0087] In this embodiment, after obtaining the probability of each predicted text word, the server can obtain the probability of each predicted text content by multiplying the probabilities of all predicted text words, and determine the predicted text content with the highest probability as the new text content. For example, continuing with the previous example, the probability of the predicted text word "yes" is 80%, on this basis, the probability of "I" is 90%, and further, the probability of "safe" is 50%, then the probability of the predicted text sentence "I am a customer of Ping An" can be obtained to be 36%, and the probability of the predicted text word "no" is 70%, on this basis, the probability of "he" is 80%, and the probability of "safe" is 60%, then the probability of the predicted text sentence "he is a customer of Ping An" can be obtained to be 33.6%. By analogy, the probabilities of multiple predicted text contents can be obtained. Then the server determines the one with the highest probability value as the new text content and outputs it.
[0088] In this embodiment, the probability calculation formula for predicting text content is shown in formula (1):
[0089]
[0090] Among them, P(s) represents the probability value of the predicted text content, n represents the number of words in the predicted text content, and P(ω i / ω1,...,ω i-1 ) represents the probability of each text word, and the subscript represents the position of each text word in the text content.
[0091] In the above embodiment, the obtained predicted text words and text keywords are used as the current predicted words, and the prediction of text words is continued based on the word structure information and grammatical structure information of the remaining text words to be predicted. As a result, the predicted text words predicted later include the prediction results of the obtained predicted text words, which can improve the accuracy of the prediction and further improve the accuracy of the generated text content.
[0092] In one embodiment, the server extracts text structure information from the reference text content, determines part-of-speech information of text keywords, part-of-speech information of text words to be predicted, and performs text word prediction through a prediction model.
[0093] For example, continue to refer to Figure 3The server refers to the text content and the text keyword input prediction model to extract the text structure information through the prediction model, that is, to extract the sentence-level grammatical structure information (Sentence level structure), word structure information (Word level POS) and character structure information (Character level POS), and then normalizes it (Normalization) and converts it into a vector through Embedding, such as a 512-dimensional vector, to represent the grammatical structure information and word structure information of the reference text content in the form of a vector, and performs vector fusion to obtain the structural information of the corresponding reference text content represented by the vector.
[0094] Furthermore, the obtained structural information is input into the multi-head self-attention layer, that is, the multi-head self-attention layer takes the 512-dimensional vector as input and obtains the corresponding output. In the multi-head self-attention layer, there is a dependency relationship between the output and the output.
[0095] In this embodiment, the Multi-head Self-attention layer outputs a 512-dimensional vector, and the input and output are normalized (Add&Norm) to obtain the final output structure information
[0096] Similarly, in this embodiment, the server can convert the input text keywords into a 512-dimensional vector by text position embedding (Text&Position Embed), input the multi-head self-attention processing mechanism (Masked Multi-head Self-attention) layer with causal masking, and output the corresponding results, and then normalize the input and output (Add&Norm) to obtain the final output text word information.
[0097] Furthermore, the server fuses the obtained output structure information and output text word information and inputs them into a simple fully connected (Feed Forward) layer to obtain the corresponding output, and adds the input and output of the Feed Forward layer and performs normalization (Add&Norm) to obtain the corresponding text word prediction result.
[0098] Furthermore, the server performs multiple predictions according to the above process until the prediction of multiple text words is completed.
[0099] In this embodiment, after the model completes the prediction of text words, it then generates and outputs new text content through linear transformation (Linear) processing and logistic regression (Soft max).
[0100] In this embodiment, the prediction model can be a pre-trained model. The server can obtain text keywords from the training set data, and input the obtained text keywords and training set data into the initial test model to extract text structure information and perform prediction training on text content.
[0101] Furthermore, the server calculates the loss value of the test model based on the trained text content and the training set data, and continuously updates the test model based on the calculated loss value to obtain a trained test model, thereby improving the accuracy of the generated text content.
[0102] In one of the embodiments, the above method may further include: uploading at least one of text keywords, reference text content, text structure information and new text content to the blockchain, and storing it in a node of the blockchain.
[0103] Blockchain refers to a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0104] Specifically, blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0105] In this embodiment, the server can upload and store one or more data including text keywords, reference text content, text structure information and new text content in the nodes of the blockchain to ensure the privacy and security of the data.
[0106] In the above embodiment, by uploading at least one of the text keywords, reference text content, text structure information and new text content to the blockchain and storing them in the nodes of the blockchain, the privacy of the data stored in the blockchain nodes can be guaranteed, and the security of the data can be improved.
[0107] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0108] In one embodiment, Figure 4 As shown, a text generation device based on artificial intelligence is provided, comprising: a text generation request acquisition module 100, a text structure information extraction module 200 and a text content generation module 300, wherein:
[0109] The text generation request acquisition module 100 is used to acquire a text generation request, where the text generation request carries text keywords and reference text content.
[0110] The text structure information extraction module 200 is used to extract text structure information from the reference text content, and the text structure information is used to control the text structure of the text content to be generated.
[0111] The text content generation module 300 is used to generate new text content according to the extracted text structure information and text keywords.
[0112] In one embodiment, the text structure information extraction module 200 may include:
[0113] The grammatical structure information extraction submodule is used to extract the grammatical structure of the reference text content to obtain the grammatical structure information of the reference text content.
[0114] The word structure information generation submodule is used to split the reference text content to obtain the word structure information of each text position in the reference text content.
[0115] The text structure information generation submodule is used to use the grammatical structure information and word structure information as the text structure information of the reference text content.
[0116] In one embodiment, the word structure information generation submodule may include:
[0117] The first splitting unit is used to split the reference text content into text words to obtain each text word in the reference text content, part-of-speech information of each text word, and word position information of each text word in the reference text content.
[0118] The second splitting unit is used to split each text word into text characters to obtain text character information of each text character and character position information of each text character in the text word.
[0119] The word structure information generating unit is used to use each part of speech information, word position information, text word information and position information as word structure information of each word in the reference text content.
[0120] In one embodiment, the text content generation module 300 may include:
[0121] The keyword part-of-speech information determination submodule is used to determine the part-of-speech information of text keywords based on text keywords.
[0122] The part-of-speech information determination submodule of the text words to be predicted is used to determine the part-of-speech information of each text word to be predicted based on the part-of-speech information of the text keywords and the word structure information of each text position in the text structure information.
[0123] The prediction submodule is used to predict text words according to text keywords, part-of-speech information of each to-be-predicted text word and text structure information to obtain each predicted text word.
[0124] The text content generation submodule is used to generate new text content according to each predicted text word.
[0125] In one embodiment, the prediction submodule may include:
[0126] The predicted text word generating unit is used to take the text keyword as the current predicted word, and predict the text word according to the part-of-speech information and text structure information of each text word to be predicted to obtain the predicted text word.
[0127] The cyclic prediction unit is used to use the obtained predicted text words and text keywords as current predicted words, and continue to predict text words according to the part-of-speech information and text structure information of the remaining text words to be predicted until the prediction of all text words to be predicted is completed.
[0128] In one embodiment, the above device may further include:
[0129] The storage module is used to upload at least one of text keywords, reference text content, text structure information and new text content to the blockchain and store it in a node of the blockchain.
[0130] For the specific definition of the text generation device based on artificial intelligence, please refer to the definition of the text generation method based on artificial intelligence above, which will not be repeated here. Each module in the above-mentioned text generation device based on artificial intelligence can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0131] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as text keywords, reference text content, text structure information and new text content. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a text generation method based on artificial intelligence is implemented.
[0132] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0133] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program: obtaining a text generation request, the text generation request carries text keywords and reference text content; extracting text structure information from the reference text content, the text structure information is used to control the text structure of the text content to be generated; and generating new text content based on the extracted text structure information and text keywords.
[0134] In one embodiment, when the processor executes a computer program, extracting text structure information from reference text content can include: extracting the grammatical structure of the reference text content to obtain grammatical structure information of the reference text content; splitting the reference text content to obtain word structure information of each text position in the reference text content; and using the grammatical structure information and word structure information as text structure information of the reference text content.
[0135] In one of the embodiments, when the processor executes the computer program, it is implemented to split the reference text content and obtain the word structure information of each text position in the reference text content, which may include: splitting the reference text content into text words to obtain each text word in the reference text content, the part-of-speech information of each text word and the word position information of each text word in the reference text content; splitting each text word into text characters to obtain the text character information of each text character and the character position information of each text character in the text word; using each part-of-speech information, word position information, text character information and position information as the word structure information of each word in the reference text content.
[0136] In one of the embodiments, when the processor executes the computer program, new text content is generated according to the extracted text structure information and text keywords, which may include: determining the part-of-speech information of the text keywords according to the text keywords; determining the part-of-speech information of each text word to be predicted according to the part-of-speech information of the text keywords and the word structure information of each text position in the text structure information; predicting text words according to the text keywords, the part-of-speech information of each text word to be predicted, and the text structure information to obtain each predicted text word; and generating new text content according to each predicted text word.
[0137] In one of the embodiments, when the processor executes the computer program, it implements text word prediction based on text keywords, part-of-speech information of each text word to be predicted, and text structure information, which can include: taking the text keyword as the current predicted word, and predicting the text word based on the part-of-speech information and text structure information of each text word to be predicted to obtain a predicted text word; taking the obtained predicted text word and text keyword as the current predicted word, and continuing to predict the text word based on the part-of-speech information and text structure information of the remaining text words to be predicted, until the prediction of all text words to be predicted is completed.
[0138] In one of the embodiments, when the processor executes the computer program, it can also implement the following steps: uploading at least one of the text keywords, reference text content, text structure information and new text content to the blockchain, and storing it in the node of the blockchain.
[0139] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining a text generation request, the text generation request carries text keywords and reference text content; extracting text structure information from the reference text content, the text structure information is used to control the text structure of the text content to be generated; and generating new text content based on the extracted text structure information and text keywords.
[0140] In one embodiment, when the computer program is executed by a processor, the text structure information is extracted from the reference text content, which may include: extracting the grammatical structure of the reference text content to obtain the grammatical structure information of the reference text content; splitting the reference text content to obtain the word structure information of each text position in the reference text content; and using the grammatical structure information and the word structure information as the text structure information of the reference text content.
[0141] In one of the embodiments, when the computer program is executed by the processor, it is implemented to split the reference text content and obtain the word structure information of each text position in the reference text content, which may include: splitting the reference text content into text words to obtain each text word in the reference text content, the part-of-speech information of each text word and the word position information of each text word in the reference text content; splitting each text word into text characters to obtain the text character information of each text character and the character position information of each text character in the text word; using each part-of-speech information, word position information, text character information and position information as the word structure information of each word in the reference text content.
[0142] In one of the embodiments, when the computer program is executed by the processor, new text content is generated based on the extracted text structure information and text keywords, which may include: determining the part-of-speech information of the text keywords based on the text keywords; determining the part-of-speech information of each text word to be predicted based on the part-of-speech information of the text keywords and the word structure information of each text position in the text structure information; predicting text words based on the text keywords, the part-of-speech information of each text word to be predicted, and the text structure information to obtain each predicted text word; and generating new text content based on each predicted text word.
[0143] In one of the embodiments, when the computer program is executed by the processor, it implements text word prediction based on text keywords, part-of-speech information of each text word to be predicted, and text structure information, which can include: taking the text keyword as the current predicted word, and predicting the text word based on the part-of-speech information and text structure information of each text word to be predicted to obtain a predicted text word; taking the obtained predicted text word and text keyword as the current predicted word, and continuing to predict the text word based on the part-of-speech information and text structure information of the remaining text words to be predicted, until the prediction of all text words to be predicted is completed.
[0144] In one embodiment, when the computer program is executed by the processor, the following steps can also be implemented: uploading at least one of text keywords, reference text content, text structure information, and new text content to the blockchain, and storing it in a node of the blockchain.
[0145] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0146] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0147] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A text generation method based on artificial intelligence, characterized in that: The method comprises: Obtaining a text generation request, wherein the text generation request carries text keywords and reference text content; Extracting text structure information from the reference text content, wherein the text structure information is used to control the text structure of the text content to be generated; Generate new text content according to the extracted text structure information and the text keywords; The extracting text structure information from the reference text content includes: Extracting the grammatical structure of the reference text content to obtain grammatical structure information of the reference text content; Splitting the reference text content to obtain word structure information of each text position in the reference text content; Using the grammatical structure information and the word structure information as text structure information of the reference text content; The step of splitting the reference text content to obtain word structure information of each text position in the reference text content includes: Splitting the reference text content into words to obtain each text word in the reference text content, part-of-speech information of each text word, and word position information of each text word in the reference text content; Splitting each of the text words into text characters to obtain text character information of each text character and character position information of each of the text characters in the text word; Using each of the part-of-speech information, the word position information, the text word information and the position information as word structure information of each word in the reference text content; Generating new text content according to the extracted text structure information and the text keywords includes: Determining part-of-speech information of the text keyword according to the text keyword; Determine the part-of-speech information of each to-be-predicted text word according to the part-of-speech information of the text keyword and the word structure information of each text position in the text structure information; Predicting text words according to the text keywords, the part-of-speech information of each of the text words to be predicted, and the text structure information to obtain each predicted text word; generating new text content according to each of the predicted text words; The step of predicting text words according to the text keywords, the part-of-speech information of each of the text words to be predicted, and the text structure information includes: Taking the text keyword as the current predicted word, and predicting the text word according to the part-of-speech information of each of the text words to be predicted and the text structure information, to obtain the predicted text word; The obtained predicted text words and the text keywords are used as current predicted words, and the prediction of text words is continued according to the part-of-speech information of the remaining text words to be predicted and the text structure information, until the prediction of all the text words to be predicted is completed.
2. The method according to claim 1, characterized in that The grammatical structure information refers to the subject-predicate-object structure of the text sentence, the main structure of the text sentence, and the modification structure information.
3. The method according to claim 1, characterized in that The text words refer to the words that constitute the text content.
4. The method according to claim 1, characterized in that: The method further comprises: At least one of the text keywords, the reference text content, the text structure information, and the new text content is uploaded to the blockchain and stored in a node of the blockchain.
5. A text generation device based on artificial intelligence, characterized in that: The device comprises: A text generation request acquisition module, used to acquire a text generation request, wherein the text generation request carries text keywords and reference text content; A text structure information extraction module, used to extract text structure information from the reference text content, wherein the text structure information is used to control the text structure of the text content to be generated; A text content generation module, used to generate new text content according to the extracted text structure information and the text keywords; The text structure information extraction module comprises: A grammatical structure information extraction submodule, used to extract the grammatical structure of the reference text content to obtain the grammatical structure information of the reference text content; A word structure information generating submodule is used to split the reference text content to obtain word structure information of each text position in the reference text content; A text structure information generating submodule, used for using the grammatical structure information and the word structure information as the text structure information of the reference text content; The word structure information generation submodule includes: A first splitting unit is used to split the reference text content into text words to obtain each text word in the reference text content, part-of-speech information of each text word, and word position information of each text word in the reference text content; A second splitting unit is used to split each of the text words into text characters to obtain text character information of each text character and character position information of each text character in the text word; A word structure information generating unit, configured to use each of the part-of-speech information, the word position information, the text word information and the position information as the word structure information of each word in the reference text content; The text content generation module includes: A keyword part-of-speech information determination submodule, used to determine the part-of-speech information of the text keyword according to the text keyword; A submodule for determining part-of-speech information of words in the text to be predicted, used to determine the part-of-speech information of each word in the text to be predicted based on the part-of-speech information of the text keywords and the word structure information of each text position in the text structure information; A prediction submodule, configured to perform text word prediction based on the text keywords, the part-of-speech information of each of the text words to be predicted, and the text structure information, to obtain each predicted text word; A text content generation submodule, used for generating new text content according to each of the predicted text words; The prediction submodule includes: A predicted text word generating unit, used for taking the text keyword as the current predicted word, and predicting the text word according to the part-of-speech information of each of the text words to be predicted and the text structure information, to obtain the predicted text word; The cyclic prediction unit is used to use the obtained predicted text words and the text keywords as current predicted words, and continue to predict text words according to the part-of-speech information of the remaining text words to be predicted and the text structure information until the prediction of all the text words to be predicted is completed.
6. The device according to claim 5, characterized in that The grammatical structure information refers to the subject-predicate-object structure of the text sentence, the main structure of the text sentence, and the modified structure information.
7. The device according to claim 5, characterized in that The text words refer to the words that constitute the text content.
8. The device according to claim 5, characterized in that The device also includes: A storage module is used to upload at least one of the text keywords, the reference text content, the text structure information and the new text content to the blockchain and store it in a node of the blockchain.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
