Natural language answer generation method and device based on multi-level copying and perception loss, and medium

By employing multi-level replication and perceptual loss methods, the problems of meaningless responses and question-answer mismatch in intelligent question-answering systems are solved, generating natural language answers that conform to grammar and context, thereby improving the answer quality of the question-answering system.

CN116975235BActive Publication Date: 2026-05-05NANJING XIAOZHUANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING XIAOZHUANG UNIV
Filing Date
2023-07-31
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing intelligent question-answering systems are prone to producing meaningless responses and question-answer mismatches when generating natural language answers, and are unable to accurately generate natural language answers that conform to grammar and context.

Method used

We employ a method based on multi-level replication and perceptual loss. By replicating the relevant semantic units in the question and triples through the decoder, we combine the vocabulary to predict commonly used words, and optimize the answer generation by using question perceptual loss and answer perceptual loss to ensure that the answer conforms to grammar and context.

Benefits of technology

The generated natural language answers can match the input question, conform to grammar and context, lay the theoretical foundation for complex multi-turn dialogues, and improve the answer quality of intelligent question answering systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116975235B_ABST
    Figure CN116975235B_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, and medium for generating natural language answers based on multi-level replication and perceptual loss. The method includes: inputting pre-acquired natural language questions and triples into corresponding encoding layers to obtain vector representations of the natural language questions and triples. This method, apparatus, and medium, based on multi-level replication and perceptual loss, focuses on natural language answer generation in intelligent QA systems. Addressing the issues of existing methods generating meaningless responses and question-answer mismatches, it proposes a decoder based on multi-level replication and prediction mechanisms. This decoder simultaneously replicates relevant semantic units from the question and triples and predicts commonly used words from a vocabulary list, thereby generating a grammatically and context-compliant natural language answer sequence according to user needs. This lays a theoretical foundation for future complex multi-turn dialogues.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method, apparatus, and medium for generating natural language answers based on multi-level replication and perceptual loss, belonging to the field of natural language processing technology. Background Technology

[0002] The rapidly developing field of artificial intelligence (AI) technology has gradually become a hot topic of social concern. As an important branch of AI technology, intelligent question answering (QA) systems have become a key research topic in academia and industry in recent years due to their ability to more accurately capture user intent, understand users' natural language questions, and return concise and accurate answers.

[0003] Most existing QA systems infer the correct entity answers. However, in real-world environments, users prefer to answer natural language questions in a more natural way. Furthermore, existing methods suffer from generating meaningless responses, question-answer mismatches, and mismatches between the generated natural language answers and the input questions.

[0004] Therefore, in order to solve the above technical problems, there is an urgent need for a natural language answer generation method, device and medium based on multi-level replication and perceptual loss. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a natural language answer generation method, apparatus, and medium based on multi-level replication and perceptual loss. Addressing the issues of meaningless responses and question-answer mismatches generated by existing methods, this invention proposes a decoder based on multi-level replication and prediction mechanisms. This decoder simultaneously replicates relevant semantic units in the question and triples, predicts commonly used words from a vocabulary, and ultimately generates grammatically correct natural language answers. Furthermore, by combining question-perceptual loss and answer-perceptual loss, it generates a sequence of grammatically and context-compliant natural language answers according to user needs, laying a theoretical foundation for future complex multi-turn dialogues.

[0006] To achieve the above objectives, the present invention is implemented using the following technical solution:

[0007] In a first aspect, the present invention provides a natural language answer generation method based on multi-level replication and perceptual loss, comprising:

[0008] Based on the pre-acquired natural language questions and triples, they are input into the corresponding coding layers to obtain vector representations of the natural language questions and triples;

[0009] Based on the obtained vector representation, and using a pre-designed decoder, the set of semantic units and the set of triples of the problem are obtained by copying.

[0010] Based on a pre-acquired vocabulary list, and using a prediction mechanism, common words in the natural language answer sequence are generated. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0011] Based on the obtained semantic unit set, entity set, and commonly used words, a complete natural language answer sequence is generated;

[0012] Based on the obtained natural language answer sequence, and using answer perception loss, the generation of natural language answer sequence is optimized to generate a grammatically correct natural language answer sequence;

[0013] Based on the obtained grammatically correct natural language answer sequence, and using question-aware loss, a target answer sequence that fits the context and matches the question is generated;

[0014] The pre-designed decoder includes a problem replication mechanism module, a triple replication mechanism module, and a prediction mechanism module.

[0015] Furthermore, the method for obtaining the set of semantic units includes:

[0016] Based on the obtained vector representation of the natural language question, relevant semantic units are copied from the source question using a question copying mechanism in a pre-designed decoder;

