A hybrid question answering method based on intent recognition and template matching
By combining feature word matching and the intention recognition method of the BERT-textCNN model, the problem that existing question-and-answer systems cannot understand user intentions and recognize multiple intentions is solved, and more efficient question-and-answer system performance is achieved.
Patent Information
- Application Number
- CN202210384730.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-13
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-04-13
AI Technical Summary
The existing question-and-answer system based on template matching cannot understand the problem that user intentions are beyond the scope of preset rules, and the deep learning-based question-and-answer system cannot effectively identify the problem of multiple intentions in a single sentence.
A mixed question-and-answer method based on intent recognition and template matching is adopted. By combining feature word matching and BERT-textCNN model, initial intent recognition and re-identification are performed, Cypher query statements are generated and answers are queried on the knowledge graph.
It improves the accuracy and efficiency of the Q&A system, can effectively identify multiple intentions in a single sentence and generate accurate answers, and overcomes the shortcomings of traditional template matching and deep learning methods.
Smart Images

Figure CN114817497B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and relates to a question-answering method based on a knowledge graph in natural language processing, and in particular to a hybrid question-answering method based on intent recognition and template matching. Background Art
[0002] The earliest research on question-answering systems can be traced back to the 1960s. Simple question-answering modules were constructed through the expression of templates and rules. Among them, the more representative question-answering system is ELAZA, which is a question-answering system based on keyword pattern matching technology. It is used to communicate with patients with mental illness and aims to help them recover. However, the knowledge coverage of the question-answering system at that time was very small and could not solve practical problems. In the 1990s, Microsoft designed a virtual question-answering assistant for users to help users solve problems encountered in the process of using the product. In 1993, MIT built the first Web-based question-answering system START, which can answer millions of questions in fields including science and technology culture, history and geography. Since the 21st century, the computing speed of computer hardware has been significantly improved, which has objectively promoted the development of intelligent question-answering systems, and various products based on intelligent question-answering systems have begun to emerge. For example, Microsoft Xiaobing, Apple's Siri, Tmall Genie, Baidu chat robot Xiaodu, etc., can not only interact with users in text, but also have voice recognition functions.
[0003] Question answering systems can be divided into two categories according to the feedback mechanism of the answer type: generative question answering systems and retrieval question answering systems. Before the knowledge graph was formally proposed, most retrieval question answering systems returned answers through keyword matching and document retrieval. The accuracy of the answers depended largely on the richness of the knowledge base, which directly led to a large amount of redundant information in its knowledge base and required a lot of time for data retrieval. With the formal proposal of the concept of knowledge graph by Microsoft in May 2012, knowledge graph, as a data source mainly based on associated data, not only is data management simple, but it can also provide high-quality data information for question answering systems. Therefore, question answering systems based on knowledge graphs have become one of the main research directions of intelligent question answering systems and have received widespread attention.
[0004] Currently, there are two mainstream implementation methods for question-answering systems based on knowledge graphs:
[0005] (I) Template matching-based methods, whose main idea is to achieve structured representation of questions through semantic parsing-related technologies, such as query templates, question templates, syntactic dependencies, etc. In the research on question-answering systems in the medical field, Ruan Tong and Shanghai Shuguang Hospital jointly studied and constructed a knowledge graph of traditional Chinese medicine. Using the idea of template matching, they built a traditional Chinese medicine question-answering and auxiliary prescription system based on the knowledge graph of traditional Chinese medicine. Through word segmentation, the main contents of the knowledge graph, including disease aspects, symptom library, Chinese herbal medicine library, and prescription library, are matched and translated, and certain rules are used to answer template combination questions composed of entities, attributes, and relationships. Cui et al. start from the questions raised by users, convert user questions into a relationship path represented by a structured representation, and then understand the questions based on fuzzy relationship matching of statistical models.
[0006] (II) Methods based on deep learning, the main idea is to convert the structured representation of the question into a vector representation through a deep neural network. Yin et al. implemented simple question answering based on a convolutional neural network. They first used n-gram question text to search the knowledge base to generate a set of candidate knowledge base facts, and then mapped the elements in the question and knowledge base (entity names and relationship names) to a common embedding space through a deep neural network. The answer to the question is obtained by calculating the correlation between the question embedding vector and the knowledge base fact embedding vector. Tan Gang et al. used a bidirectional long short-term memory network to represent the input question as a feature vector, and learned the forward and backward information in the question as much as possible. At the same time, an attention mechanism was added in this process, so that the weights of each part of the question can be distributed differently, and the answer to the question is more explanatory. True et al. first converted the unstructured user question into a structured knowledge graph query question, and then trained two neural networks to directly find the corresponding results through the query question. Borders et al. first used the representation learning method of word vectors for question answering based on knowledge graphs. Starting from analyzing the structure of the knowledge base storage data, the question was parsed into <entity, relationship,? >, finding the answer to the question becomes a process of finding the triple with the highest correlation in the knowledge base. By using natural language processing techniques such as entity recognition, the model is divided into two modules: entity recognition and relationship recognition. The accuracy of answering questions can be improved by improving the recognition accuracy of these two modules respectively.
[0007] However, there is little research on knowledge graphs and question-answering systems in the medical field. Question-answering systems implemented based on traditional template matching methods can only follow pre-set rules and templates, cannot solve question-answering tasks outside the rules and beyond the scope of the template, and cannot truly understand the user's intentions. Although question-answering systems implemented based on deep learning methods can understand the user's true intentions and meet the diverse needs of users to a certain extent, they cannot solve the problem of multi-intention recognition in a single sentence, and the implementation process is relatively complicated. The performance of the question-answering system depends on the training effect of the neural network, and there are problems such as weak interpretability, low efficiency, and poor stability. Summary of the invention
[0008] In order to overcome the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide a hybrid question and answer method based on intent recognition and template matching, in order to solve the problem that the question and answer method based on template matching is limited by pre-set rules and templates and is difficult to correctly understand user intentions, and the question and answer system based on deep learning cannot recognize multiple intentions in a single sentence.
[0009] In order to achieve the above object, the technical solution adopted by the present invention is:
[0010] A hybrid question-answering method based on intent recognition and template matching includes the following steps:
[0011] S1, initial recognition of intent based on feature word matching: Match entities and trigger words from the question input by the user, comprehensively determine the number of intents based on the entity type and trigger word type, and perform initial recognition of the intent;
[0012] S2, intent re-identification based on BERT-textCNN: Use the intent recognition method to directly identify the user's true intention;
[0013] S3, joint decision: The recognition results obtained by S1 and S2 are integrated to determine the user intent. In a single-intent scenario, the recognition result obtained by S2 is used as the determined user intent; in a multi-intent scenario, the intersection of the recognition results obtained by S1 and S2 is used as the determined user intent.
[0014] S4, parsing the question: based on the entities, entity types and determined user intent in the question input by the user, generate the corresponding Cypher query statement;
[0015] S5, Generate Answer: Call Cypher to query the graph, save the returned results, and then apply the pre-defined reply template to organize and process the returned results, generate the corresponding answer and return it to the user.
[0016] In one embodiment, the S1 includes:
[0017] S11: Entity matching based on AC automaton: After the user inputs a question, the AC automaton is used to determine whether all entities in the entity library have appeared in the question one by one, that is, multi-mode matching, to quickly identify the entities and their types in the question input by the user;
[0018] S12: defining trigger words for the question: the trigger words are used to determine the topic of the question input by the user, each topic corresponds to a set of predefined trigger words, and the trigger words of all topics constitute a trigger word library;
[0019] S13: Based on the entity type and question topic in the question input by the user, formulate question classification rules, and directly obtain the user's intention type through the rules, that is, realize the initial recognition of the user's intention.
[0020] In one embodiment, in S1, when the output of the feature word matching is empty, it means that the initial recognition fails to identify the result, and when the output of the feature word matching is not empty, it means that the initial recognition can identify the result.
[0021] In one embodiment, the S2 includes:
[0022] S21: Segment and encode the question input by the user. The input layer of the BERT model consists of three parts: word embedding, position embedding, and sentence segmentation embedding. The embedding vector obtained by adding the three is used as the model input.
[0023] S22: Perform layer normalization on the embedded vector to solve the problem of inconsistent data distribution in the hidden layer of the model and accelerate model training;
[0024] S23: Introducing a multi-head self-attention mechanism, it can learn richer feature information in multiple independent feature spaces in lower dimensions without increasing time complexity;
[0025] S24: Use the output of the BERT model as the input of the textCNN network to obtain more prior knowledge and semantic features;
[0026] S25: In the textCNN network, convolution operation is performed on the sentence vector input by the BERT model to further extract features;
[0027] S26: Perform 1-Max pooling on the result after convolution, that is, select a largest feature from the feature vector generated by each sliding window, and then concatenate the obtained largest features to form a vector representation;
[0028] S27: After feature extraction by the BERT model and the textCNN network, a high-dimensional feature matrix is obtained, which is converted into an N-dimensional vector through a fully connected layer to solve the N classification task;
[0029] S28: The output results of the textCNN network pooling layer are normalized through the softmax layer, and the output results are expressed in the form of probability. Probability values of different sizes indicate the possibility that the output results belong to different intent categories.
[0030] In one embodiment, S4 fills the entities, entity types and determined user intents in the question sentence input by the user into pre-designed slots, thereby generating a corresponding Cypher query statement; when there are multiple determined user intents, they are parsed one by one.
[0031] Compared with the prior art, the present invention transforms the complex question-answering task into an intent recognition task and a template matching task, which includes three stages: multi-intent recognition, question parsing, and answer generation. In the multi-intent recognition stage, which is the most important stage of intelligent question-answering, a joint intent recognition method based on CWM and BERT-textCNN is proposed. Experimental results show that this method not only solves the problem that the deep learning model cannot simultaneously recognize multiple intents in a single sentence; but also effectively solves the problem that traditional template matching cannot understand the user's true intention by introducing a deep pre-trained network, thereby improving the accuracy of question-answering. In the question parsing and answer generation stages, the traditional template matching method is used to improve the overall efficiency of the model while ensuring the accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 Schematic diagram of the hybrid question-answering model based on intent recognition and template matching of the present invention.
[0034] Figure 2 Chinese dictionary tree built for AC automaton algorithm.
[0035] Figure 3 This is the joint intent recognition model structure based on CWM and BERT-textCNN of the present invention.
[0036] Figure 4 This is the BERT network structure.
[0037] Figure 5 It is the textCNN network structure.
[0038] Figure 6 This is a joint decision-making flow chart of the present invention. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] The traditional template matching question-answering method relies on pre-set rules and templates, cannot solve question-answering tasks outside the rules and beyond the scope of the template, and cannot truly understand the user's intention. This paper proposes a hybrid question-answering method based on intention recognition and template matching. Figure 1 The present invention mainly includes three stages: multi-intention recognition, question parsing and answer generation. The specific process is as follows:
[0041] Step 1: Initial recognition of intent based on Characteristic Word Matching (CWM): Match entities and trigger words from the question input by the user, comprehensively judge the number of user intents based on the entity type and trigger word type, and perform initial recognition of the intent.
[0042] In this step, it is necessary to pre-build an entity library, a trigger word library, and intent classification rules; then match the question entered by the user with the entity library and the trigger word, and finally classify the user intent according to the matching results according to the rules to achieve initial recognition of the user intent. The specific implementation method is as follows:
[0043] Step 1-1: Entity matching based on AC automaton: After the user enters the question, construct Figure 2 The Chinese dictionary tree shown uses the AC automaton algorithm to determine whether all entities in the entity library have appeared in the question, that is, multi-mode matching, so as to quickly identify the entities and their types in the question input by the user. For example, the user inputs: What examinations are needed for bronchitis? The result returned by the entity matching is: {bronchitis: disease}.
[0044] Step 1-2: Define the trigger words of the question: Trigger words are used to determine the topic of the question input by the user. Each topic corresponds to a set of pre-defined trigger words, and the trigger words of all topics constitute the trigger word library. For example, the trigger words corresponding to the "cause of disease" topic include "cause, cause, lead, cause, why, how, how, how, how, how, how, why, how, how, will lead, will cause", etc. It can be seen that the trigger word library needs to be continuously expanded and updated according to user needs and language development. The more reasonable and complete the trigger word library is, the more accurate the judgment of the question topic will be.
[0045] A design form of the trigger word library of the present invention is shown in Table 1. According to this trigger word library, the user inputs: What kind of examinations are needed for bronchitis? The question subject is: examination.
[0046] Table 1 Trigger word library for some topics
[0047]
[0048] Steps 1-3: formulate question classification rules based on the entity type and question topic in the user input question, that is, the user intent classification rules, and directly obtain the user intent type through the rules to achieve the initial recognition of the user intent. For example: if the entity type is "disease" and the topic type is "symptoms", the user intent is classified as "query disease symptoms"; if the entity type is "disease" and the topic type is "cause", the user intent is classified as "query disease cause".
[0049] A rule for the intention division of the present invention is shown in Table 2. According to the rule table, the user inputs: What examinations are needed for bronchitis? The entity type is disease, and the subject type is examination, and the user intention is obtained: disease examination items.
[0050] Table 2 Some question intention types and their rules
[0051] Question Intent Type rule Symptoms Entity Type: Disease; Subject Type: Symptoms Symptom diagnosis Entity Type: Symptom; Subject Type: Symptom Causes of Disease Entity Type: Disease; Subject Type: Cause Disease complications Entity Type: Disease; Subject Type: Complications Good food No negative words, entity type: disease; topic type: food Avoid foods There are negation words, entity type: disease; topic type: food Food Benefits Entity type: food; Topic type: food, efficacy and curative effect Recommended drugs Entity Type: Disease; Subject Type: Drug Drug efficacy Entity Type: Drug; Subject Type: Efficacy and Effectiveness Disease screening items Entity Type: Disease; Subject Type: Examination Check items for diseases Entity type: examination; Subject type: examination, efficacy and efficacy Disease prevention Entity Type: Disease; Topic Type: Prevention Disease treatment cycle Entity type: disease; Topic type: treatment cycle Disease treatment Entity type: disease; Topic type: treatment Disease cure rate Entity type: disease; Topic type: cure rate Disease-susceptible population Entity type: disease; Topic type: susceptible population Disease Introduction Entity Type: Disease; Subject Type: None Symptom description Entity Type: Symptom; Subject Type: None
[0052] In this step, when the output of the feature word matching is empty, it means that the initial recognition failed to identify the result. When the output of the feature word matching is not empty, it means that the initial recognition can identify the result. The output results of the initial intent are often empty in most cases. Because users ask questions in various ways and use different words, the same intent can be asked in many words and ways. That is, the trigger vocabulary shown in Table 1 is difficult to cover all situations, and the rules in Table 2 are also difficult to cover all situations. When the trigger word in the user's query statement is outside the vocabulary range or exceeds the definition of the rule, the output result may be empty.
[0053] Step 2: Intent re-identification based on BERT-textCNN: The intent recognition method directly identifies and judges the user's true intention by training the BERT-textCNN deep neural network. This method is used to accurately identify the user's intention again and correct the CWM results.
[0054] In this step, the intent recognition method based on BERT-textCNN captures the deep semantics in the sentence and accurately calculates the probability of each intent, so that user intent outside the template rules can also be accurately recognized, thereby improving and correcting the results of CWM. Figure 3, the model mainly consists of four parts: BERT layer, textCNN layer, fully connected layer and softmax layer. The specific implementation steps are as follows:
[0055] Step 2-1: Segment and encode the question input by the user. For the specific structure of the BERT model, see Figure 4 , its input layer consists of three parts: word embedding, position embedding, and sentence segmentation embedding. The three are added together as the total word embedding for input, specifically:
[0056] E=E token +E position +E segment
[0057] In the formula, E represents the model input, E token represents word embedding, E posption represents the position embedding, E segment Represents sentence segmentation embedding;
[0058] Step 2-2: Normalize the embedding vector layer by layer to solve the problem of inconsistent data distribution in the hidden layer of the model and accelerate model training. For a word embedding in E, e = [x0, x1, ..., x H-1 ], x k is the k-th dimension component of e, k = 0, 1, ..., H-1, H is the length of the word embedding. Then the layer normalization formula is as follows:
[0059]
[0060] In the formula, y k is the output, α k and β k are learned parameters used to prevent the model’s representation ability from degrading, μ and σ 2 are the mean and variance respectively.
[0061] Step 2-3: Introduce a multi-head self-attention mechanism to learn richer feature information in multiple independent feature spaces at a lower dimension without increasing the time complexity. The calculation formula is as follows:
[0062]
[0063] Where Q, K, and V are the matrices W of the input vector through three learnable weights. q , W k , W V The query matrix, key matrix and value matrix obtained by mapping, d k is the length of each header vector.
[0064] Step 2-4: Use the output of the BERT model as the input of the textCNN network to obtain more prior knowledge and semantic features. For the specific structure of the textCNN network, see Figure 5 .
[0065] Step 2-5: In the textCNN network, convolution operation is performed on the sentence vector input by the BERT model to further extract features. If the word vector X of the BERT input, the i-th convolution kernel C i , use the convolution kernel to convolve the input word vector X to obtain a T×1 one-dimensional vector H i , where T is the dimension of the one-dimensional vector, T = L-M+1. It is expressed as follows:
[0066]
[0067] Among them, the size of X is L×W, L is the length of the input word vector, W is the dimension of the word vector, and C i The size of is M×W, where M is the size of the convolution kernel.
[0068] Step 2-6: Perform 1-Max pooling on the result after convolution, that is, select the largest feature from the feature vector generated by each sliding window, and then concatenate the largest features to form a vector representation. i =(h0,h1,…,h i ,…,h T-1 ), then the output after maximum pooling is as follows:
[0069] y i =max(h0,h1,…,h i ,…,h T-1 )
[0070] where h i is the feature vector generated by the i-th sliding of the convolution kernel.
[0071] Step 2-6: After feature extraction from the BERT model and the textCNN network, a high-dimensional feature matrix is obtained. The high-dimensional feature matrix is converted into an N-dimensional vector through a fully connected layer to solve the N classification task. The output of the fully connected layer is as follows:
[0072] Z = tanh(YW N +b N )
[0073] Step 2-7: Normalize the output of the textCNN pooling layer through the softmax layer and express the output in the form of probability. i , and the corresponding output s is obtained through the softmax layeri , as follows:
[0074]
[0075] Where n is the number of neurons in the output layer, It means to find the exponent. i ∈[0,1], for all neurons s i The sum is:
[0076]
[0077] It can be seen that the output of the fully connected layer, after being converted by the softmax function, can satisfy the characteristics of the probability expression. Probability values of different sizes indicate the possibility that the result belongs to different intent categories.
[0078] Step 3: Joint decision-making: The results of the two intent recognition methods in step 1 and step 2 are integrated according to a certain strategy to determine the user's intent. Figure 6 As shown in the figure, the user query is first initially identified by CWM. Since CWM executes queries with strong regularity efficiently and accurately, if the result can be identified, the user intent can be directly returned. However, in most cases, the user's query is not very regular, and the trigger vocabulary cannot be absolutely complete and reasonable. At this time, CWM cannot identify the user's intent, and the returned result is empty. It is necessary to use the BERT-textCNN model to re-identify the intent and further lock the user's intent. Specifically, in a single-intent scenario, the recognition result obtained in step two is the determined user intent; in a multi-intent scenario, the intersection of the recognition results obtained in step one and step two is the determined user intent.
[0079] In one embodiment, the fusion result of this step is a label corresponding to the intent type, for example, 0: definition, 1: cause, 2: prevention, 3: disease symptoms, 4: complications, 5: treatment methods, 6: department, 7: susceptible population, 8: cure rate, 9: contraindications, 10: examination, 11: treatment cycle, 12: others. Therefore, the fusion result of 5 indicates that the user intends to inquire about the treatment method of the disease.
[0080] Step 4: Question parsing: After multiple intents are identified, the entities, entity types, and determined user intents in the query entered by the user are obtained. Next, the classified results are processed, and the entities, entity types, and determined user intents are correctly filled into the pre-designed slots to generate the corresponding Cypher query statements. When there are multiple determined user intents, they are parsed one by one.
[0081] In this step, the specific implementation method of question parsing is to establish the correspondence between question types and Cypher statements shown in Table 3, where {} represents a slot. A complete Cypher statement can be generated by correctly filling the entity into the slot of the query statement.
[0082] Table 3 Cypher query statements corresponding to some question types
[0083]
[0084]
[0085] Step 5: Answer generation: After question parsing, the corresponding Cypher query language is generated for the question entered by the user. At this point, Cypher is called to query the graph and the returned results are saved. Then, the pre-defined reply template is applied to organize and process the returned results to generate the corresponding answer and return it to the user.
[0086] For example, a user asks: What is the treatment for novel coronavirus pneumonia?
[0087] Then the fixed reply template is: {Entity} can try {treatment method} for treatment.
[0088] Just fill the generated result into {}.
[0089] In order to verify the detection accuracy of the present invention, the present invention conducted experiments on a workstation with a hardware environment of Windows operating system, Intel Corei7-7820X@3.60GHz, 32G memory, two Nvidia RTX 2080TiGPUs, and 11G video memory. The present invention conducted an intent recognition experiment on a self-constructed Chinese medical data set, which has a total of 8910 data items. The results are shown in Table 4:
[0090] Table 4 Experimental results of intention recognition
[0091]
[0092]
[0093] As can be seen from the above table, for the recognition effect of a single intent, the intent recognition method based on BERT-textCNN is better than the intent recognition method based on CWM in most categories, especially in the categories of etiology and taboos, with obvious improvement. This is because the deep pre-training network can extract deep semantic features. In addition, the intent recognition method based on CWM works better in categories such as susceptible populations and departments. This is because the feature words of these categories are easy to extract and summarize, and the vocabulary basically contains all the features of the category in natural language, so the judgment of these categories is more accurate. The data in other categories are diverse and the problems cover many aspects, so the features are relatively complex, and the recognition rates of BERT-textCNN and CWM are lower.
[0094] When multi-intent data is added, 80% of the experimental data is single-intent data, and the remaining 20% is multi-intent data generated by manual combination. A manual evaluation team consisting of 5 people gave a comprehensive evaluation of the question-answering method results based on different intent recognition models. The evaluation criteria are divided into three levels: A, B, and C, where A means that the returned result completely solves the user's problem, B means that the returned result only solves part of the user's problem, and C means that the returned result does not solve the user's problem. The experimental results are shown in Table 5.
[0095] Table 5 Experimental results of question answering task
[0096] method A B C Intent recognition based on CWM 66.4% 10.1% 23.5% Intent Recognition Based on BERT-textCNN 60.8% 25.6% 13.6% Joint intent recognition based on CWM and BERT-textCNN 79.7% 8.9% 11.4%
[0097] As shown in Table 5, the intent recognition based on BERT-textCNN cannot effectively handle multi-intent problems. It cannot give a comprehensive answer to 20% of the multi-intent questions in the test data, so the probability of Class B situation is the highest. However, the intent recognition based on BERT-textCNN can extract the deep semantic information in the user's question. Compared with the traditional CWM-based intent recognition method, the probability of Class C situation is greatly reduced.
[0098] For user-input questions, CWM-based intent recognition can match multiple template libraries in sequence, so it can effectively handle the problem of multiple intents, which reduces the probability of Class B situations. However, due to the difficulty in extracting and exhaustively enumerating all types of features, the formulated rules are difficult to conform to specific reality, resulting in a higher probability of Class C situations in CWM-based intent recognition.
[0099] The joint intent recognition based on CWM and BERT-textCNN not only solves the problem that intent recognition cannot effectively handle multiple intents, but also overcomes the drawback that traditional template matching methods cannot capture deep semantic information. The experimental results show that the joint intent recognition based on CWM and BERT-textCNN has the highest probability of Class A, and the lowest probability of Class B and C, indicating that this method can effectively solve users' problems in the medical field.
[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A hybrid question-answering method based on intent recognition and template matching, characterized in that: The steps include: S1, initial recognition of intent based on feature word matching: Match entities and trigger words from the question input by the user, comprehensively determine the number of intents based on the entity type and trigger word type, and perform initial recognition of the intent; specifically includes: S11: Entity matching based on AC automaton: After the user inputs a question, the AC automaton is used to determine whether all entities in the entity library have appeared in the question one by one, that is, multi-mode matching, to quickly identify the entities and their types in the question input by the user; S12: defining trigger words for the question: the trigger words are used to determine the topic of the question input by the user, each topic corresponds to a set of predefined trigger words, and the trigger words of all topics constitute a trigger word library; S13: Formulate question classification rules based on the entity type and question topic in the user input question, and directly obtain the user's intention type through the rules, that is, realize the initial recognition of the user's intention; S2, intent re-identification based on BERT-textCNN: Use the intent recognition method to directly identify the user's true intention; specifically include: S21: Segment and encode the question input by the user. The input layer of the BERT model consists of three parts: word embedding, position embedding, and sentence segmentation embedding. The embedding vector obtained by adding the three is used as the model input. S22: Perform layer normalization on the embedded vector to solve the problem of inconsistent data distribution in the hidden layer of the model and accelerate model training; S23: Introducing a multi-head self-attention mechanism, it can learn richer feature information in multiple independent feature spaces in lower dimensions without increasing time complexity; S24: Use the output of the BERT model as the input of the textCNN network to obtain more prior knowledge and semantic features; S25: In the textCNN network, convolution operation is performed on the sentence vector input by the BERT model to further extract features; S26: Perform 1-Max pooling on the result after convolution, that is, select a largest feature from the feature vector generated by each sliding window, and then concatenate the obtained largest features to form a vector representation; S27: After feature extraction from the BERT model and the textCNN network, a high-dimensional feature matrix is obtained. The high-dimensional feature matrix is converted into dimensional vector to solve Classification tasks; S28: Normalize the output results of the textCNN network pooling layer through the softmax layer, and express the output results in the form of probability. Probability values of different sizes indicate the possibility that the output results belong to different intent categories. S3, joint decision: The recognition results obtained by S1 and S2 are integrated to determine the user intent. In a single-intent scenario, the recognition result obtained by S2 is used as the determined user intent; in a multi-intent scenario, the intersection of the recognition results obtained by S1 and S2 is used as the determined user intent. S4, parsing the question: based on the entities, entity types and determined user intent in the question input by the user, generate the corresponding Cypher query statement; S5, Generate Answer: Call Cypher to query the graph, save the returned results, and then apply the pre-defined reply template to organize and process the returned results, generate the corresponding answer and return it to the user.
2. The hybrid question-answering method based on intention recognition and template matching according to claim 1 is characterized in that: In the above S1, when the output of the feature word matching is empty, it means that the initial recognition fails to identify the result; when the output of the feature word matching is not empty, it means that the initial recognition can identify the result.
3. The hybrid question-answering method based on intention recognition and template matching according to claim 1 is characterized in that: The S4 fills the entities, entity types and determined user intents in the question input by the user into the pre-designed slots, thereby generating a corresponding Cypher query statement; when there are multiple determined user intents, they are parsed one by one.
