Question and answer processing method and apparatus
By integrating the question-answering fusion model of graph KBQA and QA question-answering algorithms with an enhanced intent recognition algorithm, the efficiency and accuracy problems of existing question-answering processing technologies in multiple scenarios are solved, and efficient processing of complex question-answering scenarios is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2022-01-04
- Publication Date
- 2026-06-05
AI Technical Summary
Existing question-answering technologies are inefficient in various scenarios and cannot accurately handle complex and comprehensive question-answering scenarios, especially when QA question-answering, graph question-answering, task-based question-answering, and basic casual question-answering coexist.
We adopt a fusion model of graph-based KBQA question answering algorithm and question-answer pair QA question answering algorithm, combined with task scenario preset rules and dialogue state detection rules. Through question answering fusion model and enhanced intent recognition algorithm, we take corresponding processing methods for different question answering modes, including data augmentation and feature engineering to improve recognition accuracy.
It achieves efficient processing of various question-and-answer scenarios, improving the efficiency and accuracy of question-and-answer processing. In particular, the enhanced intent recognition algorithm significantly improves the recognition capability in Task scenarios and multi-turn dialogue modes.
Smart Images

Figure CN116450781B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a question-and-answer processing method and apparatus. Background Technology
[0002] Current question-and-answer processing typically employs algorithms such as classification, clustering, or similarity matching to identify the intent behind the user's input question, and then retrieves a knowledge corpus accumulated by experts to provide a response.
[0003] Existing question-answering methods are primarily used for everyday knowledge retrieval and knowledge-based question-answering scenarios. Their processing logic is simple, and they support limited question-answering corpora and scenarios. They offer limited support for multiple question-answering scenarios simultaneously, including QA, graph-based question answering, task-based question answering, and basic casual conversation, making it difficult to handle complex and comprehensive question-answering scenarios. Furthermore, they suffer from insufficient computational power and efficiency when dealing with complex question answering and multi-turn dialogue question answering.
[0004] Therefore, it is of great significance to propose a method that can solve the problems of simple functions, limited scenarios, and low efficiency in existing question-answering processing technologies. Summary of the Invention
[0005] This invention provides a question-and-answer processing method and apparatus to solve the technical problem in the prior art that it is impossible to achieve efficient and accurate question-and-answer processing in various different scenarios.
[0006] In a first aspect, the present invention provides a question-and-answer processing method, comprising:
[0007] Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements;
[0008] If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, the target user statement is input into the question-and-answer fusion model to determine the matching result between the target user statement and the question-and-answer fusion model.
[0009] When the question-and-answer mode belongs to the Task scenario mode, or when the question-and-answer mode is a multi-turn dialogue mode, the target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0010] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answer pair QA question-answering algorithm.
[0011] In one embodiment, determining the question-and-answer pattern of the target user's statements based on the Task scenario preset rules and the dialogue state detection rules includes:
[0012] Based on a pre-defined keyword dictionary and pre-defined regular expressions, determine the preset rules for the Task scenario;
[0013] The dialogue state detection rules are determined based on the multi-turn dialogue management strategy built into the Rasa natural language framework.
[0014] The target user statement is matched with the preset rules of the Task scenario to determine the scenario mode in the question-and-answer mode of the target user statement, and the target user statement is matched with the dialogue state detection rules to determine the dialogue mode in the question-and-answer mode of the target user statement.
[0015] In one embodiment, inputting the target user statement into an enhanced intent recognition algorithm to determine the recognition result of the target user statement includes:
[0016] Obtain training samples and perform data augmentation on the training samples;
[0017] Based on the data-augmented training samples, a language representation model BERT is trained to obtain the trained BERT model.
[0018] The target user's statement is input into the trained BERT model to obtain the sentence vector of the target user's statement;
[0019] The target user's statement is used to obtain a sparse vector through manually defined feature engineering.
[0020] The sentence vector and the sparse vector are concatenated, and the concatenated vector is input into a fully connected layer and a softmax layer to determine the recognition result of the target user's sentence.
[0021] In one embodiment, the data augmentation of the training samples includes:
[0022] Label the slots in the training samples that are irrelevant to the intent classification;
[0023] Training negative samples are generated based on manually determined seed negative samples and slots that are irrelevant to the intended classification.
[0024] The training samples are segmented into words, and the unlabeled word slots in the resulting word slots are replaced with synonyms.
[0025] Oversampling is performed on the samples after synonym replacement to balance the number of samples in different categories and obtain balanced samples;
[0026] The training negative samples and the balanced samples are used as the data-augmented training samples.
[0027] In one embodiment, the step of inputting the target user statement into the question-answering fusion model and determining the matching result between the target user statement and the question-answering fusion model includes:
[0028] The target user's statement is input in parallel into the KBQA question-answering algorithm and the QA question-answering algorithm;
[0029] The KBQA matching result of the target user's statement is determined according to the KBQA question-answering algorithm, and the QA matching result of the target user's statement is determined according to the QA question-answering algorithm.
[0030] According to the preset priority, the KBQA matching result and the QA matching result with the higher priority are used as the matching result of the question answering fusion model;
[0031] The matching in the QA question-answering algorithm is determined based on cosine similarity matching.
[0032] In one embodiment, if the target user's statement does not match the question-answering fusion model...
[0033] The target user's statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0034] If the enhanced intent recognition algorithm fails to recognize the target user's statement, the response result is output according to the default response strategy.
[0035] In one embodiment, if the enhanced intent recognition algorithm fails to recognize the target user's statement,
[0036] The recognition rate of the enhanced intent recognition algorithm is adjusted according to the preset correction rules, and the answer result is output.
[0037] Secondly, the present invention also provides a question-and-answer processing apparatus, comprising:
[0038] The question-and-answer pattern determination module is used to determine the question-and-answer pattern of the target user's statements based on the preset rules of the Task scenario and the dialogue state detection rules.
[0039] The question-answering fusion model matching module is used to input the target user statement into the question-answering fusion model and determine the matching result between the target user statement and the question-answering fusion model when the question-answering mode does not belong to the Task scenario mode and the question-answering mode is a non-multi-turn dialogue mode.
[0040] An enhanced intent recognition algorithm matching module is used to input the target user's statement into the enhanced intent recognition algorithm and determine the recognition result of the target user's statement when the question-and-answer mode belongs to the Task scenario mode or the question-and-answer mode is a multi-turn dialogue mode.
[0041] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm.
[0042] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the question-and-answer processing method described above.
[0043] Fourthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described question-and-answer processing methods.
[0044] The question-and-answer processing method, apparatus, electronic device, and storage medium provided by this invention determine the question-and-answer pattern of the target user's statements and adopt corresponding question-and-answer processing methods for specific question-and-answer patterns, achieving efficient processing of various question-and-answer scenarios. Simultaneously, it optimizes conventional algorithms by employing a fusion model based on KBQA and QA question-and-answer algorithms for knowledge-based question-and-answer processing and by using an enhanced intent recognition algorithm for Task-based question-and-answer processing, thereby improving processing efficiency and accuracy. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in this 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 this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0046] Figure 1 A flowchart illustrating the question-and-answer processing method provided by this invention;
[0047] Figure 2 The Rasa information processing flowchart provided by this invention;
[0048] Figure 3 This is a structural diagram of the enhanced intent recognition algorithm provided by the present invention;
[0049] Figure 4 Flowchart for sample data enhancement provided by this invention;
[0050] Figure 5The fusion rule flowchart provided by this invention;
[0051] Figure 6 A flowchart illustrating the question-and-answer processing method provided by this invention;
[0052] Figure 7 A schematic diagram of the question-and-answer processing device provided by the present invention;
[0053] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0055] Figure 1 This is a flowchart illustrating the question-and-answer processing method provided by the present invention. (Refer to...) Figure 1 The question-and-answer processing method provided by this invention may include:
[0056] S110. Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements;
[0057] S120. If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, input the target user statement into the question-and-answer fusion model and determine the matching result between the target user statement and the question-and-answer fusion model.
[0058] S130. If the question-and-answer mode belongs to the Task scenario mode or the question-and-answer mode is a multi-turn dialogue mode, the target user statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user statement.
[0059] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm.
[0060] The execution subject of the question-and-answer processing method provided by this invention can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. For example, a mobile electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., while a non-mobile electronic device can be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This invention does not impose specific limitations.
[0061] The technical solution of this invention will be described in detail below using the question-and-answer processing method provided by this invention, which is executed by a computer.
[0062] It's important to note that question-and-answer (Q&A) generally includes four types: Task-based Q&A, Basic Casual Q&A, Knowledge Graph Q&A, and Knowledge-based Q&A. Task-based Q&A involves executing specific operations based on task information, such as executing a command to turn on a light. Basic Casual Q&A integrates basic Q&A functionality for casual conversation. Knowledge Graph Q&A and Q&A are both knowledge-based Q&A. KBQA uses knowledge graph queries to search data in the graph library. For example, "querying the status of linux123" will identify entities like linux123 and their categories before performing a graph query to obtain the result. Q&A uses a large number of knowledge question-and-answer pairs, matching them to determine the result.
[0063] In step S110, it is determined whether the question-and-answer mode of the target user's statement is a Task scenario according to the predefined Task scenario rules, and whether the question-and-answer mode of the target user's statement is a multi-turn dialogue mode according to the dialogue state detection rules.
[0064] The determination of whether a scenario is a Task is made through predefined Task scenario rules. These rules are derived from a pre-built Task scenario expert library. Commonly used task-related information, such as executing commands, creating tasks, and starting services, is entered into the expert library. The target user's statements are then compared with the information in the expert library to determine the appropriate task information.
[0065] Optionally, the Rasa framework can be used to determine whether the target user's statement is in a multi-turn dialogue mode. The Rasa framework has built-in various multi-turn dialogue management strategies, such as the most commonly used "form" strategy, which facilitates the design of multi-turn dialogues. The Rasa framework can be used to determine whether the target user's statement is in a multi-turn dialogue mode.
[0066] Understandably, by judging the question-and-answer patterns of the target user's statements, we can initially filter the questions and answers of the current target user's statements. Based on the filtering results, we can process the target user's statements in a targeted manner, which can improve the efficiency of question-and-answer recognition.
[0067] In step S120, if it is determined in step S110 that the question-and-answer pattern of the target user's statement does not belong to the Task scenario pattern and the question-and-answer pattern of the target user's statement is not a multi-turn dialogue pattern, the target user's statement is input into the question-and-answer fusion model to determine the matching result between the target user's statement and the question-and-answer fusion model.
[0068] If it is determined that the target user's statement does not belong to the Task scenario mode and is not a multi-turn dialogue, then the target user's statement is very likely to be a knowledge-based question-and-answer statement. Therefore, the target user's statement can be input into the question-and-answer fusion model for knowledge-based question-and-answer detection.
[0069] In step S130, if it is determined that the question-and-answer mode belongs to the Task scenario mode or the multi-turn dialogue mode, the target user's statement is directly input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement.
[0070] Understandably, given that the question-and-answer mode belongs to a Task scenario model or a multi-turn dialogue model, a data-enhanced intent recognition algorithm is constructed to determine the recognition result of the target user's statement. This data-enhanced intent recognition algorithm improves the accuracy of the recognition.
[0071] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm.
[0072] KBQA (Knowledge Base Question Answering) algorithms work by semantically understanding and parsing the input statement, then using a knowledge base to query and reason to arrive at the answer. A knowledge base is a special database used for knowledge management, for the collection, organization, and extraction of knowledge in a relevant domain. The knowledge in a knowledge base is a collection of domain knowledge needed to solve a problem, including basic facts, rules, and other relevant information. QA algorithms retrieve answers to questions that meet a matching threshold by searching for similarity indicators in the knowledge base.
[0073] Optionally, the KBQA question-answering algorithm and the QA question-answering algorithm can be fused according to pre-defined fusion rules to obtain a question-answering fusion model. The target user's input statement is then input into the KBQA and QA algorithms within the question-answering fusion model. The output of the algorithm with the better matching degree between the KBQA and QA algorithms is determined as the output of the question-answering fusion model.
[0074] The question-and-answer processing method provided by this invention determines the question-and-answer pattern of the target user's statements and adopts a corresponding question-and-answer processing method for specific question-and-answer patterns, achieving efficient processing of various question-and-answer scenarios. Simultaneously, it optimizes conventional algorithms by employing a fusion model based on KBQA and QA question-and-answer algorithms for knowledge-based question-and-answer processing, and by using an enhanced intent recognition algorithm for Task-based question-and-answer processing, thereby improving processing efficiency and accuracy.
[0075] In one embodiment, determining the question-and-answer pattern of a target user's statement based on Task scenario preset rules and dialogue state detection rules includes: determining the Task scenario preset rules based on a pre-defined keyword dictionary and pre-defined regular expressions; determining the dialogue state detection rules based on the multi-turn dialogue management strategy built into the Rasa natural language framework; matching the target user's statement with the Task scenario preset rules to determine the scenario pattern in the question-and-answer pattern of the target user's statement; and matching the target user's statement with the dialogue state detection rules to determine the dialogue pattern in the question-and-answer pattern of the target user's statement.
[0076] Specifically, based on a pre-defined keyword dictionary and pre-defined regular expressions, preset rules for the Task scenario are determined to match question-and-answer statements within the Task scenario. The target user statement is then matched against these preset rules to determine whether it is a question-and-answer statement within the Task scenario.
[0077] Secondly, it also detects whether the current target user's statement is in a multi-turn dialogue state. This multi-turn dialogue state detection can be performed using the Rasa natural language framework. Rasa has built-in various multi-turn dialogue management strategies, such as the most commonly used "form" strategy, which facilitates the design of multi-turn dialogues. Therefore, based on the Rasa framework, it is possible to determine whether the current question and answer is in a multi-turn dialogue question-and-answer mode.
[0078] Specifically, Rasa's information processing flow is as follows: Figure 2 The Rasa information processing flowchart provided by this invention is shown below. First, the system receives the target user's statement information and sends it to the Interpreter module. The Interpreter module transforms the target user's statement information into a dictionary, including the original information, intent, entities, etc. Next, the dictionary is sent to the Tracker module to record the dialogue state and track the dialogue progress. The Policy module receives the Tracker's current state and selects an appropriate Action module based on this state. The Action module sends information to the Tracker to record the current state and also returns the output result.
[0079] The target user's statement is matched with the Rasa framework-based dialogue state detection rules to determine whether the question-and-answer pattern of the target user's statement is a multi-turn dialogue pattern.
[0080] Understandably, by using the idea of layered detection, the question-and-answer pattern is first judged, and then the intent of the target user's statement is recognized. This improves the recognition speed of intent recognition while achieving recognition of multiple scenarios.
[0081] The question-and-answer processing method provided by this invention determines the question-and-answer pattern of the target user's statement by establishing preset rules for the Task scenario and dialogue state detection rules. It then adopts the corresponding question-and-answer processing method for the specific question-and-answer pattern scenario, thus achieving efficient processing of various question-and-answer scenarios.
[0082] In one embodiment, inputting the target user statement into an enhanced intent recognition algorithm to determine the recognition result of the target user statement includes: acquiring training samples and performing data augmentation on the training samples; training a language representation model BERT based on the data-augmented training samples to obtain a trained BERT model; inputting the target user statement into the trained BERT model to obtain a sentence vector of the target user statement; obtaining a sparse vector of the target user statement through manually defined feature engineering; concatenating the sentence vector and the sparse vector, and inputting the concatenated vector into a fully connected layer and a softmax layer to determine the recognition result of the target user statement.
[0083] This invention proposes an enhanced intent recognition algorithm. Based on this algorithm, the intent of the target user's statement is identified, and the recognition result of the target user's statement is determined. The algorithm's structure diagram is shown below. Figure 3 The structure diagram of the enhanced intent recognition algorithm provided by this invention is shown.
[0084] The enhanced intent recognition algorithm divides the input into two parts based on its network structure. The left branch obtains the sentence vector of the target user's statement by inputting it into the trained language representation model BERT. The BERT model is trained based on data-augmented training samples. The right branch involves obtaining a sparse vector from the target user's statement through manually defined feature engineering. Feature engineering can select features that can help improve intent recognition, as shown in Table 1.
[0085] Table 1 Feature Engineering Settings Table
[0086] Feature 1 Feature 2 Feature 3 Feature 4 ...... Matching regular expressions Matching IP regular expressions Includes a dictionary Starting with ** ......
[0087] The sentence vector obtained from the left branch is concatenated with the sparse vector obtained from the right branch. This can be understood as the right-hand vector adding auxiliary classification features to the left-hand BERT output vector. The concatenated vector is then connected to a fully connected layer and a softmax layer, thus completing the network structure of the enhanced intent recognition model.
[0088] The target user's statement is input into the constructed enhanced intent recognition model to obtain the corresponding sentence vector and sparse vector. The sentence vector and the sparse vector are concatenated, and the concatenated vector is input into a fully connected layer and a softmax layer to finally determine the recognition result of the target user's statement. In a real production environment, the enhanced intent recognition algorithm significantly improves the ability to recognize the intent of user statements that were previously difficult to recognize.
[0089] The question-and-answer processing method provided by this invention improves conventional intent recognition algorithms by constructing an enhanced intent recognition algorithm, thereby improving the efficiency and accuracy of intent recognition for target user statements.
[0090] In one embodiment, data augmentation of the training samples includes: labeling slots in the training samples that are irrelevant to the intent classification; generating training negative samples based on manually determined seed negative samples that are irrelevant to the intent classification; segmenting the training samples into words, and replacing unlabeled slots in the segmented slots with synonyms; oversampling the synonym-replaced samples to balance the number of samples of different categories and obtain balanced samples; and using the training negative samples and the balanced samples as the data-augmented training samples.
[0091] Optionally, the data augmentation steps for the training samples can be as follows: Figure 4 The flowchart for sample data augmentation provided by this invention is shown. The steps for data augmentation of training samples may include data labeling, generating negative samples, data augmentation, and oversampling.
[0092] Data labeling: When determining the original intent training samples, slots that are irrelevant to intent classification are labeled. These slots are irrelevant to intent classification but frequently change and affect the training of the intent recognition model. For example, "create a group of [cluster 001]" can be labeled with square brackets. The purpose of this is to enable automatic recognition during the next step of negative sample generation.
[0093] Negative sample generation: Negative samples can be divided into two parts: seed negative samples and automatically generated negative samples. Seed negative samples are specially designed samples that are manually compiled during the compilation of training samples. These samples are easily confused with positive category intents. Automatically generated negative samples are slot samples that are unrelated to intent classification and are automatically added to the negative sample categories. In this way, in strong intent recognition algorithms, the training model can accurately learn the weights of words in the samples, reducing the weight of slots in the positive category while increasing the weight of keywords.
[0094] Data augmentation: This involves expanding categories with fewer samples by using synonym replacement. In implementation, synonym replacement is performed on the segmented samples. However, slots marked during the data labeling step are not replaced. For example, the original target user input statement is "How to start hadoop". After segmentation, it becomes "How", "Start", and "hadoop". After synonym replacement, it becomes "How", "Start", and "hadoop".
[0095] Oversampling: In most cases, the samples augmented with synonyms can achieve data balance. However, some categories may still have a small number of samples after augmentation due to insufficient synonyms. Oversampling can be used to increase the number of samples in these categories.
[0096] The question-and-answer processing method provided by this invention enhances the training samples by inputting them into an enhanced intent recognition model for training, thereby improving the accuracy of the enhanced intent recognition algorithm in processing question-and-answer scenarios based on the enhanced intent recognition algorithm.
[0097] In one embodiment, inputting the target user statement into a question-answering fusion model and determining the matching result between the target user statement and the question-answering fusion model includes: inputting the target user statement in parallel into the KBQA question-answering algorithm and the QA question-answering algorithm; determining the KBQA matching result of the target user statement according to the KBQA question-answering algorithm, and determining the QA matching result of the target user statement according to the QA question-answering algorithm; and, according to a pre-set priority, using the higher-priority matching result between the KBQA matching result and the QA matching result as the matching result of the question-answering fusion model; wherein, the matching in the QA question-answering algorithm is determined based on cosine similarity matching.
[0098] Optionally, both the KBQA question answering algorithm and the QA question answering algorithm are about retrieving knowledge stored in a knowledge base. They both obtain the answer to the question by searching for similarity among the knowledge in the database.
[0099] The KBQA question answering algorithm uses a semantic parsing approach to perform named entity recognition and relation extraction on the input target user statement, and then puts the obtained entities and relations into a graph database for retrieval to obtain the answer.
[0100] QA (Question Answering) algorithms incorporate Elasticsearch (ES) for similar question retrieval. In addition to the inverted index, ES can use TF-IDF-based vectorization and cosine similarity to match similar vectors.
[0101] The similarity algorithm uses cosine similarity, and the calculation formula is as follows:
[0102]
[0103] Where cosθ is the cosine similarity value, a is the target user's input statement, and b is each candidate statement stored in the database.
[0104] In actual deployment, vectors a and b can be normalized first, so the denominator in the formula is 1, and only the numerator needs to be calculated. The closer the cosine angle is to 1, the closer the similarity between the two vectors, and the higher the similarity between the target user's statement and the candidate statements stored in the database. After receiving user input data, Elasticsearch first finds several candidate questions through the inverted index, then calculates the similarity value using the cosine similarity formula, and finally finds the most similar matching result by sorting in descending order.
[0105] Optionally, Python multithreading can be used to input the target user's statement into the KBQA and QA algorithms in parallel, providing prediction results simultaneously. In actual production environments, the query time for both KBQA and QA is approximately 300ms to 400ms. If the query operation is executed serially, the total time is approximately 700ms to 800ms, while the parallel query only takes 400ms, significantly reducing the question-and-answer response time.
[0106] After parallel queries yield results, a fusion rule from the question-answering fusion model is needed to find a more suitable answer. For example... Figure 5 The fusion rule flowchart provided by this invention is shown. The priority of answer selection can be set, and the ranking criteria can be determined based on the performance of the two KBQA algorithms and the QA algorithm, as well as the quality and size of the graph and question-answer pair data. Among them, the KBQA algorithm, due to its two main steps of named entity recognition and relation extraction, generally outperforms the QA question-answering algorithm in overall question-answering matching. When both algorithms find results, the graph question-answering result is prioritized as the answer. However, when the QA algorithm matches a result with extremely high similarity, the QA algorithm's matching result should be preferred. This is because the answers in question-answer pairs are generally manually compiled, and their matching results are generally more reasonable than those returned by the KBQA algorithm.
[0107] The question-answering processing method provided by this invention fuses the KBQA question-answering algorithm and the QA question-answering algorithm to obtain a question-answering fusion model. This model enables high-performance processing of knowledge-based questions.
[0108] In one embodiment, if the target user statement does not match the question-answering fusion model, the target user statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user statement; if the enhanced intent recognition algorithm cannot recognize the target user statement, the answer result is output according to the default answering strategy.
[0109] Specifically, if it is determined that the target user's statement does not match the question-answering fusion model, the user's statement is input into the enhanced intent recognition algorithm to further determine the recognition result of the target user's statement. If it is determined that the enhanced intent recognition algorithm cannot recognize the target user's statement, the answer result can be output according to the default answering strategy.
[0110] It is understandable that if the target user's statement does not match the question-answering fusion model, it can be concluded that the target user's statement is very likely a basic casual question-answering question. Therefore, the intent recognition of the target user's statement can be achieved by using an enhanced intent recognition algorithm.
[0111] Optionally, for example, if a user randomly enters a string of characters "asdfgh", the Rasa framework's FallbackPolicy can provide a predefined default response, such as "I don't understand what you mean, please rephrase it."
[0112] The question-and-answer processing method provided by this invention determines the question-and-answer pattern of the target user's statement and adopts a corresponding question-and-answer processing method for the specific question-and-answer pattern scenario, achieving efficient processing of various question-and-answer scenarios. When the enhanced intent recognition algorithm cannot recognize the target user's statement, it outputs the answer result according to the default answer strategy, enabling the setting of the corresponding response when the user's intent cannot be recognized.
[0113] In one embodiment, if the enhanced intent recognition algorithm fails to recognize the target user's statement, the recognition rate of the enhanced intent recognition algorithm is adjusted according to a preset correction rule, and the answer result is output.
[0114] Optionally, if the enhanced intent recognition algorithm fails to recognize the target user's statement, the recognition rate of the enhanced intent recognition algorithm is corrected based on pre-defined correction rules. After correcting the recognition rate, the enhanced intent recognition algorithm is used again to identify the target user's statement and output the corrected answer. The purpose of this correction is to handle some edge-case statements, such as "create, execute, restart, Hadoop cluster job group". In this case, the model may sometimes give a low recognition rate when it directly judges the statement, but this kind of question belongs to the standard question "create ** group". By correcting the recognition rate, the result of the second recognition can be output.
[0115] The question-and-answer processing method provided by this invention adjusts the recognition rate of the enhanced intent recognition algorithm according to preset correction rules, so that it can still output an answer even when the enhanced intent recognition algorithm cannot recognize the target user's statement. This achieves comprehensive coverage of target user statement recognition.
[0116] The following is a flowchart illustrating a question-and-answer processing method provided by this invention. Figure 6 For example, the technical solution provided by this invention will be explained:
[0117] The processing architecture for target user statements integrates four question-and-answer scenarios: Task scenario, KBQA question and answer, QA question and answer, and casual conversation scenario. The overall architecture is designed with a layered and modular approach, and can be divided into four parts: part1 to part4.
[0118] Part 1 defines two functions for Task-based question answering: Task scenario detection and dialogue state detection. Based on preset Task scenario rules and dialogue state detection rules, it matches and detects the target user's statements to determine whether the current target user's statements belong to the Task scenario rules or whether the current dialogue is in a multi-turn conversation.
[0119] Part 2 includes a question-answering fusion model composed of KBQA (Knowledge Base Question Answering) and QA (Question Answering). When the question-answering pattern is determined not to belong to the Task scenario mode and is not a multi-turn dialogue mode, the target user's statement will be input into both parts in parallel for KBQA and QA question-answering matching.
[0120] Part 3 handles casual conversation and task-related statements that failed to meet the preset rules in Part 1. This is achieved by embedding an enhanced intent recognition algorithm in Part 3. This enhanced intent recognition algorithm identifies target user statements that did not match in Part 2. Additionally, a default response strategy is set so that a response can be provided when the user's intent cannot be recognized.
[0121] Part 4 receives target user statements that meet the requirements of Part 1, i.e., either the question-and-answer mode belongs to the Task scenario mode, or the question-and-answer mode belongs to the multi-turn dialogue mode. Intent recognition is performed using the same enhanced intent recognition algorithm model as in Part 3. At the same time, an accuracy correction component is added, so all statements passing through this module will subsequently meet the set threshold.
[0122] The present invention also provides a question-and-answer processing apparatus, which can be referred to in correspondence with the question-and-answer processing method described above.
[0123] Figure 7 This is a schematic diagram of the question-and-answer processing device provided by the present invention, as shown below. Figure 7 As shown, the device includes:
[0124] The question-and-answer pattern determination module 710 is used to determine the question-and-answer pattern of the target user's statement based on the preset rules of the Task scenario and the dialogue state detection rules.
[0125] The question-answering fusion model matching module 720 is used to input the target user statement into the question-answering fusion model and determine the matching result between the target user statement and the question-answering fusion model when the question-answering mode does not belong to the Task scenario mode and the question-answering mode is a non-multi-turn dialogue mode.
[0126] The enhanced intent recognition algorithm matching module 730 is used to input the target user's statement into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement when the question-and-answer mode belongs to the Task scenario mode or the question-and-answer mode is a multi-turn dialogue mode.
[0127] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answer pair QA question-answering algorithm.
[0128] The question-and-answer processing device provided by this invention determines the question-and-answer pattern of the target user's statements and adopts a corresponding question-and-answer processing method for specific question-and-answer patterns, achieving efficient processing of various question-and-answer scenarios. Simultaneously, it optimizes conventional algorithms by employing a fusion model based on KBQA and QA question-and-answer algorithms for knowledge-based question-and-answer processing and by using an enhanced intent recognition algorithm for Task-based question-and-answer processing, thereby improving processing efficiency and accuracy.
[0129] In one embodiment, the question-answering pattern determination module 710 is specifically used for:
[0130] Based on the pre-defined rules for the Task scenario and the dialogue state detection rules, the question-and-answer pattern of the target user's statements is determined, including:
[0131] Based on a pre-defined keyword dictionary and pre-defined regular expressions, determine the preset rules for the Task scenario;
[0132] The dialogue state detection rules are determined based on the multi-turn dialogue management strategy built into the Rasa natural language framework.
[0133] The target user statement is matched with the preset rules of the Task scenario to determine the scenario mode in the question-and-answer mode of the target user statement, and the target user statement is matched with the dialogue state detection rules to determine the dialogue mode in the question-and-answer mode of the target user statement.
[0134] In one embodiment, the question-answering fusion model matching module 720 is specifically used for:
[0135] The target user statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user statement, including:
[0136] Obtain training samples and perform data augmentation on the training samples;
[0137] Based on the data-augmented training samples, a language representation model BERT is trained to obtain the trained BERT model.
[0138] The target user's statement is input into the trained BERT model to obtain the sentence vector of the target user's statement;
[0139] The target user's statement is used to obtain a sparse vector through manually defined feature engineering.
[0140] The sentence vector and the sparse vector are concatenated, and the concatenated vector is input into a fully connected layer and a softmax layer to determine the recognition result of the target user's sentence.
[0141] In one embodiment, the question-answering fusion model matching module 720 is further specifically used for:
[0142] Data augmentation of the training samples includes:
[0143] Label the slots in the training samples that are irrelevant to the intent classification;
[0144] Training negative samples are generated based on manually determined seed negative samples and slots that are irrelevant to the intended classification.
[0145] The training samples are segmented into words, and the unlabeled word slots in the resulting word slots are replaced with synonyms.
[0146] Oversampling is performed on the samples after synonym replacement to balance the number of samples in different categories and obtain balanced samples;
[0147] The training negative samples and the balanced samples are used as the data-augmented training samples.
[0148] In one embodiment, the question-answering fusion model matching module 720 is further specifically used for:
[0149] Inputting the target user statement into the question-answering fusion model and determining the matching result between the target user statement and the question-answering fusion model includes:
[0150] The target user's statement is input in parallel into the KBQA question-answering algorithm and the QA question-answering algorithm;
[0151] The KBQA matching result of the target user's statement is determined according to the KBQA question-answering algorithm, and the QA matching result of the target user's statement is determined according to the QA question-answering algorithm.
[0152] According to the preset priority, the KBQA matching result and the QA matching result with the higher priority are used as the matching result of the question answering fusion model;
[0153] The matching in the QA question-answering algorithm is determined based on cosine similarity matching.
[0154] In one embodiment, the enhanced intent recognition algorithm matching module 730 is specifically used for:
[0155] If the target user's statement does not match the question-answering fusion model.
[0156] The target user's statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0157] If the enhanced intent recognition algorithm fails to recognize the target user's statement, the response result is output according to the default response strategy.
[0158] In one embodiment, the enhanced intent recognition algorithm matching module 730 is further configured to:
[0159] In the event that the enhanced intent recognition algorithm fails to recognize the target user's statement,
[0160] The recognition rate of the enhanced intent recognition algorithm is adjusted according to the preset correction rules, and the answer result is output.
[0161] The present invention also provides an electronic device, such as... Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute the steps of a question-and-answer processing method, such as:
[0162] Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements;
[0163] If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, the target user statement is input into the question-and-answer fusion model to determine the matching result between the target user statement and the question-and-answer fusion model.
[0164] When the question-and-answer mode belongs to the Task scenario mode, or when the question-and-answer mode is a multi-turn dialogue mode, the target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0165] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answer pair QA question-answering algorithm.
[0166] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0167] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which, when executed by a computer, enable the computer to perform the steps of the question-and-answer processing methods provided in the above-described method embodiments, for example including:
[0168] Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements;
[0169] If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, the target user statement is input into the question-and-answer fusion model to determine the matching result between the target user statement and the question-and-answer fusion model.
[0170] When the question-and-answer mode belongs to the Task scenario mode, or when the question-and-answer mode is a multi-turn dialogue mode, the target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0171] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm.
[0172] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the question-and-answer processing methods provided in the above-described method embodiments, for example including:
[0173] Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements;
[0174] If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, the target user statement is input into the question-and-answer fusion model to determine the matching result between the target user statement and the question-and-answer fusion model.
[0175] When the question-and-answer mode belongs to the Task scenario mode, or when the question-and-answer mode is a multi-turn dialogue mode, the target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement;
[0176] The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm.
[0177] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0178] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0179] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention 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 of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A question-and-answer processing method, characterized in that, include: Based on the Task scenario preset rules and dialogue state detection rules, determine the question-and-answer pattern of the target user's statements; If the question-and-answer mode does not belong to the Task scenario mode and the question-and-answer mode is not a multi-turn dialogue mode, the target user statement is input into the question-and-answer fusion model to determine the matching result between the target user statement and the question-and-answer fusion model. When the question-and-answer mode belongs to the Task scenario mode, or when the question-and-answer mode is a multi-turn dialogue mode, the target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement; The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm. The target user statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user statement, including: Obtain training samples and perform data augmentation on the training samples; Based on the data-augmented training samples, a language representation model BERT is trained to obtain the trained BERT model. The target user's statement is input into the trained BERT model to obtain the sentence vector of the target user's statement; The target user's statement is used to obtain a sparse vector through manually defined feature engineering; the sparse vector obtained by the feature engineering is used to add auxiliary classification feature information to the statement vector. The sentence vector and the sparse vector are concatenated, and the concatenated vector is input into a fully connected layer and a softmax layer to determine the recognition result of the target user's sentence.
2. The question-and-answer processing method according to claim 1, characterized in that, The step of determining the question-and-answer pattern of the target user's statements based on the preset rules of the Task scenario and the dialogue state detection rules includes: Based on a pre-defined keyword dictionary and pre-defined regular expressions, determine the preset rules for the Task scenario; The dialogue state detection rules are determined based on the multi-turn dialogue management strategy built into the Rasa natural language framework. The target user statement is matched with the preset rules of the Task scenario to determine the scenario mode in the question-and-answer mode of the target user statement, and the target user statement is matched with the dialogue state detection rules to determine the dialogue mode in the question-and-answer mode of the target user statement.
3. The question-and-answer processing method according to claim 1, characterized in that, The data augmentation of the training samples includes: Label the slots in the training samples that are irrelevant to the intent classification; Training negative samples are generated based on manually determined seed negative samples and slots that are irrelevant to the intended classification. The training samples are segmented into words, and the unlabeled word slots in the resulting word slots are replaced with synonyms. Oversampling is performed on the samples after synonym replacement to balance the number of samples in different categories and obtain balanced samples; The training negative samples and the balanced samples are used as the data-augmented training samples.
4. The question-and-answer processing method according to claim 1, characterized in that, The step of inputting the target user statement into the question-answering fusion model and determining the matching result between the target user statement and the question-answering fusion model includes: The target user's statement is input in parallel into the KBQA question-answering algorithm and the QA question-answering algorithm; The KBQA matching result of the target user's statement is determined according to the KBQA question-answering algorithm, and the QA matching result of the target user's statement is determined according to the QA question-answering algorithm. According to the preset priority, the KBQA matching result and the QA matching result with the higher priority are used as the matching result of the question answering fusion model; The matching in the QA question-answering algorithm is determined based on cosine similarity matching.
5. The question-and-answer processing method according to claim 1, characterized in that, If the target user's statement does not match the question-answering fusion model. The target user's statement is input into the enhanced intent recognition algorithm to determine the recognition result of the target user's statement; If the enhanced intent recognition algorithm fails to recognize the target user's statement, the response result is output according to the default response strategy.
6. The question-and-answer processing method according to claim 1, characterized in that, In the event that the enhanced intent recognition algorithm fails to recognize the target user's statement, The recognition rate of the enhanced intent recognition algorithm is adjusted according to the preset correction rules, and the answer result is output.
7. A question-and-answer processing device, characterized in that, include: The question-and-answer pattern determination module is used to determine the question-and-answer pattern of the target user's statements based on the preset rules of the Task scenario and the dialogue state detection rules. The question-answering fusion model matching module is used to input the target user statement into the question-answering fusion model and determine the matching result between the target user statement and the question-answering fusion model when the question-answering mode does not belong to the Task scenario mode and the question-answering mode is a non-multi-turn dialogue mode. An enhanced intent recognition algorithm matching module is used to input the target user's statement into the enhanced intent recognition algorithm and determine the recognition result of the target user's statement when the question-and-answer mode belongs to the Task scenario mode or the question-and-answer mode is a multi-turn dialogue mode. The question-answering fusion model is obtained by fusing the graph KBQA question-answering algorithm and the question-answering pair QA question-answering algorithm. The target user statement is input into an enhanced intent recognition algorithm to determine the recognition result of the target user statement, including: Obtain training samples and perform data augmentation on the training samples; Based on the data-augmented training samples, a language representation model BERT is trained to obtain the trained BERT model. The target user's statement is input into the trained BERT model to obtain the sentence vector of the target user's statement; The target user's statement is used to obtain a sparse vector through manually defined feature engineering; the sparse vector obtained by the feature engineering is used to add auxiliary classification feature information to the statement vector. The sentence vector and the sparse vector are concatenated, and the concatenated vector is input into a fully connected layer and a softmax layer to determine the recognition result of the target user's sentence.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the question-and-answer processing method as described in any one of claims 1 to 6.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the question-and-answer processing method according to any one of claims 1 to 6.