[0017] Based on the semantic units related to replication, they are treated as a set of semantic units.

[0018] Furthermore, the method for obtaining the entity set includes:

[0019] Based on the vector representation of the obtained triples, the relevant entities are copied from the triples according to the triple copying mechanism in the pre-designed decoder;

[0020] The related entities based on the replication are treated as an entity set.

[0021] Furthermore, the method for generating commonly used words in the natural language answer sequence includes:

[0022] The decoder-based prediction mechanism module predicts frequently used words from a pre-acquired vocabulary, determines whether the scores of the predicted frequently used words meet a preset threshold, and selects the frequently used words whose scores meet the preset threshold as frequently used words in the natural language answer sequence.

[0023] The decoder's score function for predicting frequently used words from the vocabulary based on a prediction mechanism is as follows:

[0024]

[0025] The pre-acquired vocabulary includes , , Indicates any word outside the dictionary. A set of semantic units representing a problem. Represents the set of entities that form a triple. This represents the score function by which the prediction mechanism predicts frequently used words from the vocabulary. The prediction mechanism for frequently used words, This represents the sequence of natural language answers generated at time t. This represents the word vectors of the output layer. The weight matrix represents the prediction mechanism. and They represent the time steps respectively. Sometimes selectively from the problem and triplet facts The context vector read from short-term memory.

[0026] Furthermore, the probability of the generated complete natural answer sequence must meet a preset threshold, where,

[0027] The probabilistic language model representation of the generated natural language answer sequence is as follows:

[0028]

[0029] In the formula, Let P represent the sequence of natural language answers generated at time t-1, where P is the probability. To generate a complete sequence of natural language answers, , and These represent the problem's replication mechanism, the triple replication mechanism, and the prediction mechanism for common words, respectively. This is the hidden state of the decoder. This is the vector representation of the entire natural language problem. Let t be the vector representation of the fact triple, and t be the time step. This represents a probabilistic language model that selects different mechanisms. This represents the context vector.

[0030] Furthermore, the method for generating the grammatically correct natural language answer sequence includes:

[0031] Given the natural question Q, the fact triple T, and the target answer sequence Train a probabilistic language model of natural answer sequences;

[0032] For the natural language answer sequence generated by the probabilistic language model of natural answer sequence, the negative log-likelihood is optimized through the answer-aware function to generate a grammatically correct natural language answer sequence.

[0033] The answer perception loss function is as follows:

[0034] ;

[0035] In the formula, Perceived loss for the answer As a regularization factor, yes The hyperparameters, W, are the target answer sequence. This is the vector representation of the entire natural language problem. Let t be the vector representation of the fact triple, and t be the time step.

[0036] Furthermore, the method for generating the target answer sequence that conforms to the context and matches the question includes:

[0037] Based on the generated grammatically correct natural language answer sequence, a target answer subsequence corresponding to the question type words is generated according to the input question;

[0038] The question-aware loss function generates answer words that match the question type words, where the cross-entropy between the question type words and the answer words must be minimized.

[0039] The generation of natural language answer sequences is optimized based on answer words, generating target answer sequences that conform to the context and match the question.

[0040] The problem-aware loss function is expressed by the following equation:

[0041]

[0042] In the formula, Perceive loss for the problem, It is a set of question type words. It is a set of generated answer words. Indicates the type of question With the generated answer words Cross-entropy between them.

[0043] Secondly, the present invention provides a natural language answer generation device based on multi-level replication and perceptual loss, the device comprising:

[0044] The first data processing module is used to input the pre-acquired natural language questions and triples into the corresponding coding layers to obtain vector representations of the natural language questions and triples.

[0045] The second data processing module is used to obtain the set of semantic units and the set of entities of triples of the problem by copying the obtained vector representation based on a pre-designed decoder.

[0046] The third data processing module is used to generate common words in the natural language answer sequence based on a pre-acquired vocabulary and a prediction mechanism. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0047] The fourth data processing module is used to generate a complete natural language answer sequence based on the obtained semantic unit set, entity set, and commonly used words.

[0048] The fifth data processing module is used to optimize the generation of natural language answer sequences based on the obtained natural language answer sequence and answer perception loss, so as to generate a natural language answer sequence that conforms to grammar.

[0049] The target answer sequence generation module is used to generate a target answer sequence that matches the context and the question based on the obtained grammatically correct natural language answer sequence and the question-aware loss.

[0050] Thirdly, the present invention provides a natural language answer generation device based on multi-level replication and perceptual loss, characterized in that it includes a processor and a storage medium;

[0051] The storage medium is used to store instructions;

