Natural language generation methods, devices, equipment, media, and products
By classifying candidate text data using a pre-defined discriminative neural network model and generating candidate natural language sentences using multiple language generation models, a coordinating neural network model performs a comprehensive evaluation, thus solving the problem of low quality natural language in neural network-based generation methods and achieving higher quality natural language generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2026-03-13
AI Technical Summary
Natural language generation methods based on neural networks produce natural language of lower quality.
A pre-defined discriminative neural network model is used to classify multiple candidate fields in the candidate text data, determine the target field that matches each pre-defined language generation neural network model, and generate candidate natural language sentences through multiple language generation models. Finally, a coordinating neural network model performs a comprehensive score and outputs the target natural language sentence with the highest comprehensive score.
It improves the quality and efficiency of natural language generation, and the output natural language sentences are more in line with user intent and semantic requirements.
Smart Images

Figure CN114239545B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of human-computer interaction technology, and in particular to a natural language generation method, apparatus, device, medium and product. Background Technology
[0002] Research on human-computer voice interaction systems has expanded from the scientific research field to various terminal manufacturing fields such as smart TVs, in-vehicle navigation, and smart speakers. Besides speech recognition and text-to-speech modules, voice interaction systems require the following four key capabilities: natural language understanding, dialogue state tracking, dialogue strategy learning, and natural language generation. Among these, the natural language generation module needs to convert specific semantic information into sentences in a natural language format familiar to the user.
[0003] Traditional rule-based template-based natural language generation methods are gradually being replaced due to poor transferability and rigid, one-dimensional responses, while neural network-based natural language generation methods are gaining increasing attention due to their flexibility and versatility. However, neural network-based generative models also suffer from problems such as inaccurate semantic representation.
[0004] Therefore, the quality of natural language generated by current neural network-based natural language generation methods is relatively low. Summary of the Invention
[0005] This invention provides a natural language generation method, apparatus, device, medium, and product to solve the problem of low quality of natural language generated by neural network-based natural language generation methods.
[0006] In a first aspect, embodiments of the present invention provide a natural language generation method, including:
[0007] Obtain target user interaction information;
[0008] Based on the target user interaction information, the candidate text data on which the generation of candidate natural language statements depends is determined, and the candidate text data includes multiple candidate fields;
[0009] A preset discriminative neural network model is used to classify multiple candidate fields in the candidate text data to determine multiple target fields that match each preset language generation neural network model, and the multiple target fields form target text data;
[0010] The corresponding candidate natural language sentences are generated using various preset language generation neural network models and matched target text data.
[0011] Multiple candidate natural language statements are input into a pre-defined coordinating neural network model to output the target natural language statement with the highest comprehensive score.
[0012] In some embodiments of this application, the language generation neural network model includes: a knowledge-based language generation model, a dialogue action-based language generation model, and a search condition-based language generation model;
[0013] The process of generating corresponding candidate natural language sentences using preset language generation neural network models and matched target text data includes:
[0014] Input various types of target text data into a matching language generation neural network model;
[0015] The target text data is processed by natural language generation neural network models that match the language, and the corresponding candidate natural language sentences are output.
[0016] In some embodiments of this application, the knowledge-based language generation model includes an encoder, a knowledge selector, a decoder, and a word generator; the target text data matched with the knowledge-based language generation model is knowledge-based target text data; the knowledge-based target text data includes the following target fields: user intent search results, entities in the knowledge base associated with user intent, user profile information, dialogue actions, and slot information;
[0017] A knowledge-based language generation model and knowledge-based target text data are used to generate corresponding candidate natural language sentences, including:
[0018] The encoder is used to encode each knowledge-based target field to generate corresponding hidden state representation data;
[0019] The knowledge selector is used to determine the directly associated entities in the knowledge base associated with the user intent based on the implicit state representation data.
[0020] A decoder is used to decode the knowledge-based target text data, excluding entities in the knowledge base associated with the user intent, and the directly associated entities, to form decoded text data.
[0021] Based on the decoded text data and the word generator, matching candidate natural language sentences are generated.
[0022] In some embodiments of this application, the knowledge-based language generation model further includes a coordinator; the word generator includes a vocabulary generator and a copy generator.
[0023] The step of generating matching candidate natural language sentences based on the decoded text data and the word generator includes:
[0024] The coordinator determines, according to the decoding order, whether the current text data in the decoded text data is matched by the vocabulary generator or the copy generator; the decoding order is the order in which the decoder generates the decoded text data.
[0025] If it is determined that the match is a word generator, then the word generator is used to generate the corresponding words based on the user intent search results, user profile information, dialogue actions, and slot information;
[0026] If it is determined that the match is a copy generator, then the copy generator is used to generate corresponding words based on the user intent search results, the directly associated entities, the dialogue actions, and the slot information;
[0027] Semantic recognition processing is performed on all generated words to concatenate them into candidate natural language sentences.
[0028] In some embodiments of this application, the step of inputting multiple candidate natural language statements into a preset coordinating neural network model to output the target natural language statement with the highest comprehensive score includes:
[0029] Input multiple candidate natural language statements into a pre-defined coordinating neural network model;
[0030] The coordinated neural network model is used to comprehensively score multiple candidate natural language statements according to a preset evaluation strategy, and outputs the target natural language statement with the highest comprehensive score.
[0031] In some embodiments of this application, the step of using the coordinated neural network model to comprehensively score multiple candidate natural language statements according to a preset evaluation strategy includes:
[0032] The perplexity of each candidate natural language statement is calculated using the aforementioned coordinated neural network model, and semantic analysis is performed on each candidate natural language statement to obtain semantic analysis results.
[0033] The comprehensive score of each candidate natural language statement is determined based on the perplexity and semantic analysis results.
[0034] In some embodiments of this application, before inputting multiple candidate natural language statements into a preset coordinated neural network model, the method further includes:
[0035] Multiple candidate natural language statements are input into a preset language model to determine the perplexity of each candidate natural language statement.
[0036] Determine whether each of the stated perplexity values is less than a preset perplexity threshold;
[0037] If the perplexity is determined to be less than a preset perplexity threshold, then the candidate natural language statement corresponding to that perplexity is retained.
[0038] If the perplexity is determined to be greater than or equal to a preset perplexity threshold, then the candidate natural language statement corresponding to that perplexity is deleted.
[0039] In some embodiments of this application, before inputting multiple candidate natural language statements into a preset coordinated neural network model, the method further includes:
[0040] Determine whether the number of identical words in each candidate natural language statement is greater than or equal to a preset threshold.
[0041] If the number of identical words is less than a preset threshold, the corresponding candidate natural language sentences are retained.
[0042] If the number of identical words is determined to be greater than or equal to the preset detection threshold, the corresponding candidate natural language statement is deleted.
[0043] In some embodiments of this application, before generating corresponding candidate natural language sentences using a knowledge-based language generation model and knowledge-based target text data, the method further includes:
[0044] Obtain training samples, which include: historical user intent search results, entities in the knowledge base associated with historical user intent, historical dialogue actions, historical user profile information, and historical slot information;
[0045] The training samples are input into a preset knowledge-based language generation model to train the preset knowledge-based language generation model;
[0046] The preset knowledge-based language generation model is judged to meet the convergence condition by using a preset knowledge selection loss function and a preset generation response loss function.
[0047] When the sum of the preset knowledge selection loss function and the preset generation response loss function reaches its minimum, the preset knowledge-based language generation model is determined to satisfy the convergence condition.
[0048] The pre-defined knowledge-based language generation model that meets the convergence condition is selected as the knowledge-based language generation model that has been trained to convergence.
[0049] A second aspect of the present invention provides a natural language generation apparatus, comprising:
[0050] The acquisition module is used to acquire target user interaction information;
[0051] The determination module is used to determine the candidate text data on which the generation of candidate natural language statements depends based on the target user interaction information, wherein the candidate text data includes multiple candidate fields;
[0052] The classification module is used to classify multiple candidate fields in the candidate text data using a preset discriminative neural network model, so as to determine multiple target fields that match each preset language generation neural network model, and the multiple target fields form target text data;
[0053] The generation module is used to generate corresponding candidate natural language sentences using preset language generation neural network models and matched target text data.
[0054] The output module is used to input multiple candidate natural language statements into a preset coordinating neural network model to output the target natural language statement with the highest comprehensive score.
[0055] Thirdly, embodiments of the present invention provide an electronic device, including: a memory and a processor;
[0056] Memory; memory for storing executable instructions of the processor;
[0057] The processor is configured to execute the natural language generation method described in any of the first aspects.
[0058] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the natural language generation method described in any of the first aspects.
[0059] Fifthly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the natural language generation method described in any of the first aspects.
[0060] This invention provides a natural language generation method, apparatus, device, medium, and product. The method classifies multiple candidate fields in candidate text data using a preset discriminative neural network model to determine multiple target fields that match each preset language generation neural network model. Then, it generates corresponding candidate natural language sentences using each preset language generation neural network model and the matched target text data. These candidate natural language sentences are input into a preset coordinating neural network model to output the target natural language sentence with the highest overall score, thereby solving the problem of low-quality natural language generated by neural network-based natural language generation methods. Attached Figure Description
[0061] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0062] Figure 1 The diagram illustrates an application scenario according to some embodiments;
[0063] Figure 2 The diagram illustrates a flowchart of a natural language generation method according to some embodiments;
[0064] Figure 3 The diagram illustrates a flowchart of a natural language generation method according to some embodiments;
[0065] Figure 4 The diagram above exemplifies a model architecture diagram of a natural language generation method according to some embodiments;
[0066] Figure 5 The diagram above exemplifies the structure of a knowledge-based language generation model according to some embodiments;
[0067] Figure 6 The diagram above exemplarily illustrates a structural schematic of a natural language generation apparatus according to some embodiments;
[0068] Figure 7 The diagram illustrates a structural schematic of an electronic device according to some embodiments.
[0069] The accompanying drawings have illustrated specific embodiments of the invention, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the invention in any way, but rather to illustrate the concept of the invention to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0071] To make the objectives, implementation methods and advantages of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only some embodiments of this application, and not all embodiments.
[0072] Based on the exemplary embodiments described in this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the appended claims. Furthermore, although the disclosures in this application are presented by way of one or more exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete implementation on its own.
[0073] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0074] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities and do not necessarily imply a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be used interchangeably where appropriate, for example, to implement the application in a sequence other than those given in the embodiments illustrated or described herein.
[0075] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclusively include, for example, a product or device that includes a series of components is not necessarily limited to those that are explicitly listed, but may include other components that are not explicitly listed or that are inherent to such product or device.
[0076] As used in this application, the term "module" means any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code capable of performing the functions associated with that element.
[0077] To clearly understand the technical solution of this application, the solutions of existing technologies will first be described in detail. Currently, neural network-based generation methods for natural language sentences are typically implemented using a sequence-to-sequence generation approach. This method usually takes dialogue actions, user intent, and slot information as input and outputs natural language sentences that conform to the semantic scenario. Natural language sentences generated by neural network-based generation methods using different language generation models suffer from inaccurate semantic expression, resulting in low quality of natural language generated by current neural network-based natural language generation methods.
[0078] Therefore, addressing the issue of low-quality natural language generation by existing neural network-based natural language generation methods, the inventors discovered that a pre-trained discriminative neural network model could be used to classify the candidate fields required as input for each language generation model. These classified candidate fields would then be input into the matching language generation models, thereby improving the quality and efficiency of the natural language sentences generated by each model. Simultaneously, multiple language generation models could be integrated, and the natural language sentences generated by these models could be comprehensively scored to output the natural language sentence with the highest comprehensive score, thus improving the overall quality of the output natural language sentence.
[0079] Specifically, during user interaction, target user interaction information is acquired, and candidate text data is determined based on this information to generate candidate natural language statements. This candidate text data includes multiple candidate fields. Simultaneously, a pre-defined discriminative neural network model is used to classify these candidate fields, identifying multiple target fields that match each pre-defined language generation neural network model. These target fields form the target text data. Corresponding candidate natural language statements are then generated using each pre-defined language generation neural network model and the matched target text data. These candidate natural language statements are then input into a pre-defined coordinating neural network model to output the target natural language statement with the highest overall score. This solves the problem of low-quality natural language generated by neural network-based natural language generation methods.
[0080] Based on the above-mentioned inventive discovery, the inventor has proposed the technical solution of this application.
[0081] The following describes the application scenarios of the natural language generation method provided in the embodiments of the present invention. For example... Figure 1 As shown, 10 is an electronic device, 11 is the microphone in electronic device 10, and 20 is the user. Electronic device 10 can be a smart speaker, display device, in-vehicle device, or other device with voice interaction capabilities.
[0082] Electronic device 10 is equipped with a sound acquisition device, such as microphone 11, which can be used to receive the user's voice. Electronic device 10 can accurately recognize the user's voice and convert it into target user interaction information.
[0083] When electronic device 10 receives a user's voice through microphone 11, it converts it into target user interaction information. Based on this information, it determines candidate text data for generating candidate natural language statements. This candidate text data includes multiple candidate fields. Simultaneously, electronic device 10 uses a preset discriminative neural network model to classify these fields, identifying multiple target fields that match each preset language generation neural network model. These target fields form target text data. Electronic device 10 then uses each preset language generation neural network model and the matched target text data to generate corresponding candidate natural language statements. These candidate statements are input into a preset coordinating neural network model to output the target natural language statement with the highest overall score. The output of the target natural language statement can be in the form of voice or text. After outputting the target natural language statement, the user can provide a further voice response based on it. For example, if a user says, "I want to watch a movie," the electronic device 10 can recognize it and convert it into corresponding target user interaction information. Then, based on the target user interaction information, it generates a target natural language statement: "What kind of movie would you like to watch?" The user can then reply with "I want to watch a certain type of movie," etc., to achieve flexible interaction with the user.
[0084] The embodiments of the present invention will now be described with reference to the accompanying drawings.
[0085] Figure 2 The diagram illustrates a flowchart of a natural language generation method according to some embodiments, such as... Figure 2 As shown, in this embodiment, the execution subject of this invention is a natural language generation device, which can be integrated into an electronic device, such as a smart speaker, display device, or in-vehicle device, that has voice interaction capabilities. The natural language generation method provided in this embodiment includes the following steps:
[0086] Step S101: Obtain target user interaction information.
[0087] In some embodiments, when a user needs to interact with an electronic device, such as wanting to watch a video, they can speak to the electronic device to say what video they want to watch.
[0088] For example, a user could say, "Please play a movie," where "movie" is the movie's name. The electronic device, after recognizing the user's voice, would then convert the speech into interactive information for the target user.
[0089] Step S102: Determine the candidate text data on which the generated candidate natural language statements depend based on the target user interaction information. The candidate text data includes multiple candidate fields.
[0090] In some embodiments, due to the complexity of speech, target user interaction information generally contains multiple words, such as verbs including "please play," "watch," and "switch," and nouns including movie titles and music titles. Therefore, to determine the candidate text data upon which the candidate natural language statements depend based on the target user interaction information, key information in the target user interaction information can be extracted through semantic recognition and word segmentation processing, thereby generating the candidate text data upon which the candidate natural language statements depend.
[0091] The candidate text data includes multiple candidate fields, such as user intent search results, entities in a knowledge base associated with the user intent, user profile information, dialogue actions, and slot information. User intent can be determined from the target user's interaction information.
[0092] For example, if a user says they want to listen to a certain piece of music, where "a" is the name of the music, then the user's intent is to listen to that specific music. Based on this user intent, the corresponding music stored in the database can be searched, which is the user intent search result. The music genre, artist, etc., corresponding to that music are entities in the knowledge base associated with the user intent. User profile information consists of the user's common attributes, such as favorite music genres and artists. The dialogue action is the action that the electronic device needs to perform; in this embodiment, it is to search for and play a specific piece of music. Slot information is related information about that music. If the user adds descriptions to the music, such as who performs it or when it was released, these descriptions constitute slot information.
[0093] In some embodiments, existing knowledge-based language generation typically only covers two categories: film and music, and the knowledge is derived from only a few entity attributes, resulting in limited coverage. In this embodiment, the knowledge base can include multiple types of knowledge bases, such as film, music, sports, and technology knowledge bases, thereby improving the richness of the generated natural language statements and adapting to flexible and varied language scenarios.
[0094] Step S103: A preset discriminative neural network model is used to classify multiple candidate fields in the candidate text data to determine multiple target fields that match each preset language generation neural network model. The multiple target fields form the target text data.
[0095] In some embodiments, the discriminative neural network model can be pre-trained to convergence, enabling it to accurately classify multiple candidate fields in the candidate text data. This allows the classified candidate fields to be matched with each pre-defined language generation neural network model.
[0096] Step S104: Generate corresponding candidate natural language sentences using each preset language generation neural network model and the matched target text data.
[0097] In some embodiments, the language generation neural network model may include a knowledge-based language generation model, a dialogue action-based language generation model, and a search condition-based language generation model.
[0098] Step S105: Input multiple candidate natural language sentences into a preset coordinating neural network model to output the target natural language sentence with the highest comprehensive score.
[0099] In some embodiments, a coordinated neural network model is used to comprehensively score multiple candidate natural language statements. The scoring criteria may include the perplexity of the candidate natural language statements, whether the semantics of the candidate natural language statements meet the requirements, etc. This results in the output of the target natural language statement with the highest comprehensive score among the multiple candidate natural language statements, thereby improving the quality of the output natural language statement.
[0100] This invention provides a natural language generation method. This method uses a preset discriminative neural network model to classify multiple candidate fields in candidate text data to determine multiple target fields that match each preset language generation neural network model. Then, it uses each preset language generation neural network model and the matched target text data to generate corresponding candidate natural language sentences. These candidate natural language sentences are then input into a preset coordinating neural network model to output the target natural language sentence with the highest overall score. This solves the problem of low-quality natural language generated by neural network-based natural language generation methods.
[0101] Figure 3 The diagram illustrates a flowchart of a natural language generation method according to some embodiments, such as... Figure 3 As shown, the natural language generation method provided in this embodiment is based on the natural language generation method provided in the previous embodiment of the present invention, and further refines several steps. Therefore, the natural language generation method provided in this embodiment includes the following steps.
[0102] Step S201: Obtain target user interaction information.
[0103] In some embodiments, step 201 is implemented in a similar manner to step 101 in the previous embodiment of the present invention, and will not be described in detail here.
[0104] Step S202: Determine the candidate text data on which the candidate natural language statement depends based on the target user interaction information. The candidate text data includes multiple candidate fields.
[0105] In some embodiments, step 202 is implemented in a similar manner to step 102 in the previous embodiment of the present invention, and will not be described in detail here.
[0106] Step S203: A preset discriminative neural network model is used to classify multiple candidate fields in the candidate text data to determine multiple target fields that match each preset language generation neural network model. The multiple target fields form the target text data.
[0107] In some embodiments, step 203 is implemented in a similar manner to step 103 in the previous embodiment of the present invention, and will not be described in detail here.
[0108] It should be noted that language generation neural network models include: knowledge-based language generation models, dialogue action-based language generation models, and search condition-based language generation models.
[0109] Step S204: Input the target text data of each type into the matching language generation neural network model.
[0110] In some embodiments, the target text data required by each language generation neural network model is different. For example, a knowledge-based language generation model requires user intent search results, entities in a knowledge base associated with the user intent, user profile information, dialogue actions, and slot information. However, user intent search results are not currently relevant in the field of natural language sentence generation. A dialogue action-based language generation model requires dialogue actions, semantic information of user interaction, etc., while a search condition-based language generation model requires slot information and entities in a knowledge base associated with the user intent.
[0111] Step S205: Perform natural language generation processing on the target text data through each matched language generation neural network model, and output the corresponding candidate natural language sentences.
[0112] In some embodiments, each language generation neural network model generates candidate natural language sentences, and the generated candidate natural language sentences are different due to the different language generation neural network models.
[0113] Step S206: Input multiple candidate natural language statements into a preset coordinating neural network model.
[0114] A fully connected neural network can be used to coordinate neural network models.
[0115] In some embodiments, quality checks can be performed on the candidate natural language statements before inputting them into a pre-defined coordinating neural network model. Currently, the most common quality checks are performed offline by manual verification, which cannot provide online verification and is inefficient.
[0116] This embodiment provides two quality inspection methods. The first quality inspection method is as follows:
[0117] Multiple candidate natural language statements are input into a pre-defined language model to determine the perplexity of each candidate natural language statement.
[0118] Determine whether each level of perplexity is less than a preset perplexity threshold.
[0119] If the perplexity is determined to be less than the preset perplexity threshold, then the candidate natural language statement corresponding to that perplexity is retained.
[0120] If the perplexity level is determined to be greater than or equal to the preset perplexity threshold, then the candidate natural language statement corresponding to that perplexity level is deleted.
[0121] The language model can employ a bidirectional LSTM (long-short term memory) model, which is used to calculate the perplexity evaluation of candidate natural language sentences to assess their quality. This language model is a pre-trained Chinese model based on whole-word masking technology.
[0122] In the specific evaluation, each character / word in the sentence is covered in turn, and the probability of the character / word appearing in the given context is calculated. Finally, the perplexity of the sentence is obtained. A perplexity threshold is set in advance. If the perplexity of the candidate natural language sentence is lower than the perplexity threshold, the candidate natural language sentence is considered to be of good quality and can be retained. Otherwise, the candidate natural language sentence is considered to be of poor quality and needs to be deleted.
[0123] The second quality inspection method is as follows:
[0124] Determine whether the number of identical words in each candidate natural language statement is greater than or equal to a preset threshold.
[0125] If the number of identical words is less than a preset threshold, the corresponding candidate natural language statement is retained.
[0126] If the number of identical words is determined to be greater than or equal to the preset detection threshold, the corresponding candidate natural language statement is deleted.
[0127] The second quality detection method can use a word segmentation model to perform quality detection without human intervention. For example, the word "movie" should not normally appear more than 4 times in a candidate natural language sentence. If "movie" appears more than 4 times, the candidate natural language sentence can be determined to be of poor quality and deleted. Conversely, if it appears more than 4 times, the candidate natural language sentence can be determined to be of good quality and retained.
[0128] At the same time, the punctuation at the end of the candidate natural language statement and the continuous occurrence of letters, numbers and Chinese characters can also be detected and judged. If the number of consecutive letters, numbers and Chinese characters is too high or the punctuation at the end does not meet the requirements, the candidate natural language statement is determined to be of poor quality.
[0129] Step S207: A coordinated neural network model is used to comprehensively score multiple candidate natural language sentences according to a preset evaluation strategy, and the target natural language sentence with the highest comprehensive score is output.
[0130] In some embodiments, the evaluation strategy may include calculating the perplexity of each candidate natural language statement and performing semantic analysis on each candidate natural language statement, as follows:
[0131] A coordinated neural network model is used to calculate the perplexity of each candidate natural language statement, and semantic analysis is performed on each candidate natural language statement to obtain the semantic analysis results.
[0132] The comprehensive score of each candidate natural language statement is determined based on the perplexity and semantic analysis results.
[0133] To better illustrate the architecture of the natural language generation method in this embodiment of the invention, the following will be combined with... Figure 4 and Figure 5 Provide a detailed description.
[0134] like Figure 4 As shown, the candidate text data determined based on the target user interaction information will be classified by a discriminative neural network model. The target text data generated after classification will then be input into different language generation neural network models, namely, the language generation model based on dialogue actions, the language generation model based on knowledge, and the language generation model based on search conditions, to output different candidate natural language sentences. Finally, the coordination neural network model will comprehensively score each candidate natural language sentence and output the target natural language sentence with the highest comprehensive score.
[0135] The internal structure of knowledge-based language generation models, such as Figure 5As shown, a knowledge-based language generation model includes an encoder, a knowledge selector, a decoder, a coordinator, and a word generator. The word generator includes a vocabulary generator and a copy generator. The target text data matched with the knowledge-based language generation model is called knowledge-based target text data. Knowledge-based target text data includes several target fields: user intent search results, entities in the knowledge base associated with the user intent, user profile information, dialogue actions, and slot information. In the diagram, K1, K2, K3, and D refer to entities in the knowledge base associated with the user intent. K1, K2, and K3 are generally represented in the form of knowledge sequences, and D is represented in the form of a knowledge domain, which is the domain category to which the entity in the knowledge base belongs. U represents user profile information, and X represents a question sequence, which generally includes slot information, dialogue actions, and user intent search results.
[0136] The specific process of generating corresponding candidate natural language sentences using a knowledge-based language generation model and knowledge-based target text data is as follows:
[0137] An encoder is used to encode each knowledge-based target field to generate corresponding hidden state representation data.
[0138] A knowledge selector is used to determine the directly associated entities in the knowledge base that are related to the user's intent based on the implicit state representation data.
[0139] A decoder is used to decode knowledge-based target text data and directly associated entities, excluding entities in the knowledge base associated with user intent, to form decoded text data.
[0140] Based on the decoded text data and the word generator, matching candidate natural language sentences are generated.
[0141] In some embodiments, latent state representation data is data that has category information but no specific data information, such as an entity in a knowledge base associated with a user intent. It can be known that the corresponding latent state representation data is an entity, but it is not known which specific type it is.
[0142] A knowledge selector is used to determine the directly related entities in the knowledge base associated with the user's intent based on the implicit state representation data. The directly related entities represent the most relevant entities. For example, if a user says they want to watch a movie, the related entities of a movie may include movie name, director, producer, actors, music, etc. The most relevant entity is the movie name. If a user says they want to watch a movie by a certain director, then the most relevant entities are the movie name and the director.
[0143] Meanwhile, the knowledge-based language generation model in this embodiment can achieve better natural language sentence generation results through pre-training.
[0144] The training process is as follows:
[0145] Obtain training samples, which include: historical user intent search results, entities in the knowledge base associated with historical user intent, historical dialogue actions, historical user profile information, and historical slot information.
[0146] The training samples are input into a pre-defined knowledge-based language generation model to train the model.
[0147] The preset knowledge-based language generation model is judged to meet the convergence condition by using a preset knowledge selection loss function and a preset generation response loss function.
[0148] When the sum of the preset knowledge selection loss function and the preset generation response loss function reaches its minimum, the preset knowledge-based language generation model is determined to satisfy the convergence condition.
[0149] The pre-defined knowledge-based language generation model that meets the convergence condition is selected as the knowledge-based language generation model that has been trained to convergence.
[0150] The sum of the preset selection knowledge loss function and the preset generation response loss function is:
[0151] L(θ)=L s (θ)+L G (θ)
[0152] The knowledge loss function is chosen as follows:
[0153] L s (θ)=-logp(K l |X,D)
[0154] Among them, K l X is the sequence of knowledge to be selected, X is the sequence of questions, and D is the knowledge domain.
[0155] The loss function for generating the response is:
[0156]
[0157] Where N is the total number of natural language statements generated to reply to users, and y i Let X be the i-th word in the generated natural language sentence, and K be the question sequence. i It is the selected knowledge sequence, and U is the user profile information.
[0158] Simultaneously, when generating matching candidate natural language sentences, the coordinator can determine the word generator that matches the decoded text data, thereby converting the decoded text data into candidate natural language sentences through the matching word generator. The specific steps are as follows:
[0159] The coordinator determines, according to the decoding order, whether the word generator or the copy generator matches the current text data in the decoded text data. The decoding order is the order in which the decoder generates the decoded text data.
[0160] The decoding order can be preset or randomized. At each time step of decoding, the coordinator will select from multiple word generators to determine which word generator will generate the next word.
[0161] If the match is determined to be a word generator, then the word generator is used to generate corresponding words based on the user intent search results, user profile information, dialogue actions, and slot information.
[0162] If the match is determined to be a copy generator, then the copy generator is used to generate corresponding words based on the user intent search results, directly associated entities, dialogue actions, and slot information.
[0163] The copy generator is typically generated by copying a word from user intent search results, directly associated entities, dialogue actions, and slot information.
[0164] Once all the decoded text data has generated corresponding words, semantic recognition processing is performed on all the generated words to concatenate them into candidate natural language sentences.
[0165] Figure 6 The diagram illustrates, for example, a structural schematic of a natural language generation apparatus according to some embodiments, such as... Figure 6 As shown, in this embodiment, the natural language generation device 300 includes:
[0166] The acquisition module 301 is used to acquire target user interaction information.
[0167] The determination module 302 is used to determine the candidate text data on which the generation of candidate natural language statements depends based on the target user interaction information. The candidate text data includes multiple candidate fields.
[0168] The classification module 303 is used to classify multiple candidate fields in the candidate text data using a preset discriminative neural network model, so as to determine multiple target fields that match each preset language generation neural network model, and the multiple target fields form target text data.
[0169] The generation module 304 is used to generate corresponding candidate natural language sentences using preset language generation neural network models and matched target text data.
[0170] The output module 305 is used to input multiple candidate natural language sentences into a preset coordinating neural network model to output the target natural language sentence with the highest comprehensive score.
[0171] The natural language generation device provided in this embodiment can perform... Figure 2 The technical solution of the method embodiment shown has the same implementation principle and technical effect as... Figure 2 The methods and embodiments shown are similar and will not be described in detail here.
[0172] Meanwhile, the natural language generation device provided by the present invention further refines the natural language generation device 300 based on the natural language generation device provided in the previous embodiment.
[0173] In some embodiments, the language generation neural network model includes: a knowledge-based language generation model, a dialogue action-based language generation model, and a search condition-based language generation model.
[0174] Module 304 is specifically used for:
[0175] The target text data of various types is input into the matching language generation neural network model. The matching language generation neural network model performs natural language generation processing on the target text data and outputs the corresponding candidate natural language sentences.
[0176] In some embodiments, a knowledge-based language generation model includes an encoder, a knowledge selector, a decoder, and a word generator. The target text data matched with the knowledge-based language generation model is knowledge-based target text data. Knowledge-based target text data includes various target fields such as: user intent search results, entities in a knowledge base associated with the user intent, user profile information, dialogue actions, and slot information.
[0177] When generating candidate natural language sentences using a knowledge-based language generation model and knowledge-based target text data, the generation module 304 is specifically used for:
[0178] An encoder is used to encode each knowledge-based target field to generate corresponding latent state representation data. A knowledge selector is used to determine the directly related entities in the knowledge base associated with the user intent based on each latent state representation data. A decoder is used to decode the knowledge-based target text data other than the entities in the knowledge base associated with the user intent, as well as the directly related entities, to form decoded text data. Based on the decoded text data and a word generator, matching candidate natural language sentences are generated.
[0179] In some embodiments, the knowledge-based language generation model also includes a coordinator. The word generator includes a vocabulary generator and a copy generator.
[0180] When generating candidate natural language sentences based on the decoded text data and the word generator, the generation module 304 is specifically used for:
[0181] A coordinator determines, according to the decoding order, whether the current text data in the decoded text data is matched by a vocabulary generator or a copy generator. The decoding order is the order in which the decoder generates the decoded text data. If the match is determined to be a vocabulary generator, the vocabulary generator generates corresponding words based on user intent search results, user profile information, dialogue actions, and slot information. If the match is determined to be a copy generator, the copy generator generates corresponding words based on user intent search results, directly related entities, dialogue actions, and slot information. Semantic recognition processing is performed on all generated words to concatenate them into candidate natural language sentences.
[0182] In some embodiments, the output module 305 is specifically used for:
[0183] Multiple candidate natural language statements are input into a pre-defined coordinating neural network model. The coordinating neural network model performs a comprehensive evaluation of the multiple candidate natural language statements according to a pre-defined evaluation strategy, and outputs the target natural language statement with the highest comprehensive score.
[0184] In some embodiments, when the output module 305 performs a comprehensive evaluation of multiple candidate natural language statements using a coordinated neural network model according to a preset evaluation strategy, it is specifically used for:
[0185] A coordinated neural network model is used to calculate the perplexity of each candidate natural language statement, and semantic analysis is performed on each candidate natural language statement to obtain the semantic analysis results. Based on the perplexity and semantic analysis results, a comprehensive score for each candidate natural language statement is determined.
[0186] In some embodiments, the natural language generation apparatus 300 further includes:
[0187] The first quality inspection module is used to input multiple candidate natural language statements into a preset language model to determine the perplexity of each candidate natural language statement. It then determines whether each perplexity is less than a preset perplexity threshold. If the perplexity is less than the preset perplexity threshold, the candidate natural language statement corresponding to that perplexity is retained. If the perplexity is greater than or equal to the preset perplexity threshold, the candidate natural language statement corresponding to that perplexity is deleted.
[0188] In some embodiments, the natural language generation apparatus 300 further includes:
[0189] The second quality inspection module determines whether the number of identical words in each candidate natural language statement is greater than or equal to a preset threshold. If the number of identical words is less than the preset threshold, the corresponding candidate natural language statement is retained. If the number of identical words is greater than or equal to the preset detection threshold, the corresponding candidate natural language statement is deleted.
[0190] In some embodiments, the natural language generation apparatus 300 further includes:
[0191] The training module is used to acquire training samples, which include: historical user intent search results, entities in the knowledge base associated with historical user intents, historical dialogue actions, historical user profile information, and historical slot information. These training samples are input into a pre-defined knowledge-based language generation model for training. A pre-defined knowledge selection loss function and a pre-defined generation response loss function are used to determine whether the pre-defined knowledge-based language generation model meets the convergence condition. When the sum of the pre-defined knowledge selection loss function and the pre-defined generation response loss function reaches its minimum, the pre-defined knowledge-based language generation model is considered to have met the convergence condition. The pre-defined knowledge-based language generation model that meets the convergence condition is defined as the knowledge-based language generation model that has been trained to convergence.
[0192] The natural language generation device provided in this embodiment can perform... Figures 2-5 The technical solution of the method embodiment shown has the same implementation principle and technical effect as... Figures 2-5 The methods and embodiments shown are similar and will not be described in detail here.
[0193] According to embodiments of the present invention, the present invention also provides an electronic device, a computer-readable storage medium, and a computer program product.
[0194] like Figure 7 As shown, Figure 7 The present invention exemplifies a schematic diagram of an electronic device according to some embodiments. The electronic device is intended in various forms suitable for use as a server, such as a digital computer, a laptop computer, a personal digital assistant, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0195] like Figure 7As shown, the electronic device includes a processor 401 and a memory 402. The various components are interconnected via different buses and can be mounted on a common motherboard or installed in other ways as needed. The processor can process instructions executed within the electronic device.
[0196] The memory 402 is the non-transitory computer-readable storage medium provided by this invention. The memory stores instructions executable by at least one processor to cause the at least one processor to perform the natural language generation method provided by this invention. The non-transitory computer-readable storage medium of this invention stores computer instructions for causing a computer to perform the natural language generation method provided by this invention.
[0197] Memory 402, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the natural language generation method in this embodiment of the invention (e.g., appendix). Figure 6 The acquisition module 301, determination module 302, classification module 303, generation module 304, and output module 305 are shown. The processor 401 executes various server functions and data processing by running non-transient software programs, instructions, and modules stored in the memory 402, thereby implementing the natural language generation method in the above method embodiments.
[0198] In addition, this embodiment also provides a computer product, which, when the instructions in the computer product are executed by the processor of an electronic device, enables the electronic device to execute the natural language generation methods of the above embodiments.
[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0200] For ease of explanation, the above description has been provided in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Various modifications and variations can be obtained based on the above teachings. The selection and description of the above embodiments are for the purpose of better explaining the principles and practical applications, thereby enabling those skilled in the art to better utilize the embodiments and various different variations of embodiments suitable for specific application considerations.
Claims
1. A natural language generation method, characterized by, The method comprises the following steps: acquiring target user interaction information; determining candidate text data relied on for generating a candidate natural language sentence according to the target user interaction information, the candidate text data comprising a plurality of candidate fields; the plurality of candidate fields comprising a user intent search result, an entity in a knowledge base associated with the user intent, user portrait information, a dialogue action, and slot information; classifying the plurality of candidate fields in the candidate text data using a preset discriminant neural network model to determine a plurality of target fields matched with each preset language generation neural network model, the plurality of target fields forming target text data matched with the corresponding preset language generation network model; the language generation neural network model comprising a knowledge-based language generation model, a dialogue action-based language generation model, and a search condition-based language generation model; generating a corresponding candidate natural language sentence using each preset language generation neural network model and the matched target text data; inputting the plurality of candidate natural language sentences into a preset language model to determine a perplexity corresponding to each candidate natural language sentence; determining whether each perplexity is less than a preset perplexity threshold; if it is determined that the perplexity is less than the preset perplexity threshold, retaining the candidate natural language sentence corresponding to the perplexity; if it is determined that the perplexity is greater than or equal to the preset perplexity threshold, deleting the candidate natural language sentence corresponding to the perplexity; inputting the plurality of candidate natural language sentences retained after the perplexity screening into a preset coordination neural network model, calculating a perplexity corresponding to each candidate natural language sentence using the coordination neural network model, and performing semantic analysis on each candidate natural language sentence to obtain a semantic analysis result; determining a comprehensive score of each candidate natural language sentence according to the perplexity and the semantic analysis result corresponding to each candidate natural language sentence to output a target natural language sentence with the highest comprehensive score.
2. The method of claim 1, wherein: the step of generating a corresponding candidate natural language sentence using each preset language generation neural network model and the matched target text data comprises: inputting each type of target text data into a matched language generation neural network model; performing natural language generation processing on the target text data by each matched language generation neural network model and outputting a corresponding candidate natural language sentence.
3. The method of claim 2, wherein, The knowledge-based language generation model comprises an encoder, a knowledge selector, a decoder, and a word generator; the target text data matched with the knowledge-based language generation model is knowledge-based target text data; the knowledge-based target text data comprises a plurality of target fields including a user intent search result, an entity in a knowledge base associated with the user intent, user portrait information, a dialogue action, and slot information; the step of generating a corresponding candidate natural language sentence using the knowledge-based language generation model and the knowledge-based target text data comprises: performing encoding processing on each knowledge-based target field using the encoder to generate corresponding hidden state representation data; determining, by the knowledge selector, a direct association entity from the entities in the knowledge base associated with the user intent according to the respective hidden state representation data; decoding, by the decoder, the knowledge-based target text data and the direct association entity other than the entities in the knowledge base associated with the user intent to form decoded text data; generating, by the word generator, a matched candidate natural language sentence according to the decoded text data.
4. The method of claim 3, wherein, The knowledge-based language generation model further comprises a coordinator, and the word generator comprises a word table generator and a copy generator. The generation of the matched candidate natural language sentence according to the decoded text data and the word generator comprises: determining, by the coordinator, whether the word table generator or the copy generator matches the current text data in the decoded text data according to a decoding order; the decoding order is the order in which the decoder generates the decoded text data; if it is determined that the word table generator matches, generating, by the word table generator, corresponding words according to the user intent search result, the user portrait information, the dialogue action and the slot information; if it is determined that the copy generator matches, generating, by the copy generator, corresponding words according to the user intent search result, the direct association entity, the dialogue action and the slot information; performing semantic recognition processing on all generated words to splice all the words into a candidate natural language sentence.
5. The method of claim 1, wherein, Before inputting the plurality of candidate natural language sentences into the preset coordination neural network model, the method further comprises: determining whether the number of identical words in each candidate natural language sentence is greater than or equal to a preset number threshold; if it is determined that the number of identical words is less than the preset number threshold, retaining the corresponding candidate natural language sentence; if it is determined that the number of identical words is greater than or equal to the preset number threshold, deleting the corresponding candidate natural language sentence.
6. The method of claim 3, wherein, Before generating the corresponding candidate natural language sentence by using the knowledge-based language generation model and the knowledge-based target text data, the method further comprises: obtaining training samples, wherein the training samples comprise historical user intent search results, historical entities in the knowledge base associated with the user intent, historical dialogue actions, historical user portrait information and historical slot information; inputting the training samples into a preset knowledge-based language generation model to train the preset knowledge-based language generation model; determining whether the preset knowledge-based language generation model satisfies a convergence condition by using a preset selection knowledge loss function and a preset generation reply loss function; when the sum of the preset selection knowledge loss function and the preset generation reply loss function reaches a minimum value, it is determined that the preset knowledge-based language generation model satisfies the convergence condition; determining the preset knowledge-based language generation model that satisfies the convergence condition as a trained knowledge-based language generation model that converges.
7. A natural language generation apparatus, characterized by: comprises: an acquisition module configured to acquire target user interaction information; The determining module is configured to determine candidate text data on which the candidate natural language sentences are generated according to target user interaction information, wherein the candidate text data comprises a plurality of candidate fields; and the plurality of candidate fields comprise user intent search results, entities in a knowledge base associated with the user intent, user portrait information, dialogue actions and slot information. The classification module is configured to classify the plurality of candidate fields in the candidate text data by using a preset discriminant neural network model, so as to determine a plurality of target fields matched with each preset language generation neural network model, and the plurality of target fields form target text data matched with the corresponding preset language generation network model. The language generation neural network model comprises a knowledge-based language generation model, a dialogue action-based language generation model and a search condition-based language generation model. The generation module is configured to generate corresponding candidate natural language sentences by using each preset language generation neural network model and the matched target text data. The output module is configured to input the plurality of candidate natural language sentences into a preset coordination neural network model, so as to output a target natural language sentence with the highest comprehensive score. The first quality detection module is configured to input the plurality of candidate natural language sentences into a preset language model, so as to determine a perplexity corresponding to each candidate natural language sentence; determine whether the perplexity is less than a preset perplexity threshold; if the perplexity is determined to be less than the preset perplexity threshold, retain the candidate natural language sentence corresponding to the perplexity; and if the perplexity is determined to be greater than or equal to the preset perplexity threshold, delete the candidate natural language sentence corresponding to the perplexity. The output module is specifically configured to input the plurality of candidate natural language sentences retained after the perplexity screening into the preset coordination neural network model, calculate a perplexity corresponding to each candidate natural language sentence by using the coordination neural network model, and perform semantic analysis on each candidate natural language sentence to obtain a semantic analysis result; determine a comprehensive score of each candidate natural language sentence according to the perplexity corresponding to the candidate natural language sentence and the semantic analysis result, and output a target natural language sentence with the highest comprehensive score.
8. An electronic device, comprising: Comprise: a memory, a processor; a memory; a memory for storing processor-executable instructions; The processor is configured to execute the natural language generation method of any one of claims 1 to 6 by the processor.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by the processor to implement the natural language generation method of any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the natural language generation method of any one of claims 1 to 6.
Citation Information
Patent Citations
Man-machine question and answering method, device, equipment and storage medium
CN109920414A
Text processing method and device
CN111291172A
Man-machine dialogue method and system, computer equipment and medium
CN112100353A
Open domain dialogue generation method and model with strong generalization knowledge selection
CN112463935A
Conversational language and informational response systems and methods
US20190197106A1