[0052] The processor is configured to operate according to the instructions to perform the steps of the method described in the first aspect.

[0053] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, characterized in that the program, when executed by a processor, implements the steps of the method described in the first aspect.

[0054] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0055] This invention provides a method, apparatus, and medium for generating natural language answers based on multi-level replication and perceptual loss. Taking natural language answer generation in intelligent QA systems as the research object, it addresses the problems of existing methods generating meaningless responses and question-answer mismatches. It proposes a decoder based on a multi-level replication and prediction mechanism, which simultaneously replicates relevant semantic units in the question and triples, and predicts commonly used words from a vocabulary list, ultimately generating a grammatically correct natural language answer. Then, to address the problem of mismatch between the generated natural language answer and the input question, a question-answer matching mechanism based on question perceptual loss is designed. This enables the natural language answer generation model to generate a target answer subsequence that matches the question's interrogative words within the target answer, ultimately obtaining a natural language answer statement corresponding to the input question. This generates a grammatically and context-compliant natural language answer sequence according to user needs, laying a theoretical foundation for future complex multi-turn dialogues. Attached Figure Description

[0056] Figure 1 This is a flowchart illustrating the natural language answer generation method based on multi-level replication and perceptual loss provided in Implementation Example 1.

[0057] Figure 2 Generate model graphs for natural language answers;

[0058] Figure 3 This is a schematic diagram illustrating the principle of the natural language answer generation method based on multi-level replication and perceptual loss provided in Example 1. Detailed Implementation

[0059] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments and specific features in the embodiments are detailed descriptions of the technical solution of the present application, rather than limitations thereof. In the absence of conflict, the embodiments and technical features in the embodiments can be combined with each other.

[0060] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0061] Example 1:

[0062] Figure 1This is a flowchart of a natural language answer generation method based on multi-level replication and perceptual loss, according to Embodiment 1 of the present invention. The natural language answer generation method based on multi-level replication and perceptual loss provided in this embodiment can be applied to a terminal and can be executed by a natural language answer generation device based on multi-level replication and perceptual loss. This device can be implemented in software and / or hardware and can be integrated into the terminal, such as any smartphone, tablet, or computer device with communication capabilities. See also... Figure 1 The method implemented in this way specifically includes the following steps:

[0063] Step A: Based on the pre-acquired natural language question and triples, input them into the corresponding encoding layers to obtain vector representations of the natural language question and triples;

[0064] Step B: Based on the obtained vector representation, and using a pre-designed decoder, obtain the set of semantic units and the set of entities of triples for the problem by copying.

[0065] Step C: Based on the pre-acquired vocabulary, and using a prediction mechanism, generate common words in the natural language answer sequence. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0066] Step D: Based on the relevant semantic units obtained by the question replication mechanism, the relevant entities obtained by the triple replication mechanism, and the commonly used words obtained by the prediction mechanism, generate a complete natural language answer sequence;

[0067] Step E: Based on the obtained natural language answer sequence, optimize the generation of the natural language answer sequence using answer perception loss to generate a grammatically correct natural language answer sequence;

[0068] Step F: Based on the obtained grammatically correct natural language answer sequence, generate a target answer sequence that matches the context and the question, using question-aware loss;

[0069] The pre-designed decoder includes a problem replication mechanism module, a triple replication mechanism module, and a prediction mechanism module.

[0070] Step Aa: Table 1 is the problem and triplet coding table of this invention:

[0071] Table 1

[0072]

[0073] The encoder is responsible for converting discrete input symbols into numerical vector representations. The specific details of the Bi-RNN-based encoder are shown in Table 1, mainly consisting of two parts: question encoding and triple encoding. The encoder's input has two aspects: a natural language question... and fact triples Its output is the problem. vector representation and triplet Vector representation of;

[0074] The question encoding layer transforms the question sequence into a series of connected hidden states using a bidirectional recurrent neural network (Bi-RNN). The Bi-RNN-based question encoder generates the forward hidden states. and backward hidden state Regarding user issues The concatenation of the two-way hidden states is as follows: , Considered as input word The word vector representation. The last word. vector representation yes , Used as a vector representation of the user's question, denoted as In other words, the whole problem The vector representation of is .

[0075] Step Ab: The input to the triplet encoding layer is structured data, i.e., fact triples. The triplet encoding layer receives the input triples. Head entity ,relation Tail-end entity The triple encoder transforms each element of the input triples into a fixed vector generated by the KG vector matrix. To capture more fact triple information, the KG vector matrix is ​​pre-trained using the TransE model.

[0076] , , The vector representations are respectively , , ;

[0077] , , connection Representing fact triples The vector, denoted as . .

[0078] Step Ba: The method for obtaining the set of semantic units includes:

[0079] Based on the obtained vector representation of the natural language question, relevant semantic units are copied from the source question using a question copying mechanism in a pre-designed decoder;

[0080] Based on the semantic units related to replication, they are treated as a set of semantic units;

[0081] Specifically, the decoder is responsible for generating the target answer sequence. Based on the vector representation of the question, the decoder uses a recurrent neural network (RNN) to generate a subsequence of natural language answers. The decoder integrates a copying mechanism that can directly copy a subsequence from the source question to generate the target answer sequence. The decoder can copy words from the input question. The formula for calculating its score function is: , The replication mechanism is from the problem Select the scoring function for the relevant semantic units; This represents a neural network function with a two-layer perceptron. It is a cumulative vector that collects the attention history for each semantic unit in the source problem.

[0082] Step Bb: The method for obtaining the entity set includes:

[0083] Based on the vector representation of the obtained triples, the relevant entities are copied from the triples according to the triple copying mechanism in the pre-designed decoder;

[0084] Based on the related entities of the replication, they are treated as an entity set;

[0085] Specifically: Based on the vector representation of triples, the decoder uses an RNN to generate subsequences of natural language answers. The decoder starts from the input triples... The decoder copies the semantic entities related to the answer, i.e., the tail entities, from the input triples to generate the target answer subsequence. The decoder copies the tail entities from the input triples, and its scoring function is expressed as follows: , This indicates that the replication mechanism originates from the triplet. Select a scoring function for relevant semantic entities; It is a cumulative vector that collects the attention history of each entity in the input triplet.

[0086] Step Ca: The method for generating common words in the natural language answer sequence includes:

[0087] The decoder-based prediction mechanism module predicts frequently used words from a pre-acquired vocabulary, determines whether the scores of the predicted frequently used words meet a preset threshold, and selects the frequently used words whose scores meet the preset threshold as frequently used words in the natural language answer sequence.

[0088] The decoder's score function for predicting frequently used words from the vocabulary based on a prediction mechanism is as follows:

[0089]

[0090] The pre-acquired vocabulary includes , , Indicates any word outside the dictionary. A set of semantic units representing a problem. Represents the set of entities that form a triple. This represents the score function by which the prediction mechanism predicts frequently used words from the vocabulary. The prediction mechanism for frequently used words, This represents the sequence of natural language answers generated at time t. This represents the word vectors of the output layer. The weight matrix represents the prediction mechanism. and They represent the time steps respectively. Sometimes selectively from the problem and triplet facts The context vector read from short-term memory.

[0091] The prediction mechanism can generate some commonly used words from a sequence of natural language answers. More specifically, some words or phrases need to be predicted from a fixed vocabulary. Defined as ,in, This represents any word outside the lexicon. In addition, the prediction mechanism also uses two other sets: and These encompass the words or entities in the input question and the input triples. In other words, this section uses a vocabulary for each target answer sequence. ,and , and These three vocabularies may overlap. Some common words in the natural language answer sequence are usually predicted using a conditional language model. The score function for the decoder to predict common words from the vocabulary is expressed as:

[0092]

[0093] In the formula, This represents the word vectors of the output layer. The weight matrix represents the prediction mechanism. and They represent the time steps respectively. Sometimes selectively from the problem and triplet facts The context vector read from short-term memory.

[0094] Step Da: Table 2 shows the decoding algorithm of this invention based on multi-level replication and prediction mechanisms:

[0095] Table 2

[0096]

[0097] At each time step of the decoding process In the middle, the hidden state based on the decoder Vector representation of the entire natural language problem Vector representation of fact triples Generate a sequence of natural language answers The probability function is a mixture model, and the probability of the generated complete natural answer sequence must meet a preset threshold. Its probability function is defined as follows:

[0098]

[0099] In the formula, To generate a complete sequence of natural language answers, , and These represent the problem's replication mechanism, the triple replication mechanism, and the prediction mechanism for common words, respectively. This is the hidden state of the decoder. This is the vector representation of the entire natural language problem. Let t be the vector representation of the fact triple, and t be the time step. This represents a probabilistic language model that selects different mechanisms. Represents the context vector;

[0100] To calculate the context vector The decoder of the answer generation method proposed in this invention learns attention values. Its calculation formula is expressed as: , where the function Used to calculate each input hidden state Attention intensity. Currently, most decoder prediction mechanisms use the same context vector. However, from a fixed context vector When generating target words, the decoder is prone to producing poor results. However, the attention mechanism can dynamically select the hidden state at each time step to generate different context vectors. Context vector The calculation is as follows: The specific details of the decoder are given in Table 2. These implementation details mainly consist of three parts: copying relevant semantic units from the question, copying answer entities from the triples, and predicting common words from the vocabulary. The decoder's input has two aspects: the representation of the question... and the representation of triples Its output is the sequence of target answers. .

[0101] Step Ea: The method for generating the grammatically correct natural language answer sequence includes:

[0102] Given the natural question Q, the fact triple T, and the target answer sequence Train a probabilistic language model of natural answer sequences;

[0103] For the natural language answer sequence generated by the probabilistic language model of natural answer sequence, the negative log-likelihood is optimized through the answer-aware function to generate a grammatically correct natural language answer sequence.

[0104] The answer perception loss function is as follows:

[0105]

[0106] The natural language answer generation model generates a sequence of natural language answers. By adjusting parameters, the generated natural language answers become more fluent, natural, and grammatically correct.

[0107] In the formula, As a regularization factor, yes The hyperparameters, W, are the target answer sequence. This is the vector representation of the entire natural language problem. Let t be the vector representation of the fact triple, where t is the time step;

[0108] The answer reflects perceived loss. Includes negative log-likelihood and Regularization can generate more natural, grammatically correct sequences of target answers.

[0109] Step Fa: Based on the generated grammatically correct natural language answer sequence, generate a target answer subsequence corresponding to the question type words according to the input question;

[0110] The question-aware loss function generates answer words that match the question type words, where the cross-entropy between the question type words and the answer words must be minimized.

[0111] The generation of natural language answer sequences is optimized based on answer words to generate target answer sequences that conform to the context and match the question.

[0112] Perceived loss through optimizing answers The natural language answer generation method proposed in this invention can generate grammatically correct target answer sequences. However, a problem exists with these target answer sequences: the generated natural language answers do not match the input natural language question. To address this mismatch, a question-answer matching mechanism based on question-aware loss is designed. This mechanism enables the natural language answer generation model to generate target answer subsequences that match the question words in the target answer sequence, ultimately obtaining the natural language answer statement corresponding to the input question. Based on the question-aware loss, the model can generate question type words in the target answer sequence. Formally, the question-aware loss is expressed by the following formula:

[0113]

[0114] In the formula, It is a set of question type words. It is a set of generated answer words. Indicates the type of question With the generated answer words Cross-entropy between;

[0115] The model uses minimum cross-entropy as the problem-aware loss. Loss perceived through optimization problems. The model focuses on generating a sequence of question types from the target answer sequence. The model's total loss is shown below: .

[0116] Table 3 shows the QA pattern, fact triples, and generated QA pairs of this invention:

[0117] Table 3

[0118]

[0119] Based on a QA corpus, two generators construct different QA patterns: one generates the question pattern, and the other generates the corresponding natural language answer pattern. For example, the natural language question pattern "What is the capital of $Country$?" has the natural language answer pattern "The capital of $Country$ is called $City$." where the variables $Country$ and $City$ represent the country name and city name, respectively. Given KG fact triples and QA patterns, the generator can ultimately obtain specific QA pairs. The KG fact triples, QA patterns, and generated QA pairs are shown in Table 3.

[0120] Figure 2Generate a model graph for natural language answers. The QA system generates semantic units (words, phrases, and entities) for the answers. However, in real-world environments, users expect the QA system to provide correct answers in a more natural way to meet their needs. For example, for the natural language question "What is the capital of China?", most users prefer a natural sequence of answers like "The capital of China is called Beijing." rather than simply responding with the entity "Beijing". Figure 2 This paper demonstrates the main process of Question Answering over Knowledge Graph (KGQA), which includes three aspects: question analysis, answer retrieval, and natural language answer generation. First, the QA system identifies the central entity (i.e., China) and the main relation (i.e., capital) in the question. Then, the topic entities and main relations in the question are mapped to the KG. Second, based on the KG's triple query and reasoning, relevant fact triples (China, capital, Beijing) are retrieved from the KG. Finally, based on the input natural language question "What is the capital of China?" and the retrieved fact triples (China, capital, Beijing), the system can automatically generate a grammatically correct and contextually appropriate natural language answer. The KGQA system generates natural language answer sequences in different ways, specifically: common words are usually predicted using a conditional model (e.g., "is called"), the main semantic units are copied from the user question (e.g., "The capital of China"), and the answer entities are copied from the triples (e.g., "Beijing").

[0121] Figure 3 This diagram illustrates the natural language answer generation method based on multi-level replication and question-aware loss of the present invention. Figure 3 A natural language answer generation method based on multi-level replication and question-aware loss is presented, which is an encoder-decoder architecture for generating natural language answer sequences. Figure 3 This paper presents a general solution for a natural language answer generation method based on multi-level replication and question-aware loss. First, a Bi-RNN-based encoder generates vector representations of the question and triples. Then, the encoded vector representations are submitted to a decoder to generate natural language answers. Finally, considering the possibility of mismatch between the generated natural language answer sequence and the input question, this invention also designs a question-answer matching mechanism based on question-aware loss to generate a context-appropriate natural language answer sequence.

[0122] like Figure 3 As shown, the specific implementation details of each part of the present invention are as follows:

[0123] 1. A Bi-RNN-based encoder. The encoder is responsible for converting discrete input symbols into numerical vector representations. The specific details of a Bi-RNN-based encoder mainly include two parts: question encoding and triple encoding. The encoder's input has two aspects: a natural language question. and fact triples Its output is the problem. vector representation and triplet vector representation .

[0124] 2. Decoder based on question copying mechanism. Some words in the input question are meaningless symbols and do not need to be analyzed or processed during decoding. The decoder integrates a question copying mechanism, which can copy relevant semantic units from the source question to generate the target answer sequence.

[0125] 3. Decoder based on triple copying mechanism. Most input questions contain head entities and their relationships, while tail entities rarely appear. Therefore, the decoder needs to copy the semantic entities related to the answer, i.e., the tail entities, from the input triples. The target answer subsequence is generated by copying the tail entities of the input triples.

[0126] 4. Decoder Based on Prediction Mechanism. The prediction mechanism generates some commonly used words in a natural language answer sequence. More specifically, some words or phrases need to be predicted from a fixed vocabulary. Commonly used words in a natural language answer sequence are typically predicted using a conditional language model. The scoring function for the decoder to predict commonly used words from the vocabulary is shown below: , This represents the word vectors of the output layer. The weight matrix represents the prediction mechanism. and They represent the time steps respectively. Sometimes selectively from the problem and triplet facts The context vector read from short-term memory.

[0127] 5. Question-Answer Matching Mechanism Based on Question-Aware Loss. To address the mismatch between the generated natural language answer and the input question, a question-answering matching mechanism based on question-aware loss is designed. This mechanism enables the natural language answer generation model to generate a target answer subsequence that matches the question's interrogative words within the target answer, ultimately obtaining the natural language answer statement corresponding to the input question. Formally, question-aware loss... Represented as: ,in, It is a set of question type words. These are the generated answer words. Indicates the type of question With the generated answer words The model uses the minimum cross-entropy as the problem-aware loss. Loss perceived through optimization problems. The model focuses on generating a sequence of question types from the target answer sequence.

[0128] In summary, the natural language answer generation method based on multi-level replication and perceptual loss provided in this embodiment takes natural language answer generation in intelligent QA systems as its research object. Addressing the issues of existing methods generating meaningless responses and question-answer mismatches, it proposes a decoder based on a multi-level replication and prediction mechanism. This decoder simultaneously replicates relevant semantic units in the question and triples, predicts commonly used words from a vocabulary, and ultimately generates a grammatically correct natural language answer. Furthermore, to address the mismatch between the generated natural language answer and the input question, a question-answer matching mechanism based on question perceptual loss is designed. This enables the natural language answer generation model to generate a target answer subsequence that matches the question's interrogative words within the target answer, ultimately obtaining a natural language answer statement corresponding to the input question. This allows for the generation of grammatically and context-compliant natural language answer sequences based on user needs, laying a theoretical foundation for future complex multi-turn dialogues.

[0129] Example 2:

[0130] A natural language answer generation device based on multi-level replication and perceptual loss, the device comprising:

[0131] The first data processing module is used to input the pre-acquired natural language questions and triples into the corresponding coding layers to obtain vector representations of the natural language questions and triples.

[0132] The second data processing module is used to obtain the set of semantic units and the set of entities of triples of the problem by copying the obtained vector representation based on a pre-designed decoder.

[0133] The third data processing module is used to generate common words in the natural language answer sequence based on a pre-acquired vocabulary and a prediction mechanism. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0134] The fourth data processing module is used to generate a complete natural language answer sequence based on the relevant semantic units obtained by the question replication mechanism, the relevant entities obtained by the triple replication mechanism, and the commonly used words obtained by the prediction mechanism.

[0135] The fifth data processing module is used to optimize the generation of natural language answer sequences based on the obtained natural language answer sequence and answer perception loss, so as to generate a natural language answer sequence that conforms to grammar.

[0136] The target answer sequence generation module is used to generate a target answer sequence that matches the context and the question based on the obtained grammatically correct natural language answer sequence and the question-aware loss.

[0137] The natural language answer generation device based on multi-level replication and perceptual loss provided in the embodiments of the present invention can execute the natural language answer generation method based on multi-level replication and perceptual loss provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method.

[0138] Example 3:

[0139] This invention also provides a natural language answer generation device based on multi-level replication and perceptual loss, including a processor and a storage medium;

[0140] The storage medium is used to store instructions;

[0141] The processor is configured to operate according to the instructions to perform the steps of the following method:

[0142] Based on the pre-acquired natural language questions and triples, they are input into the corresponding coding layers to obtain vector representations of the natural language questions and triples;

[0143] Based on the obtained vector representation, and using a pre-designed decoder, the set of semantic units and the set of triples of the problem are obtained by copying.

[0144] Based on a pre-acquired vocabulary list, and using a prediction mechanism, common words in the natural language answer sequence are generated. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0145] Based on the relevant semantic units obtained by the question replication mechanism, the relevant entities obtained by the triple replication mechanism, and the commonly used words obtained by the prediction mechanism, a complete natural language answer sequence is generated.

[0146] Based on the obtained natural language answer sequence, and using answer perception loss, the generation of natural language answer sequence is optimized to generate a grammatically correct natural language answer sequence;

[0147] Based on the obtained grammatically correct natural language answer sequence, and using question-aware loss, a target answer sequence that fits the context and matches the question is generated.

[0148] For details of each step in this embodiment, please refer to Embodiment 1, which will not be repeated here. Since this embodiment adopts the same technical concept as Embodiment 1, it also possesses the technical effects described in Embodiment 1.

[0149] Example 4:

[0150] This invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the following method:

[0151] Based on the pre-acquired natural language questions and triples, they are input into the corresponding coding layers to obtain vector representations of the natural language questions and triples;

[0152] Based on the obtained vector representation, and using a pre-designed decoder, the set of semantic units and the set of triples of the problem are obtained by copying.

[0153] Based on a pre-acquired vocabulary list, and using a prediction mechanism, common words in the natural language answer sequence are generated. Common words include at least verbs, prepositions, definite articles, and indefinite articles.

[0154] Based on the relevant semantic units obtained by the question replication mechanism, the relevant entities obtained by the triple replication mechanism, and the commonly used words obtained by the prediction mechanism, a complete natural language answer sequence is generated.

[0155] Based on the obtained natural language answer sequence, and using answer perception loss, the generation of natural language answer sequence is optimized to generate a grammatically correct natural language answer sequence;

[0156] Based on the obtained grammatically correct natural language answer sequence, and using question-aware loss, a target answer sequence that fits the context and matches the question is generated.

[0157] For details of each step in this embodiment, please refer to Embodiment 1, which will not be repeated here. Since this embodiment adopts the same technical concept as Embodiment 1, it also possesses the technical effects described in Embodiment 1.

[0158] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0159] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0160] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0161] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0162] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A natural language answer generation method based on multi-level replication and perceptual loss, characterized in that, include: Based on the pre-acquired natural language questions and triples, they are input into the corresponding coding layers to obtain vector representations of the natural language questions and triples; Based on the obtained vector representation, and using a pre-designed decoder, the set of semantic units and the set of triples of the problem are obtained by copying. Based on a pre-acquired vocabulary list, and using a prediction mechanism, common words in the natural language answer sequence are generated. Common words include at least verbs, prepositions, definite articles, and indefinite articles. Based on the obtained semantic unit set, entity set, and commonly used words, a complete natural language answer sequence is generated; Based on the obtained natural language answer sequence, and using answer perception loss, the generation of natural language answer sequence is optimized to generate a grammatically correct natural language answer sequence; Based on the obtained grammatically correct natural language answer sequence, and using question-aware loss, a target answer sequence that fits the context and matches the question is generated; The pre-designed decoder includes a problem replication mechanism module, a triple replication mechanism module, and a prediction mechanism module.

2. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 1, characterized in that, The method for obtaining the set of semantic units includes: Based on the obtained vector representation of the natural language question, relevant semantic units are copied from the source question using a question copying mechanism in a pre-designed decoder; Based on the semantic units related to replication, they are treated as a set of semantic units.

3. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 1, characterized in that, The method for obtaining the entity set includes: Based on the vector representation of the obtained triples, the relevant entities are copied from the triples according to the triple copying mechanism in the pre-designed decoder; The related entities based on the replication are treated as an entity set.

4. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 1, characterized in that, The methods for generating commonly used words in the natural language answer sequence include: The decoder-based prediction mechanism module predicts frequently used words from a pre-acquired vocabulary, determines whether the scores of the predicted frequently used words meet a preset threshold, and selects the frequently used words whose scores meet the preset threshold as frequently used words in the natural language answer sequence. The decoder's score function for predicting frequently used words from the vocabulary based on a prediction mechanism is as follows: φ predict (w t =v i )=v i W predict [d t ,c Qt ,c Tt ] The pre-acquired vocabulary includes V∪V Q ∪V T V = {v1, v2, ..., v} n-1 ,v n }∪{OOVW}, where OOVW represents any word outside the dictionary, and V Q V represents the set of semantic units of a problem. T φ represents the set of entities that form a triple. predict (w t =v i ) represents the score function of the prediction mechanism that predicts common words from the vocabulary, predict represents the prediction mechanism for common words, and w t v represents the sequence of natural language answers generated at time t. i W represents the word vectors of the output layer. predict c represents the weight matrix of the prediction mechanism. Qt and c Tt These represent the selective selection of elements from problem h at time step t. Q and the fact of the triple h T The context vector read from short-term memory.

5. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 1, characterized in that, The probability of the generated complete natural answer sequence must meet a preset threshold, where, The probabilistic language model representing the generated complete sequence of natural answers is as follows: In the formula, w t-1 Let P(w) represent the sequence of natural language answers generated at time t-1. t |d t ,w t-1 ,h Q ,h T ) is a probabilistic language model for generating arbitrary natural language answer sequences, w t To generate a complete sequence of natural language answers, copy Q copy T `d` and `predict` represent the problem's replication mechanism, the triple replication mechanism, and the prediction mechanism for common words, respectively. t h represents the hidden state of the decoder. Q h is the vector representation of the entire natural language problem. T Let P be the vector representation of the fact triple, where t is the time step and P is the vector representation of the fact triple. d (·|·) represents the probabilistic language model that selects different mechanisms, c t This represents the context vector.

6. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 5, characterized in that, The method for generating the grammatically correct natural language answer sequence includes: Given the natural question Q, the fact triple T, and the target answer sequence W = (w1, w2, ..., w...), t ,...,w |W| Train a probabilistic language model of natural answer sequences; For the natural language answer sequence generated by the probabilistic language model of natural answer sequence, the negative log-likelihood is optimized through the answer-aware function to generate a grammatically correct natural language answer sequence. The answer perception loss function is as follows: In the formula, ψ A_loss Let W be the answer-perceived loss function, L2 be the regularization factor, κ be the L2 hyperparameter, W be the target answer sequence, and h be the answer-perceived loss function. Q h is the vector representation of the entire natural language problem. T Let t be the vector representation of the fact triple, and t be the time step.

7. The natural language answer generation method based on multi-level replication and perceptual loss according to claim 1, characterized in that, The method for generating a target answer sequence that conforms to the context and matches the question includes: Based on the generated grammatically correct natural language answer sequence, a target answer subsequence corresponding to the question type words is generated according to the input question; The question-aware loss function generates answer words that match the question type words, where the cross-entropy between the question type words and the answer words must be minimized. The generation of natural language answer sequences is optimized based on answer words, generating target answer sequences that conform to the context and match the question. The problem-aware loss function is expressed by the following equation: In the formula, ψ Q_loss Perceive loss for the problem, Y is a set of question type words, and Y is a set of generated answer words. The term q indicates the type of problem. n With the generated answer word w t Cross-entropy between them.

8. A natural language answer generation device based on multi-level replication and perceptual loss, characterized in that, The device includes: The first data processing module is used to input the pre-acquired natural language questions and triples into the corresponding coding layers to obtain vector representations of the natural language questions and triples. The second data processing module is used to obtain the set of semantic units and the set of entities of triples of the problem by copying the obtained vector representation based on a pre-designed decoder. The third data processing module is used to generate common words in the natural language answer sequence based on a pre-acquired vocabulary and a prediction mechanism. Common words include at least verbs, prepositions, definite articles, and indefinite articles. The fourth data processing module is used to generate a complete natural language answer sequence based on the obtained semantic unit set, entity set, and commonly used words. The fifth data processing module is used to optimize the generation of natural language answer sequences based on the obtained natural language answer sequence and answer perception loss, so as to generate a natural language answer sequence that conforms to grammar. The target answer sequence generation module is used to generate a target answer sequence that matches the context and the question based on the obtained grammatically correct natural language answer sequence and the question-aware loss.

9. A natural language answer generation device based on multi-level replication and perceptual loss, characterized in that, Including processor and storage media; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • A natural question answering method based on text, knowledge base and sequence-to-sequence

    CN109271496A

  • Method for generating chapter-level complex problem based on dual programming

    CN115510814A