Text processing method and device
By determining the target entity and candidate relationship of the question text in the question answer system, combined with the integrated processing of similarity and feature calculation modules, the problem of reducing the accuracy of answers caused by excessive candidate relationships is solved, and the efficiency and accuracy of answers are improved.
Patent Information
- Application Number
- CN202011191981.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-30
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-10-30
AI Technical Summary
When handling user questions, the existing question-and-answer system has too many candidate relationships, resulting in a decrease in the accuracy of the answers and is unable to effectively answer user questions.
By determining the target entity of the problem text and extracting multiple candidate relationships of the target entity from the preset knowledge base, combining the similarity calculation module and the feature calculation module, integrating the similarity score and feature scores, filtering out the target relationships to Confirm the answer.
It improves the efficiency and accuracy of answer determination, reduces the number of candidate relationships, ensures the accuracy of the target relationship, and achieves high-precision answers in a short time.
Smart Images

Figure CN114444505B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing technology, and in particular to a text processing method and device. Background Art
[0002] With the development of Internet technology, more and more question-answering systems have emerged. In order to accurately answer questions raised by users, it is usually necessary to semantically understand and parse the questions raised by users before extracting answers in the question-answering system. Then, the answers are queried and inferred based on the information from semantic understanding. For example, in the knowledge base question answering (KB-QA) system, the commonly used algorithm flow is entity recognition, entity linking, relationship recognition, and answer retrieval. However, in this process, due to the excessive number of candidate relationships determined for the questions, the accuracy of the answer determination will be greatly affected, and it is impossible to effectively answer the questions raised by users. Therefore, an effective solution is urgently needed to solve the above problems. Summary of the invention
[0003] In view of this, the embodiment of the present application provides a text processing method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a text processing device, a computing device, and a computer-readable storage medium.
[0004] According to a first aspect of an embodiment of the present application, a text processing method is provided, comprising:
[0005] Determine the target entity corresponding to the question text, and extract multiple candidate relations corresponding to the target entity in a preset knowledge base;
[0006] Inputting the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text;
[0007] Inputting the multiple candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text;
[0008] A target relationship is determined among the multiple candidate relationships based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship.
[0009] Optionally, determining the target entity corresponding to the question text includes:
[0010] Obtain the question text, and input the question text into a named entity recognition model for processing to obtain candidate entities of the question text;
[0011] The knowledge base is queried based on the candidate entity, and the target entity corresponding to the question text is determined according to the query result.
[0012] Optionally, extracting a plurality of candidate relations corresponding to the target entity from a preset knowledge base includes:
[0013] Determining a question type of the question text;
[0014] In the case where the question type is the first question type, extracting a plurality of head entity first relations and a plurality of tail entity first relations corresponding to the target entity from the knowledge base as the candidate relations;
[0015] In the case where the question type is the second question type, a plurality of head entity first relations, a plurality of tail entity first relations, a plurality of head entity second relations and a plurality of tail entity second relations corresponding to the target entity are extracted from the knowledge base as the candidate relations.
[0016] Optionally, the inputting the multiple candidate relations and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relation and the question text includes:
[0017] In the case where the question type is the first question type, the plurality of first head entity relationships and the question text are input into the similarity calculation module for processing to obtain a first similarity score between each first head entity relationship and the question text;
[0018] The plurality of tail entity first relations and the question text are input into the similarity calculation module for processing to obtain a second similarity score between each tail entity first relation and the question text.
[0019] Optionally, the step of inputting the plurality of candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text includes:
[0020] Preprocessing the multiple head entity first relations and the question text to obtain a first feature matrix corresponding to each head entity first relation;
[0021] Inputting the first feature matrix into the feature calculation module for processing to obtain the first feature score of each head entity first relationship and the question text;
[0022] Preprocessing the plurality of tail entity first relations and the question text to obtain a second feature matrix corresponding to each tail entity first relation;
[0023] The second feature matrix is input into the feature calculation module for processing to obtain the second feature score of each tail entity first relationship and the question text.
[0024] Optionally, determining a target relationship among the multiple candidate relationships based on the similarity score and the feature score includes:
[0025] Determine a first candidate score for each head entity first relationship according to the first similarity score and the first feature score, and determine a second candidate score for each tail entity first relationship according to the second similarity score and the second feature score;
[0026] A target candidate score is selected from the first candidate scores of the first relations of the head entities and the second candidate scores of the first relations of the tail entities, and the target relation corresponding to the target candidate score is determined.
[0027] Optionally, the inputting the multiple candidate relations and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relation and the question text includes:
[0028] In the case where the question type is the second question type, determining head entity relationship pairs according to the multiple head entity first relationships and the multiple head entity second relationships, and inputting the head entity relationship pairs and the question text into the similarity calculation module for processing to obtain a third similarity score between each head entity relationship pair and the question text;
[0029] Determine tail entity relationship pairs according to the multiple tail entity first relationships and the multiple tail entity second relationships, and input the tail entity relationship pairs and the question text into the similarity calculation module for processing to obtain the sixth similarity score between each tail entity relationship pair and the question text.
[0030] Optionally, determining the head entity relationship pair according to the plurality of head entity first relationships and the plurality of head entity second relationships includes:
[0031] Inputting the plurality of first head entity relationships and the question text into a first similarity calculation model in the similarity calculation module for processing, and obtaining a first similarity score between each first head entity relationship and the question text;
[0032] Screening out a set number of first candidate head entity relationships from the plurality of first head entity relationships according to the first similarity score, and screening out a set number of second candidate head entity relationships from the plurality of second head entity relationships according to the set number of first candidate head entity relationships;
[0033] Inputting the set number of head entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a second similarity score between each head entity second candidate relation and the question text;
[0034] The head entity second target relationship is screened out from the set number of head entity second candidate relationships according to the second similarity score, and the set number of head entity first candidate relationships and the head entity second target relationship are integrated to obtain the head entity relationship pair.
[0035] Optionally, determining a tail entity relationship pair according to the plurality of tail entity first relationships and the plurality of tail entity second relationships comprises:
[0036] Inputting the plurality of tail entity first relations and the question text into the first similarity calculation model in the similarity calculation module for processing, and obtaining a fourth similarity score between each tail entity first relation and the question text;
[0037] Screening out a set number of tail entity first candidate relations from the plurality of tail entity first relations according to the fourth similarity score, and screening out a set number of tail entity second candidate relations from the plurality of tail entity second relations according to the set number of tail entity first candidate relations;
[0038] Inputting the set number of tail entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a fifth similarity score between each tail entity second candidate relation and the question text;
[0039] A tail entity second target relationship is screened out from the set number of tail entity second candidate relationships according to the fifth similarity score, and the set number of tail entity first candidate relationships and the tail entity second target relationship are integrated to obtain the tail entity relationship pair.
[0040] Optionally, the step of inputting the plurality of candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text includes:
[0041] Determine the head entity relationship pair and the tail entity relationship pair according to the multiple candidate relationships;
[0042] Inputting the head entity relationship pair and the question text into the feature calculation module for processing to obtain a first feature score of the head entity relationship pair and the question text;
[0043] The tail entity relationship pair and the question text are input into the feature calculation module for processing to obtain a second feature score of the tail entity relationship pair and the question text.
[0044] Optionally, determining a target relationship among the multiple candidate relationships based on the similarity score and the feature score includes:
[0045] Calculate a first total similarity score of the head entity relationship pair according to the third similarity score and the first feature score;
[0046] Calculate a second total similarity score of the tail entity relationship pair according to the sixth similarity score and the second feature score;
[0047] The head entity relationship pair and the tail entity relationship pair are sorted based on the first similarity total score and the second similarity total score, and the target relationship is determined according to the sorting result.
[0048] Optionally, determining the answer to the question text according to the entity associated with the target relationship includes:
[0049] Determining in the knowledge base an associated entity of the target entity based on the target relationship mapping;
[0050] An answer to the question text is generated according to the associated entity.
[0051] According to a second aspect of an embodiment of the present application, there is provided a text processing device, including:
[0052] A target entity determination module is configured to determine a target entity corresponding to the question text and extract multiple candidate relations corresponding to the target entity from a preset knowledge base;
[0053] A similarity score calculation module is configured to input the plurality of candidate relations and the question text into the similarity calculation module for processing, and obtain a similarity score between each candidate relation and the question text;
[0054] A feature score calculation module is configured to input the plurality of candidate relationships and the question text into the feature calculation module for processing, and obtain a feature score of each candidate relationship and the question text;
[0055] The answer determination module is configured to determine a target relationship among the multiple candidate relationships based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship.
[0056] According to a third aspect of an embodiment of the present application, another text processing method is provided, including:
[0057] Determine a target entity corresponding to the question text, and extract multiple first candidate relations and multiple second candidate relations corresponding to the target entity from a preset knowledge base;
[0058] Determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text;
[0059] Inputting the set number of candidate relationship pairs and the question text into a feature calculation module for processing to obtain a feature score for each candidate relationship pair and the question text;
[0060] A target relationship pair is determined from the set number of candidate relationship pairs based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship pair.
[0061] According to a fourth aspect of an embodiment of the present application, another text processing device is provided, including:
[0062] An extraction module is configured to determine a target entity corresponding to the question text, and extract a plurality of first candidate relations and a plurality of second candidate relations corresponding to the target entity from a preset knowledge base;
[0063] A similarity calculation module is configured to determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text;
[0064] A feature calculation module is configured to input the set number of candidate relationship pairs and the question text into a feature calculation module for processing, and obtain a feature score of each candidate relationship pair and the question text;
[0065] The determination module is configured to determine a target relationship pair from the set number of candidate relationship pairs based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship pair.
[0066] According to a fifth aspect of an embodiment of the present application, there is provided a computing device, including:
[0067] Memory and processor;
[0068] The memory is used to store computer-executable instructions, and the processor implements the steps of the text processing method when executing the computer-executable instructions.
[0069] According to a sixth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of text processing are implemented.
[0070] The text processing method provided by the present application, after obtaining the question text, will determine the target entity of the question text, and at the same time extract multiple candidate relationships corresponding to the target entity in a preset knowledge base, and then input the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text, and at the same time, input the multiple candidate relationships and the question text into a feature calculation module for processing to obtain a feature score between each candidate relationship and the question text, and finally determine the target relationship among the multiple candidate relationships by integrating the similarity scores and the feature scores, and then determine the answer to the question text based on the target relationship, thereby achieving the improvement of the efficiency of determining the answer by reducing the number of candidate relationships in the process of screening the answer to the question text, and at the same time ensuring the accuracy of determining the target relationship by combining the similarity dimension and the feature dimension, further improving the accuracy of determining the answer, and achieving a high-precision answer to the question in a shorter time. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 is a flowchart of a text processing method provided by an embodiment of the present application;
[0072] Figure 2 is a processing flow chart of a text processing method applied to a first-degree relationship provided by an embodiment of the present application;
[0073] Figure 3 is a structural schematic diagram of a text processing device provided by an embodiment of the present application;
[0074] Figure 4 is a flowchart of another text processing method provided by an embodiment of the present application;
[0075] Figure 5 is a processing flow chart of a text processing method applied to a second-degree relationship provided in an embodiment of the present application;
[0076] Figure 6 It is a structural diagram of an entity relationship provided by an embodiment of the present application;
[0077] Figure 7 is a structural schematic diagram of another text processing device provided by an embodiment of the present application;
[0078] Figure 8 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0079] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0080] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0081] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0082] First, the terms involved in one or more embodiments of the present invention are explained.
[0083] First-degree question: A question that can be answered with one query can be understood as a relationship, such as "What is A's position?".
[0084] Second-degree questions: The results that can be obtained through two-step queries can be understood as multiple relationships, such as "Who is the son of the chairman of Group B?"
[0085] KBQA: Knowledge base question answering (KB-QA). KBQA is a question-answering system based on knowledge graph. The basic process is to query the knowledge graph according to the question, and then generate an answer based on the information in the knowledge graph and return it to the user.
[0086] Entity linking: Entity linking (EL) maps entity mentions in text to a given knowledge base (KB).
[0087] Knowledge base: refers to a knowledge base that gathers knowledge in specific fields. The knowledge is organized in unstructured natural language. In order to facilitate computer processing and understanding, the knowledge is formalized and simplified in the form of triples. The triples in the knowledge base are (entity entity, entity relationship relation, entity entity).
[0088] Named Entity Recognition: Named Entity Recognition (NER) refers to the identification of entities with specific meanings in text.
[0089] Similarity score: refers to the similarity score between multiple candidate relationships and the question text in the semantic dimension. The higher the similarity score, the higher the similarity between the candidate relationship and the question text. Conversely, the lower the similarity score, the lower the similarity between the candidate relationship and the question text.
[0090] Feature score: refers to the score of the similarity between multiple candidate relationships and the question text in the feature dimension. The higher the feature score, the higher the similarity between the candidate relationship and the question text. Conversely, the lower the feature score, the lower the similarity between the candidate relationship and the question text.
[0091] Target relationship: refers to the relationship that can help the question text determine the correct answer by screening out from multiple candidate relationships. The entity associated with the target relationship is the answer to the question text.
[0092] BERT model: (Bidirectional Encoder Representations from Transformer) is a bidirectional encoder representation based on Transformer. The foundation of BERT model is Transformer, which comes from attention is all you need. The bidirectional meaning is that when it processes a word, it can take into account the information of the words before and after the word, so as to obtain the semantics of the context.
[0093] In the present application, a text processing method is provided. The present application also relates to a text processing apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0094] In practical applications, since the KBQA relational entities in open fields are usually more complex, for example, the PKUBASE knowledge base contains more than 64 million triples, more than 10 million entities and more than 400,000 relations. When answering questions raised by users, the only way to determine the answers is to search the knowledge base. However, due to the high complexity of the knowledge base, when screening answers to questions, a large number of candidate relations are generally obtained. If the answers are screened based on a large number of candidate relations, the efficiency and accuracy of answer extraction will be greatly reduced. In addition, when facing the problem of multi-degree, it is more likely to cause an explosive growth of candidate relations. Therefore, when extracting answers from the KBQA system in open fields, how to improve the efficiency and accuracy of answer extraction is an important issue that needs to be solved urgently.
[0095] Figure 1 A flowchart of a text processing method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0096] Step S102: determining a target entity corresponding to the question text, and extracting a plurality of candidate relations corresponding to the target entity in a preset knowledge base.
[0097] The text processing method provided by the present application, in order to improve efficiency and accuracy when extracting answers, will determine the target entity of the question text after obtaining the question text, and extract multiple candidate relationships corresponding to the target entity in a preset knowledge base, and then input the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text, and also input the multiple candidate relationships and the question text into a feature calculation module for processing to obtain a feature score between each candidate relationship and the question text, and finally determine the target relationship among the multiple candidate relationships by integrating the similarity scores and the feature scores, and then determine the answer to the question text based on the target relationship, thereby achieving the improvement of the efficiency of determining the answer by reducing the number of candidate relationships in the process of screening answers to the question text, and at the same time ensuring the accuracy of determining the target relationship by combining the similarity dimension and the feature dimension, further improving the accuracy of determining the answer, and achieving a high-precision answer to the question in a shorter time.
[0098] In specific implementation, when the answer to a question is determined through the KBQA system, it is usually necessary to go through the following steps: named entity recognition > entity linking > sentence classification (determining first-degree questions or multi-degree questions) > relationship extraction > relationship sorting > screening of correct answers. In this process, due to the different levels of complexity of different questions, more relationships are obtained during relationship extraction, which will increase the difficulty of screening subsequent answers and affect the accuracy of answer screening. The text processing method provided in this embodiment will further limit the relationship extraction in order to ensure the accuracy and screening efficiency of the answer, thereby reducing the number of candidate relationships while ensuring the accuracy, thereby meeting the needs of subsequent answer determination.
[0099] Based on this, the question text is the question that needs to be answered through the knowledge base corresponding to the KBQA system, and the target entity is the entity contained in the question text. The entity exists in the knowledge base, so that the question to which the entity belongs can be answered through the knowledge base. Correspondingly, the candidate relationship specifically refers to a relationship that is directly or indirectly associated with the target entity. By determining the target relationship from the candidate relationships, the correct answer to the question can be screened out.
[0100] Furthermore, in the process of determining the target entity corresponding to the question text, since different question texts have different entities, the difficulty of extraction is also different. In order to accurately extract entities to facilitate the subsequent text processing process, the entity extraction process can be completed through a named entity recognition model. In this embodiment, the specific implementation method is as follows:
[0101] Obtain the question text, and input the question text into a named entity recognition model for processing to obtain candidate entities of the question text;
[0102] The knowledge base is queried based on the candidate entity, and the target entity corresponding to the question text is determined according to the query result.
[0103] Specifically, the candidate entity refers to the entity contained in the question text. Since there may be entities with the same name in the knowledge base, it is necessary to query the knowledge base through the candidate entity to determine the target entity corresponding to the question text, so as to further ensure the accuracy of subsequent screening answers.
[0104] Among them, the named entity recognition model specifically refers to a model that can obtain candidate entities after processing the question text. The specific implementation method is to extract candidate entities by adopting data annotation, that is, marking each character in the question text through B (Begin, indicating the beginning), I (intermediate, indicating the middle), E (End, indicating the end), S (Single, indicating a single character), and O (Other, indicating other, used to mark irrelevant characters). The result output by the named entity recognition model is a sequence carrying an identifier, and the candidate entities in the question text can be determined through this sequence; for example, the question text is "Is A's computer repaired?" The question text is processed by the named entity recognition model, and the obtained sequence is (S-PER, O, B-ORG, I-ORG, E-ORG, O, O, O, O), and the person name entity "A" and the place name entity "computer" can be determined through this sequence.
[0105] In specific implementation, the named entity recognition model includes but is not limited to a hidden Markov model (HMM), a maximum entropy model (ME), a support vector machine (SVM) or a conditional random field (CRF). It only needs to be able to complete the extraction of candidate entities in the question text during the named entity recognition process. In actual applications, the selection of the named entity recognition model can be set according to the actual application scenario, and this embodiment does not make any limitation here.
[0106] Based on this, after obtaining the question text, the question text is input into the named entity recognition model for processing to obtain the candidate entities in the question text. Then, the knowledge base is queried based on the candidate entities, and the entity corresponding to the question text is selected as the target entity according to the query results.
[0107] For example, the question text is "Where does A live?" At this time, the candidate entity "A" in the question text can be extracted through the named entity recognition model. The knowledge base not only has entities such as name A, but also place name A, song A and product name A. Different entity A will correspond to different relationships. Therefore, in order to accurately determine the answer to the question text "Where does A live?", the target entity corresponding to the question text will be determined through the semantic dimension, that is, the target entity is name: A.
[0108] In summary, in order to improve the accuracy of subsequent answer determination, the named entity recognition model will be used to extract entities, and the target entities will be determined through semantic analysis, which will further promote the accuracy of subsequent screening of correct answers.
[0109] Furthermore, after determining the target entity of the question text, since the structure of the question text is composed of entity plus relationship, when screening the correct answer, it is also necessary to determine the entity plus relationship with the same structure as the question text in the knowledge base, so as to determine the correct answer. However, due to the different complexity of different question texts, it is necessary to determine a large number of candidate relationships, and then screen out the target relationship that satisfies the screening of the correct answer to determine the answer. In this embodiment, different processing methods are used to complete the determination of the answer for questions of different complexity. The specific implementation method is as follows:
[0110] Determining a question type of the question text;
[0111] In the case where the question type is the first question type, extracting a plurality of head entity first relations and a plurality of tail entity first relations corresponding to the target entity from the knowledge base as the candidate relations;
[0112] In the case where the question type is the second question type, a plurality of head entity first relations, a plurality of tail entity first relations, a plurality of head entity second relations and a plurality of tail entity second relations corresponding to the target entity are extracted from the knowledge base as the candidate relations.
[0113] Specifically, the first question type specifically refers to that the question text is a single-entity first-degree question type, and the second question type specifically refers to that the question text is a single-entity second-degree question type or a single-entity multiple-degree question type; based on this, since a single-entity first-degree question only needs to determine the first-degree relationship to complete the determination of the answer, the number of determined candidate relationships is less than that of a single-entity second-degree question or a single-entity multiple-degree question. It is only necessary to accurately determine the target entity, and then select the target relationship from the first-degree relationship corresponding to the target entity to complete the answer to the question text; while in a single-entity second-degree question or a single-entity multiple-degree question, it is necessary not only to determine the first-degree relationship corresponding to the target entity, but also to determine the second-degree relationship of the target entity, and then screen the target relationship by combining the first-degree and second-degree relationships to complete the answer to the question text.
[0114] Based on this, before processing the question text, it is necessary to determine the question type of the question text. The process of determining the question type of the question text is actually to divide the question text into corresponding intent categories through intent recognition, and determine the question type of the question text through the intent category. If it is identified that the intent expressed by the question text is direct intent, it can be determined that the intent category into which the question text is divided is a direct intent category, and the question type of the question text is determined to be a first-degree question; if it is identified that the intent expressed by the question text is indirect intent, it can be determined that the intent category into which the question text is divided is an indirect intent category, and the question type of the question text is determined to be a second-degree question or a multi-degree question, so as to facilitate the subsequent text processing in different ways for different types of questions.
[0115] Among them, when identifying the intent of the question text, it includes but is not limited to being implemented through statistical feature classification methods (implementing intent classification through training classifiers, such as Naive Bayes (NB), support vector machine (SVM) or logistic regression, etc.), implemented through recognition models (such as LSTM and Softmax combination (using LSTM to extract features from word vectors of the question text, and combining Softmax to complete intent classification), or CNN and Softmax combination), or implemented through dictionary + rules (selecting a domain dictionary for the domain of the question text and combining it with preset rules). During specific implementation, the method for determining the question type of the question text can be selected according to the actual application scenario, and this embodiment does not make any limitation here.
[0116] After the question type of the question text is determined, different processing methods are selected according to the question type to screen the answers. This embodiment will describe the question text as the first question type (single-entity first-degree question type). Accordingly, the head entity first relationship specifically refers to: a first-degree relationship determined with the target entity as the starting feature, and the tail entity first relationship specifically refers to: a first-degree relationship determined with the target entity as the terminal feature; that is, all relationships corresponding to the target entity are determined in the knowledge base to generate the multiple head entity first relationships and the multiple tail entity first-degree relationships as the candidate relationships for subsequent processing; wherein, a first-degree relationship specifically refers to a relationship that has a direct connection with an entity.
[0117] Continuing with the above example, after determining that the target entity of the question text "Where does A live?" is A, it is determined that the question text belongs to a first-degree question, and then the relationships directly corresponding to the target entities are extracted from the knowledge base, and the first-degree relationships of the head entity are determined to be: name relationship (A's name), address relationship (A's address), age relationship (A's age), etc., and the first-degree relationships of the tail entity are determined to be: father-son relationship (father is A), identity relationship (identity is A), position relationship (position is A), etc., as candidate relationships of the question text, which are used to screen the correct answer to the question text.
[0118] In summary, since different types of questions are handled differently, in order to improve the efficiency of question handling, questions will be classified before processing, so that the method matching the question type can be selected to complete the subsequent answer determination process, so as to improve the efficiency of question answering.
[0119] Step S104: input the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text.
[0120] Specifically, on the basis of the above-mentioned determination of the multiple candidate relations corresponding to the question text, further, in order to improve the accuracy of the answer, the similarity can be calculated from the semantic dimension, and the similarity can also be calculated from the feature dimension, so as to obtain an answer that meets the response requirements; based on this, in the analysis process of the semantic dimension, the similarity calculation module will be combined to complete the calculation of the similarity between each candidate relation and the question text, wherein the similarity calculation module is integrated by different semantic similarity calculation models, and different semantic similarity calculation models will correspond to different question types; for example, if a single-entity first-degree question contains only one candidate relation, when calculating the similarity between the relation and the question text through the semantic similarity calculation model, it is only necessary to calculate the encoding vector corresponding to the relation and the encoding vector corresponding to the question text By measuring the cosine similarity between the two, the similarity score between the relationship and the question text can be obtained; and there are two candidate relationships included in the single-entity second-degree problem. If the semantic similarity model corresponding to the single-entity first-degree problem is still used to calculate the similarity between the relationship and the question text, it may lead to a problem of excessive error in the similarity score, which may affect the subsequent processing process. In order to be able to accurately process question texts of different question types, in actual applications, when calculating the similarity between the candidate relationship and the question text in the single-entity second-degree problem, a semantic similarity calculation model that is only used for calculating the similarity between the candidate relationship and the question text in the single-entity second-degree problem will be configured in the similarity calculation module, thereby accurately calculating the similarity score between the candidate relationship and the question text in the single-entity second-degree problem.
[0121] In specific implementation, when calculating the similarity between the candidate relationship and the question text through the semantic similarity model, the question text and the candidate relationship are first embedded respectively to obtain the question text vector corresponding to the question text and the candidate relationship vector corresponding to the candidate relationship; secondly, the question text vector and the candidate relationship vector are encoded respectively to obtain the question text encoding vector corresponding to the question text vector and the candidate relationship encoding vector corresponding to the candidate relationship vector; finally, the cosine values of the question text encoding vector and the candidate relationship encoding vector are calculated to determine the similarity score between the question text and the candidate relationship; in practical applications, the semantic similarity calculation model can be constructed using the BERT model, that is, the cosine similarity is calculated after the encoding vector is obtained in the BERT model.
[0122] It should be noted that the similarity score refers to the semantic similarity score between each candidate relationship and the question text. The higher the similarity score, the higher the semantic similarity between the candidate relationship and the question text. Conversely, the lower the similarity score, the lower the semantic similarity between the candidate relationship and the question text.
[0123] Further, in the case where the question text is of the first question type, it is only necessary to calculate the similarity score between the first-degree relationship and the question text. In this embodiment, the specific process of calculating the similarity score is as follows:
[0124] The multiple head entity first relations and the question text are input into the similarity calculation module for processing to obtain a first similarity score between each head entity first relation and the question text; and the multiple tail entity first relations and the question text are input into the similarity calculation module for processing to obtain a second similarity score between each tail entity first relation and the question text.
[0125] Specifically, since the multiple candidate relations include multiple head entity first relations and multiple tail entity first relations, and the structures of the head entity first relations and the tail entity first relations are different, the similarity scores will be calculated for the two relations separately, that is, the multiple head entity first relations and the question text are input into the similarity calculation module for processing to obtain a first similarity score between each head entity first relation and the question text, and at the same time, the multiple tail entity first relations and the question text are input into the similarity calculation module for processing to obtain a second similarity score between each tail entity first relation and the question text.
[0126] In specific implementation, since the structures of the first relationship of the head entity and the first relationship of the tail entity are different, they will be converted into different input formats according to their respective structures before being input into the similarity calculation module for processing. In practical applications, <entity><relationship> <pad>To express the relationship sequence of the first relationship of the head entity, use <pad><relationship><entity> expresses the relationship sequence of the first relationship of the last entity; <pad>Indicates the location information of entities and relationships in the knowledge base. <Entity> represents the target entity, and <Relationship> represents the first relationship of each head entity or the first relationship of each tail entity.
[0127] In addition, the first relationship of the head entity and the first relationship of the tail entity can also be represented by other relationship sequences, as long as they conform to the input format of the similarity calculation module. This embodiment does not make any limitations here.
[0128] Continuing with the above example, after determining the first-degree relationship of the head entity and the first-degree relationship of the tail entity in the question text "Where does A live?", each relationship will be transformed. The relationship sequence corresponding to the name relationship (the name of A) is <Name><pad_S1>, the relationship sequence corresponding to the address relationship (the address of A) is <Address><pad_S2>, the relationship sequence corresponding to the age relationship (the age of A) is <Age><pad_S3>...; and the relationship sequence corresponding to the father-son relationship (the father is A) is <pad_P1><Father-Son>, the relationship sequence corresponding to the identity identification relationship (the identity identification is A) is <pad_P2><Identity Identification>, the relationship sequence corresponding to the employment relationship (the position is A) is <pad_P3><Employment>...
[0129] Furthermore, each relationship sequence and the question text are respectively input into the BERT model for calculating the similarity score. It is determined that in the first-degree relationship of the head entity: the similarity score between the name relationship (the name of A) and the question text is 0.3, the similarity score between the address relationship (the address of A) and the question text is 0.85, the similarity score between the age relationship (the age of A) and the question text is 0.25...; it is determined that in the first-degree relationship of the tail entity: the similarity score between the father-son relationship (the father is A) and the question text is 0.20, the similarity score between the identity identification relationship (the identity identification is A) and the question text is 0.10, the similarity score between the employment relationship (the position is A) and the question text is 0.30...
[0130] In summary, since the correct answer corresponding to the question text may be determined based on the first relationship of the head entity or the first relationship of the tail entity, when calculating the similarity score, different relationships will be calculated separately to facilitate more accurate analysis of the semantic similarity between each relationship and the question text, so as to improve the accuracy of determining the answer subsequently.
[0131] Step S106, input the multiple candidate relationships and the question text into the feature calculation module for processing, and obtain the feature scores of each candidate relationship and the question text.
[0132] Specifically, on the basis of the above-mentioned determination of multiple candidate relations corresponding to the question text, further, in order to improve the accuracy of the answer, the similarity will also be calculated from the feature dimension, so as to obtain an answer that meets the response requirements; based on this, in the analysis process of the feature dimension, the feature calculation module will be combined to complete the calculation of the similarity between each candidate relation and the question text, wherein the feature calculation module is integrated by different feature similarity calculation models, and different feature similarity calculation models will correspond to different question types; since there is only one candidate relation contained in a single-entity first-degree question, when the similarity between the relation and the question text in the feature dimension is calculated by the feature similarity calculation model, it is only necessary to obtain the feature matrix of the candidate relation and the feature matrix of the question text to complete the task. The similarity between the two in the feature dimension is calculated; and there are two candidate relations contained in the single-entity two-degree problem. At this time, if the above-mentioned feature similarity calculation model is still used to calculate the feature similarity between the two candidate relations and the question text, there will be a split problem, that is, the feature similarity between each candidate relation and the question text is calculated separately, and the feature similarity between the two candidate relations and the question text cannot be considered as a whole. Therefore, when calculating the feature similarity between the candidate relation and the question text in the single-entity two-degree problem, a feature similarity calculation model for calculating the feature similarity between the candidate relation and the question text in the single-entity two-degree problem will be configured in the feature calculation module, so as to realize the consideration of the similarity between the candidate relation and the question text in the feature dimension as a whole, so as to improve the processing efficiency of subsequent processing.
[0133] In specific implementation, when calculating the similarity between candidate relations and question texts through a feature similarity calculation model, in order to improve the accuracy of feature score calculation and reduce the resources consumed by training the model in the model preparation stage, the LGBM classifier is preferentially used to construct the feature similarity calculation model.
[0134] It should be noted that the feature score refers to the feature similarity score between each candidate relationship and the question text. The higher the feature score, the higher the feature similarity between the candidate relationship and the question text. Conversely, the lower the feature score, the lower the feature similarity between the candidate relationship and the question text. The feature score specifically refers to the score calculated from multiple angles such as the number of characters, the number of words, the number of character overlaps and / or the number of word overlaps between the candidate relationship and the question text, and refers to the degree of similarity between the two in form / format.
[0135] In addition, the similarity calculation module and feature calculation module in this embodiment are not actually functionally divided or separated. The similarity calculation process and feature calculation process defined by such a group of functional modules should be understood as a functional module framework that mainly solves the technical similarity calculation problem and feature calculation problem through the content recorded in this embodiment, and should not be understood as a physical device that mainly implements the solution in hardware.
[0136] Further, in the case where the question text is of the first question type, it is only necessary to calculate the feature score of the first-degree relationship and the question text. In this embodiment, the specific process of calculating the feature score is as follows:
[0137] Preprocessing the multiple head entity first relations and the question text to obtain a first feature matrix corresponding to each head entity first relation; inputting the first feature matrix into the feature calculation module for processing to obtain a first feature score of each head entity first relation and the question text;
[0138] Preprocess the multiple tail entity first relations and the question text to obtain a second feature matrix corresponding to each tail entity first relation; input the second feature matrix into the feature calculation module for processing to obtain a second feature score of each tail entity first relation and the question text.
[0139] Specifically, since the multiple candidate relations include multiple head entity first relations and multiple tail entity first relations, and the structures of the head entity first relations and the tail entity first relations are different, the feature scores will be calculated for the two relations separately, and in order to meet the input of the feature calculation module, the multiple head entity first relations and the question text will be preprocessed to obtain the first feature matrix corresponding to each head entity first relation, and the multiple tail entity first relations and the question text will also be preprocessed to obtain the second feature matrix corresponding to each tail entity first relation.
[0140] Then, the first feature matrix is input into the feature calculation module for processing to obtain the first feature score of each head entity first relationship and the question text, and the second feature matrix is input into the feature calculation module for processing to obtain the second feature score of each tail entity first relationship and the question text.
[0141] In specific implementation, the preprocessing process refers to converting the feature matrix according to preset feature processing dimensions, and the feature processing dimensions may include relationship length feature dimensions, relationship and question text word overlap feature dimensions, relationship popularity feature dimensions in the knowledge base, appearance feature dimensions in the question text and / or relative position feature dimensions with the entity, etc. This embodiment does not make any limitation here.
[0142] In addition, when the question type is a first-order question type, step S104 and step S106 may be performed simultaneously or in a set execution order, and this embodiment does not impose any limitation thereto.
[0143] Continuing with the above example, after determining the first-degree relationship of the head entity and the first-degree relationship of the tail entity of the question text "Where does A live?", the first-degree relationship of each head entity and the question text will be transformed into a matrix based on the feature processing dimension, and the feature expression matrix of the name relationship (A's name) and the question text, the feature expression matrix of the address relationship (A's address) and the question text, the feature expression matrix of the age relationship (A's age) and the question text will be obtained respectively...; at the same time, the first-degree relationship of each tail entity and the question text will also be transformed into a matrix based on the feature processing dimension, and the feature expression matrix of the father-son relationship (the father is A) and the question text will be obtained respectively, the feature expression matrix of the identity relationship (the identity is A) and the question text, the feature expression matrix of the position relationship (the position is A) and the question text will be obtained respectively...
[0144] Afterwards, each feature expression matrix is input into the LGBM classifier to calculate the feature similarity, and the feature score between the name relationship (A's name) and the question text is 0.10; the feature score between the address relationship (A's address) and the question text is 0.70, the feature score between the age relationship (A's age) and the question text is 0.25...; the feature score between the father-son relationship (the father is A) and the question text is 0.20, the feature score between the identity relationship (the identity is A) and the question text is 0.10, the feature score between the position relationship (the position is A) and the question text is 0.15...
[0145] To summarize, since the correct answer corresponding to the question text may be determined based on the first relationship of the head entity or the first relationship of the tail entity, different relationships will be calculated separately when calculating the feature scores to facilitate a more accurate analysis of the feature similarity between each relationship and the question text, so as to improve the accuracy of the subsequent answer determination.
[0146] Step S108, determining a target relationship among the multiple candidate relationships based on the similarity score and the feature score, and determining an answer to the question text according to an entity associated with the target relationship.
[0147] Specifically, based on the similarity scores and feature scores obtained above between each candidate relationship and the question text, the target relationship will be further determined in combination with the semantic dimension and the feature dimension. The target relationship specifically refers to a relationship that can determine the correct answer to the question text. Accordingly, the architecture of entity relationships in the knowledge base is entity-relationship-entity. After determining the target entity and the target relationship, another connected entity can be determined based on the target entity and the target relationship, and the answer to the question text can be determined through this entity.
[0148] The target relationship is determined by jointly analyzing the semantic dimension and the feature dimension. Therefore, the similarity scores of the candidate relationships in the semantic dimension and the feature scores in the feature dimension are summed, and the candidate relationship with the largest sum is selected as the target relationship to screen the correct answer to the question text. In this embodiment, the specific implementation method is as follows:
[0149] Determine a first candidate score for each head entity first relationship according to the first similarity score and the first feature score, and determine a second candidate score for each tail entity first relationship according to the second similarity score and the second feature score;
[0150] A target candidate score is selected from the first candidate scores of the first relations of the head entities and the second candidate scores of the first relations of the tail entities, and the target relation corresponding to the target candidate score is determined.
[0151] Specifically, the first candidate score specifically refers to the score obtained by integrating the similarity scores of the feature dimension and the semantic dimension of the first relationship of each head entity, the second candidate relationship specifically refers to the score obtained by integrating the similarity scores of the feature dimension and the semantic dimension of the first relationship of each tail entity, the target candidate score specifically refers to the score with the highest similarity score, and the target relationship is the relationship selected from the candidate relationships according to the highest score, and the answer to the question text can be determined through the target relationship.
[0152] Based on this, first, the first candidate score of each head entity first relationship is determined based on the first similarity score and the first feature score, and the second candidate score of each tail entity first relationship is determined according to the second similarity score and the second feature score. Secondly, the head entity first relationship and the tail entity first relationship can be sorted in descending order according to the candidate scores, and then the relationship ranked first is selected as the target relationship.
[0153] Furthermore, after determining the target relationship, it is necessary to determine the answer to the question text according to the target relationship. In this embodiment, the specific implementation method is as follows:
[0154] Determining in the knowledge base an associated entity of the target entity based on the target relationship mapping;
[0155] An answer to the question text is generated according to the associated entity.
[0156] Specifically, the mapped associated entity can be determined in the knowledge base through the target entity and the target relationship, and then the correct answer to the question text can be generated according to the associated entity.
[0157] Continuing with the above example, add the similarity score and feature score of the name relationship (A's name) and the question text to 0.30+0.10=0.40; add the similarity score and feature score of the address relationship (A's address) and the question text to 0.85+0.70=1.55; add the similarity score and feature score of the age relationship (A's age) and the question text to 0.25+0.25=0.5...; add the similarity score and feature score of the father-son relationship (the father is A) and the question text to 0.20+0.20=0.40; add the similarity score and feature score of the identity relationship (the identity is A) and the question text to 0.10+0.10=0.20; add the similarity score and feature score of the position relationship (the position is A) and the question text to 0.30+0.15=0.45...
[0158] After calculating the total score of each first-degree relationship and the question text (combining the similarity score and the feature score), the multiple first-degree relationships of the head entity and the multiple first-degree relationships of the tail entity are sorted according to the total score. The sorting result is address relationship (A's address) > age relationship (A's age) > position relationship (position is A)...; then the address relationship (A's address) is selected as the target relationship according to the sorting result, and the mapped associated entity is determined to be city A in the knowledge base corresponding to the KBQA system through the address relationship (A's address), and the answer to the question text "Where does A live?" is determined to be "city A".
[0159] In summary, by combining the semantic dimension and the feature dimension to conduct an overall analysis of the target relationship corresponding to the question text, not only can the accuracy of the target relationship determination be guaranteed, but also the answer to the question text can be effectively analyzed, thereby meeting the user's question and answer needs.
[0160] Another specific embodiment is provided in this implementation mode. This embodiment will be described by taking the question text as the second question type as an example to specifically explain how to complete the determination of the correct answer to the question text in a second-degree question or a multi-degree question. It should be noted that the corresponding explanations of terms or corresponding contents in this embodiment can refer to the specific descriptions in the above embodiments, and this embodiment will not be described in detail here. How to complete the determination of the correct answer to the question text in a second-degree question or a multi-degree question, the specific implementation method is as follows:
[0161] Step 1, determine the target entity corresponding to the question text, and extract multiple head entity first relations, multiple tail entity first relations, multiple head entity second relations and multiple tail entity second relations corresponding to the target entity in a preset knowledge base.
[0162] In actual applications, since the relationships involved in second-degree questions are relatively complex, in order to improve the accuracy of answers to second-degree questions, this embodiment will reduce the number of candidate relationships layer by layer when determining the target relationship, and improve the accuracy of answer screening through feature dimensions and semantic dimensions, thereby achieving responses to second-degree questions.
[0163] In specific implementation, as the degree of the question text increases, the candidate relationships involved will also become more. Therefore, in order to avoid the explosive growth of candidate relationships, the efficiency of answering the question text will be improved by gradually reducing the candidate relationships. This embodiment will be described using the question text as a single-entity two-degree question as an example. The description process of the single-entity multi-degree problem can refer to the corresponding description content of this embodiment, and this application will not go into details here.
[0164] Based on this, in a single-entity second-degree problem, it is necessary not only to determine the first-degree relationship corresponding to the target entity, but also to determine the second-degree relationship of the target entity, and then to screen the target relationship by combining the first-degree and second-degree relationships to complete the answer to the question text; wherein, the first-degree relationship specifically refers to a relationship that has a direct connection with the entity, and the second-degree relationship specifically refers to a relationship that has an indirect correspondence with the target entity; accordingly, the multiple candidate relationships will include multiple head entity first relationships, multiple tail entity first relationships, multiple head entity second relationships and multiple tail entity second relationships, for subsequent analysis of the answer to the second-degree question.
[0165] For example, the question text is "What is the weather like at A's address?" After entity extraction through the named entity recognition model, it is determined that the target entity corresponding to the question text is "A". Then, based on the target entity "A", the first-degree relationship and the second-degree relationship are extracted in the knowledge base, so as to determine the first relationship of the head entity and the first relationship of the tail entity as {first-degree relationship ①, address relationship ②, first-degree relationship ③, first-degree relationship ④}, and determine the second relationship of the head entity and the second relationship of the tail entity as {climate relationship a, second-degree relationship b, second-degree relationship c, second-degree relationship d, second-degree relationship e, second-degree relationship f, second-degree relationship g, second-degree relationship h}.
[0166] It should be noted that, for the convenience of description, this implementation does not provide detailed descriptions of specific first-degree relationships and second-degree relationships, where the first relationship of the head entity can be a name relationship (A's name), and the first relationship of the tail entity can be a father-son relationship (the father is A); the corresponding second relationship of the head entity can be a retirement relationship (A's age to retirement age), and the second relationship of the tail entity can be a climate relationship (A lives in the city with the best weather). This embodiment does not elaborate on the above-mentioned first-degree relationships and second-degree relationships, and describes them in a general manner.
[0167] Step 2: determine head entity relationship pairs based on the multiple head entity first relationships and the multiple head entity second relationships, and input the head entity relationship pairs and the question text into the similarity calculation module for processing to obtain a third similarity score between each head entity relationship pair and the question text.
[0168] Specifically, after obtaining multiple candidate relationships as mentioned above, in order to avoid the explosive growth of the head entity second relationship and the tail entity second relationship, which will affect the efficiency of subsequently determining the answer to the question text, the number of candidate relationships can be reduced by determining the head entity relationship pair, wherein the head entity relationship pair specifically refers to a relationship pair composed of the head entity first relationship and the head entity second relationship, the head entity first relationship in the head entity relationship pair is screened out from multiple head entity first relationships, and the head entity second relationship in the head entity relationship pair is screened out from multiple head entity second relationships, thereby reducing the number of candidate relationships to improve text processing efficiency.
[0169] Based on this, after determining the head entity relationship pair, it has been shown that the candidate relationships have been effectively reduced. Therefore, the answer to the question text can be determined subsequently through the head entity relationship pair and the tail entity relationship pair, and the semantic similarity between the head entity relationship pair and the question text can be calculated.
[0170] Further, in the process of determining the head entity relationship pairs according to the multiple head entity first relationships and the multiple head entity second relationships, since the number of head entity first relationships and head entity second relationships is large, it is necessary to reduce the number of relationships by step-by-step screening, so as to obtain the head entity relationship pairs that meet the use requirements. In this embodiment, the specific implementation method is as follows:
[0171] Inputting the plurality of first head entity relationships and the question text into a first similarity calculation model in the similarity calculation module for processing, and obtaining a first similarity score between each first head entity relationship and the question text;
[0172] Screening out a set number of first candidate head entity relationships from the plurality of first head entity relationships according to the first similarity score, and screening out a set number of second candidate head entity relationships from the plurality of second head entity relationships according to the set number of first candidate head entity relationships;
[0173] Inputting the set number of head entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a second similarity score between each head entity second candidate relation and the question text;
[0174] The head entity second target relationship is screened out from the set number of head entity second candidate relationships according to the second similarity score, and the set number of head entity first candidate relationships and the head entity second target relationship are integrated to obtain the head entity relationship pair.
[0175] Specifically, the first similarity score specifically refers to the semantic similarity score between the head entity first relationship and the question text, the head entity first candidate relationship specifically refers to a set number of head entity first relationships with higher first similarity scores, the head entity second candidate relationship specifically refers to the head entity second relationship associated on the basis of the head entity first candidate relationship, the second similarity score specifically refers to the semantic similarity score between the head entity second candidate relationship and the question text, the head entity second target relationship specifically refers to a set number of head entity second relationships with higher second similarity scores, and the head entity relationship pair specifically refers to a relationship pair consisting of an associated head entity second target relationship and a head entity first candidate relationship.
[0176] Furthermore, first, the semantic similarity between the multiple head entity first relations and the question text is calculated by the first similarity calculation model in the similarity calculation module to obtain the first similarity score between each head entity first relation and the question text; secondly, in order to reduce the problem of explosive growth of head entity second relations, a set number of head entity first candidate relations are screened out from the multiple head entity first relations according to the first similarity score, that is, a set number of head entity first relations with higher first similarity scores are selected as the head entity first candidate relations; then, the head entity second relations that have an associated relationship with the head entity first candidate relations are determined from the multiple head entity second relations, as a set number of head entity second candidate relations that are screened out from the multiple head entity second relations. At this time, the number of head entity second candidate relations obtained is relatively small compared to the number of multiple head entity second relations, which can effectively improve the efficiency of subsequent text processing.
[0177] Furthermore, after determining a set number of head entity second candidate relationships, there may still be too many candidate relationships, which is not convenient for the subsequent determination of the answer to the question text. In this case, the second similarity calculation model in the similarity calculation module can be used to calculate the second similarity score between each head entity second candidate relationship and the question text, and then the head entity second target relationship is screened out from the set number of head entity second candidate relationships, that is, the head entity second candidate relationship with a higher second similarity score is selected as the head entity second target relationship. At this time, the obtained head entity second target relationship is already less in number relative to the multiple head entity second relationships, and can be used for the subsequent determination of the correct answer to the question text. Then, the head entity first candidate relationship that has an associated relationship with the head entity second target relationship is determined from the set number of head entity first candidate relationships to form the head entity relationship pair, which is input into the similarity calculation module for processing to obtain the third similarity score between each head entity relationship pair and the question text.
[0178] During specific implementation, the selection numbers of the first candidate relationship of the head entity and the second candidate relationship of the head entity can be set according to the actual application scenario, and this embodiment does not impose any limitation thereto.
[0179] Continuing with the above example, convert the first relationship of each head entity to obtain the relationship sequence corresponding to the address relationship ② (the address of A), which is <address><pad_S1>, and the relationship sequence corresponding to the first-degree relationship ① is <relationship ①><pad_S2>. Then, form a group with each converted relationship sequence and the question text "What's the weather like at A's address?" and input them into the first BERT similarity model respectively to calculate the similarity scores between the first relationship of each head entity and the question text. It is determined that the similarity score between the address relationship ② (the address of A) and the question text "What's the weather like at A's address?" is 0.8, and the similarity score between the first-degree relationship ① and the question text "What's the weather like at A's address?" is 0.2.
[0180] After determining the first similarity scores between the first relationship of each head entity and the question text, select the top 2 first relationships of the head entities as the first candidate relationships of the head entities in descending order of the similarity scores. At this time, it can be determined that the first candidate relationships of the head entities are the address relationship ② (the address of A) and the first-degree relationship ① respectively.
[0181] Screen the second candidate relationships of the head entities according to the address relationship ② (the address of A) and the first-degree relationship ① in the second-degree relationships involved in the target entity, and determine that the second relationships of the head entities are: the climate relationship a, the second-degree relationship b, and the second-degree relationship h.
[0182] After determining that the second relationships of the head entities are: the climate relationship a, the second-degree relationship b, and the second-degree relationship h, in order to improve the accuracy of determining the question text at this time, the similarity between the second candidate relationships of the head entities and the question text will be calculated through the second BERT similarity model. Before that, it is also necessary to convert the second candidate relationships of the head entities to obtain <pad><Relationship> <pad>The expressed relationship sequences; that is, the relationship sequence corresponding to climate relationship a is <pad_S1><climate><pad_D1>, the relationship sequence corresponding to second-degree relationship b is <pad_S2><relationship b><pad_D2>, and the relationship sequence corresponding to second-degree relationship h is <pad_S3><relationship h><pad_D3>.
[0183] After that, each of the converted relationship sequences is combined with the question text "What is the weather like at A's address?" to form a group and input into the second BERT similarity model to calculate the similarity scores between each second candidate relationship of the head entity and the question text. The similarity score between climate relationship a output by the model and the question text is 0.5, the similarity score between second-degree relationship b and the question text is 0.15, and the similarity score between second-degree relationship h and the question text is 0.2.
[0184] When it is determined that the first-degree relationships of the head entity include: address relationship ② (A's address) and first-degree relationship ①, and the second candidate relationships of the head entity include: climate relationship a, second-degree relationship b, and second-degree relationship h, then the top 2 second candidate relationships of the head entity are selected as the second target relationships of the head entity according to the second similarity scores, that is, it is determined that climate relationship a and second-degree relationship h are the second target relationships of the head entity; then, according to the associated relationships existing between them, the first candidate relationship of the head entity and the second target relationship of the head entity are integrated, and the obtained head entity relationship pairs are {address relationship ②, climate relationship a} and {first-degree relationship ①, second-degree relationship h}.
[0185] Before inputting the head entity relationship pairs and the question text into the third BERT similarity model, it is necessary to convert the relationship sequences of each head entity relationship pair. It is determined that the relationship sequence corresponding to {address relationship ②, climate relationship a} is <address><pad_S1><pad_S1><climate><pad_D1>, and the relationship sequence corresponding to {first-degree relationship ①, second-degree relationship h} is <relationship ①><pad_S2><pad_S3><relationship h><pad_D3>.
[0186] After that, each of the converted relationship sequences is combined with the question text "What is the weather like at A's address?" to form a group and input into the third BERT similarity model to calculate the similarity scores between each head entity relationship pair and the question text. The similarity score between {address relationship ②, climate relationship a} output by the model and the question text is 0.9, and the similarity score between {first-degree relationship ①, second-degree relationship h} and the question text is 0.3.
[0187] In summary, by gradually reducing the number of second relationships through semantic similarity analysis, the problem of explosive growth of second relationships can be effectively avoided, the efficiency of determining the answer to the question text can be further improved, and the answering requirements for the question text can be met.
[0188] Step 3, determining a tail entity relationship pair according to the multiple tail entity first relationships and the multiple tail entity second relationships, and inputting the tail entity relationship pair and the question text into the similarity calculation module for processing to obtain the sixth similarity score between each tail entity relationship pair and the question text.
[0189] Specifically, after obtaining multiple candidate relationships as mentioned above, in order to avoid the explosive growth of the head entity second relationship and the tail entity second relationship, which will affect the efficiency of subsequently determining the answer to the question text, the number of candidate relationships can be reduced by determining a tail entity relationship pair, wherein the tail entity relationship pair specifically refers to a relationship pair composed of a tail entity first relationship and a tail entity second relationship, the tail entity first relationship in the tail entity relationship pair is screened out from multiple tail entity first relationships, and the tail entity second relationship in the tail entity relationship pair is screened out from multiple tail entity second relationships, thereby reducing the number of candidate relationships to improve text processing efficiency.
[0190] Based on this, after determining the tail entity relationship pair, it has been shown that the candidate relationships have been effectively reduced. Therefore, the answer to the question text can be determined subsequently through the head entity relationship pair and the tail entity relationship pair, and the semantic similarity between the tail entity relationship pair and the question text can be calculated.
[0191] Further, in the process of determining the tail entity relationship pair according to the multiple tail entity first relationships and the multiple tail entity second relationships, since the number of tail entity first relationships and tail entity second relationships is large, it is necessary to reduce the number of relationships by a step-by-step screening method, so as to obtain a tail entity relationship pair that meets the use requirements. In this embodiment, the specific implementation method is as follows:
[0192] Inputting the plurality of tail entity first relations and the question text into the first similarity calculation model in the similarity calculation module for processing, and obtaining a fourth similarity score between each tail entity first relation and the question text;
[0193] Screening out a set number of tail entity first candidate relations from the plurality of tail entity first relations according to the fourth similarity score, and screening out a set number of tail entity second candidate relations from the plurality of tail entity second relations according to the set number of tail entity first candidate relations;
[0194] Inputting the set number of tail entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a fifth similarity score between each tail entity second candidate relation and the question text;
[0195] A tail entity second target relationship is screened out from the set number of tail entity second candidate relationships according to the fifth similarity score, and the set number of tail entity first candidate relationships and the tail entity second target relationship are integrated to obtain the tail entity relationship pair.
[0196] Specifically, the fourth similarity score specifically refers to the semantic similarity score between the tail entity first relationship and the question text, the tail entity first candidate relationship specifically refers to a set number of tail entity first relationships with higher fourth similarity scores, the tail entity second candidate relationship specifically refers to the tail entity second relationship associated on the basis of the tail entity first candidate relationship, the fifth similarity score specifically refers to the semantic similarity score between the tail entity second candidate relationship and the question text, the tail entity second target relationship specifically refers to a set number of tail entity second relationships with higher fifth similarity scores, and the tail entity relationship pair specifically refers to a relationship pair consisting of an associated tail entity second target relationship and a tail entity first candidate relationship.
[0197] It should be noted that the process of determining the tail entity relationship pair can refer to the process of determining the head entity relationship pair, and the subsequent calculation of the sixth similarity score can also refer to the calculation process of the third similarity score, which will not be elaborated in detail in this embodiment.
[0198] Step 4: Input the head entity relationship pair and the question text into the feature calculation module for processing to obtain a first feature score of the head entity relationship pair and the question text; input the tail entity relationship pair and the question text into the feature calculation module for processing to obtain a second feature score of the tail entity relationship pair and the question text.
[0199] Specifically, based on the above-mentioned calculation of the semantic similarity between the head entity relationship pair and the question text, and the semantic similarity between the tail entity relationship pair and the question text, further, in order to improve the accuracy of determining the correct answer to the question text, the feature similarity between the head entity relationship pair and the question text, and the feature similarity between the tail entity relationship pair and the question text are calculated from the feature dimension, thereby obtaining a first feature score between the head entity relationship pair and the question text, and a second feature score between the tail entity relationship pair and the question text; wherein, the feature calculation module is integrated by different feature similarity calculation models, and different feature similarity calculation models will correspond to different question types. In practical applications, the feature similarity calculation model can be constructed using the LGBM classifier.
[0200] In practical applications, before the head entity relationship pair and the question text are input into the feature calculation module for processing, it is also necessary to construct a feature expression matrix based on the head entity relationship pair and the question text as the input of the feature calculation module. At the same time, it is also necessary to construct a feature expression matrix based on the tail entity relationship pair and the question text as the input of the feature calculation module to meet the processing requirements of the feature calculation module.
[0201] Using the above example, by performing matrix conversion on the head entity relationship pair and the question text, we obtain the feature expression matrix of {address relationship ②, climate relationship a} and the question text "How is the weather at A's address?", and the feature expression matrix of {first-degree relationship ①, second-degree relationship h} and the question text "How is the weather at A's address?". Then, each feature expression matrix is input into the LGBM classifier to calculate the feature similarity, and the feature similarity score of {address relationship ②, climate relationship a} and the question text "How is the weather at A's address?" is 0.8, and the feature similarity score of {first-degree relationship ①, second-degree relationship h} and the question text "How is the weather at A's address?" is 0.3; similarly, the tail entity relationship pair and the question text are matrix converted, and the feature score is calculated through the LGBM classifier to obtain the feature similarity score of each tail entity relationship pair and the question text.
[0202] Step 5: Calculate a first total similarity score of the head entity relationship pair according to the third similarity score and the first feature score; calculate a second total similarity score of the tail entity relationship pair according to the sixth similarity score and the second feature score.
[0203] Specifically, after obtaining the third similarity score of the head entity relationship pair in the semantic dimension and the first feature score in the feature dimension, the first total similarity score of the head entity relationship pair relative to the question text can be determined by combining the total scores of the two dimensions. Similarly, after obtaining the sixth similarity score of the tail entity relationship pair in the semantic dimension and the second feature score in the feature dimension, the second total similarity score of the tail entity relationship pair relative to the question text can be determined by combining the total scores of the two dimensions.
[0204] Continuing with the above example, the similarity score and feature similarity score of {address relationship ②, climate relationship a} and the question text are added, and the total similarity score of {address relationship ②, climate relationship a} and the question text is determined to be 0.9+0.8=1.7; the similarity score and feature similarity score of {first-degree relationship ①, second-degree relationship h} and the question text are added, and the total similarity score of {first-degree relationship ①, second-degree relationship h} and the question text is determined to be 0.3+0.3=0.6; similarly, the similarity score and feature similarity score of the tail entity relationship pair and the question text are added to determine the total similarity score.
[0205] Step 6: sort the head entity relationship pair and the tail entity relationship pair based on the first similarity total score and the second similarity total score, and determine the target relationship according to the sorting result.
[0206] Specifically, based on the first similarity total score and the second similarity total score obtained by the above calculation, the head entity relationship pair and the tail entity relationship pair can be sorted according to the similarity total score, and the relationship pair with the highest similarity total score is selected according to the sorting result to determine the target relationship, that is, the target relationship will be composed of a first entity relationship and a second entity relationship, and the two have an associated relationship.
[0207] Continuing with the above example, the head entity relationship pair is determined by the total similarity score: {address relationship ②, climate relationship a} is the entity relationship pair with the highest total score, then {address relationship ②, climate relationship a} is determined as the target relationship pair, which is used to determine the answer to the question text "What is the weather like at A's address?" in the knowledge graph corresponding to the KBQA system.
[0208] Step 7: determining in the knowledge base the associated entities of the target entity based on the target relationship mapping; and generating an answer to the question text according to the associated entities.
[0209] Specifically, after determining the target relationship, the associated entity of the target entity based on the target relationship mapping can be determined in the knowledge base, and the answer to the question text can be analyzed based on the associated entity.
[0210] Continuing with the above example, based on {address relationship ②, climate relationship a}, the mapped associated entity is determined to be sunny in the knowledge base corresponding to the KBQA system, and the answer to the question text "What is the weather at A's address?" is determined to be "sunny", that is, it is determined that the weather at A's address is sunny.
[0211] To sum up, when determining the answer to a single-entity second-degree question, the similarity calculation model and the feature calculation model are combined to perform continuous screening of entity relationship pairs, thereby reducing the amount of calculation when screening entity relationships, thereby improving the screening efficiency of entity relationship pairs, and through multiple screening methods, the accuracy and efficiency of determining the answer can be effectively improved, further meeting the user's usage needs.
[0212] The text processing method provided by the present application, after obtaining the question text, will determine the target entity of the question text, and at the same time extract multiple candidate relationships corresponding to the target entity in a preset knowledge base, and then input the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text, and at the same time, input the multiple candidate relationships and the question text into a feature calculation module for processing to obtain a feature score between each candidate relationship and the question text, and finally determine the target relationship among the multiple candidate relationships by integrating the similarity scores and the feature scores, and then determine the answer to the question text based on the target relationship, thereby achieving the improvement of the efficiency of determining the answer by reducing the number of candidate relationships in the process of screening the answer to the question text, and at the same time ensuring the accuracy of determining the target relationship by combining the similarity dimension and the feature dimension, further improving the accuracy of determining the answer, and achieving a high-precision answer to the question in a shorter time.
[0213] The following combination Figure 2 , taking the application of the text processing method provided by the present application in a first-order problem as an example, the text processing method is further explained. Among them, Figure 2 A processing flow chart of a text processing method applied to a problem provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0214] Step S202, obtaining question text.
[0215] This embodiment takes the question text as a single-entity first-degree question as an example to describe the text processing method; wherein the question text is "Where is A's address?"; accordingly, the answer will be determined and fed back through the KBQA system at this time, and the specific process is described as follows.
[0216] Step S204: input the question text into a named entity recognition model for entity recognition to obtain candidate entities corresponding to the question text.
[0217] At this time, the question text "Where is A's address?" is input into the named entity recognition model to extract entities, and the candidate entity of the question text is "A".
[0218] Step S206: query a preset knowledge base according to the candidate entity, and determine a target entity to be mapped to the candidate entity according to the query result.
[0219] Query the knowledge base corresponding to the knowledge graph based on the candidate entity "A", and it is determined that there are multiple entities with the same name "A" in the library, including a name entity, a song entity, an address entity, etc. At this time, in order to accurately determine the answer to the question text, multiple entities will be sorted, and the first n entities will be selected as the target entities for subsequent screening of target relationships according to the sorting results. For the convenience of description in this embodiment, n will be described as 1.
[0220] Correspondingly, after sorting the multiple entities, select the candidate entity ranked first as the target entity for subsequent determination of the target relationship. That is, after sorting the multiple entities, it is determined that the name entity is ranked first, so the name entity "A" is used as the target entity linked by the candidate entity.
[0221] Step S208, extract multiple head entity first-degree relationships and multiple tail entity first-degree relationships corresponding to the target entity from the preset knowledge base.
[0222] After determining that the target entity is the name entity "A", at this time, first-degree relationships will be extracted from the knowledge base based on the target entity "A", and it is determined that the included head entity first-degree relationships are: name relationship (the name of A), address relationship (the address of A), age relationship (the age of A), etc., and the included tail entity first-degree relationships are: father-son relationship (the father is A), identity identification relationship (the identity identification is A), employment relationship (the position is A), etc.
[0223] Step S210, input the multiple head entity first-degree relationships and the question text into the BERT similarity model for similarity calculation to obtain the first similarity scores of each head entity first-degree relationship and the question text.
[0224] Before inputting the multiple head entity first-degree relationships and the question text into the BERT similarity model, each head entity first-degree relationship needs to be converted; that is, the relationship sequence corresponding to the name relationship (the name of A) is <name><pad_S1>, the relationship sequence corresponding to the address relationship (the address of A) is <address><pad_S2>, the relationship sequence corresponding to the age relationship (the age of A) is <age><pad_S3>...; then each converted relationship sequence is combined with the question text "Where is A's address?" into a group and input into the BERT similarity model respectively to calculate the similarity scores of each head entity first-degree relationship and the question text, and it is determined that the similarity score of the name relationship (the name of A) and the question text "Where is A's address?" is 0.30, the similarity score of the address relationship (the address of A) and the question text "Where is A's address?" is 0.85, the similarity score of the age relationship (the age of A) and the question text "Where is A's address?" is 0.25...
[0225] Step S212: Input multiple first-degree relationships of tail entities and the question text into the BERT similarity model for similarity calculation, and obtain the second similarity scores between each first-degree relationship of tail entities and the question text.
[0226] Before inputting multiple first-degree relationships of tail entities and the question text into the BERT similarity model, determine that the relationship sequence corresponding to the father-son relationship (the father is A) is <pad_P1><father-son>, the relationship sequence corresponding to the identity identification relationship (the identity identification is A) is <pad_P2><identity identification>, the relationship sequence corresponding to the employment relationship (the position is A) is <pad_P3><employment>...; then, after combining each converted relationship sequence with the question text "Where is A's address?" into a group, input them into the BERT similarity model respectively for calculating the similarity scores between each first-degree relationship of tail entities and the question text. Determine that the similarity score between the father-son relationship (the father is A) and the question text is 0.20, the similarity score between the identity identification relationship (the identity identification is A) and the question text is 0.10, the similarity score between the employment relationship (the position is A) and the question text is 0.30...
[0227] Step S214: Input multiple first-degree relationships of head entities and the question text into the LGBM classifier for feature similarity calculation, and obtain the first feature similarity scores between each first-degree relationship of head entities and the question text.
[0228] At this time, perform matrix transformation on each first-degree relationship of head entities and the question text based on the above feature processing dimensions, and respectively obtain the feature expression matrices of the name relationship (A's name) and the question text "Where is A's address?", the feature expression matrix of the address relationship (A's address) and the question text "Where is A's address?", the feature expression matrix of the age relationship (A's age) and the question text "Where is A's address?"...; then input each feature expression matrix into the LGBM classifier for feature similarity calculation, and obtain that the feature similarity score between the name relationship (A's name) and the question text "Where is A's address?" is 0.10; the feature similarity score between the address relationship (A's address) and the question text "Where is A's address?" is 0.70, the feature similarity score between the age relationship (A's age) and the question text "Where is A's address?" is 0.25...
[0229] Step S216: Input multiple first-degree relationships of tail-head entities and the question text into the LGBM classifier for feature similarity calculation, and obtain the second feature similarity scores between each first-degree relationship of tail entities and the question text.
[0230] At this time, based on the above-mentioned feature processing dimensions, matrix transformation is performed on the first-degree relationship of each tail entity and the question text, and the feature expression matrix of the father-son relationship (the father is A) and the question text, the feature expression matrix of the identity relationship (the identity is A) and the question text, the feature expression matrix of the position relationship (the position is A) and the question text are obtained respectively...; then each feature expression matrix is input into the LGBM classifier to calculate the feature similarity, and the feature similarity score of the father-son relationship (the father is A) and the question text is 0.20, the feature similarity score of the identity relationship (the identity is A) and the question text is 0.10, the feature similarity score of the position relationship (the position is A) and the question text is 0.15...
[0231] Step S218: summing the first similarity score and the first feature similarity score, and summing the second similarity score and the second feature similarity score.
[0232] Step S220 , sorting the plurality of first-degree relationships of the head entity and the plurality of first-degree relationships of the tail entity according to the summation result, and selecting a target relationship according to the sorting result.
[0233] Specifically, the similarity score and feature similarity score of the name relationship (A's name) and the question text are added by 0.30+0.10=0.40; the similarity score and feature similarity score of the address relationship (A's address) and the question text are added by 0.85+0.70=1.55; the similarity score and feature similarity score of the age relationship (A's age) and the question text are added by 0.25+0.25=0.5...; the similarity score and feature similarity score of the father-son relationship (the father is A) and the question text are added by 0.20+0.20=0.40; the similarity score and feature similarity score of the identity relationship (the identity is A) and the question text are added by 0.10+0.10=0.20; the similarity score and feature similarity score of the position relationship (the position is A) and the question text are added by 0.30+0.15=0.45...
[0234] After calculating the total score of each first-degree relationship and the question text (combining the similarity score and the feature similarity score), the multiple head entity first-degree relationships and the multiple tail entity first-degree relationships are sorted according to the total score. The sorting result is address relationship (A's address) > age relationship (A's age) > position relationship (position is A)...; then the address relationship (A's address) is selected as the target relationship according to the sorting result, so as to determine the answer to the question text "Where is A's address?" in the knowledge graph corresponding to the KBQA system.
[0235] Step S222, determining the answer to the question text based on the associated entities mapped to the target relationship in the preset knowledge base.
[0236] Through the address relationship (A's address) in the knowledge graph corresponding to the KBQA system, it is determined that the mapped associated entity is city A, and the answer to the question text "Where is A's address?" is determined to be "city A".
[0237] In summary, in order to answer the question text accurately and efficiently based on the KBQA system, after screening out the relationships corresponding to the question text entities, the BERT model and the LGBM classifier are combined to calculate the scores of the two dimensions. Then, the target relationship is screened by the calculated total score, and the answer to the question text is determined by the target relationship. This can effectively improve the accuracy and efficiency of determining the answer and further meet the user's usage needs.
[0238] Corresponding to the above method embodiment, the present application also provides a text processing device embodiment, Figure 3 FIG. 1 shows a schematic diagram of the structure of a text processing device provided by an embodiment of the present application. Figure 3 As shown, the device comprises:
[0239] The target entity determination module 302 is configured to determine the target entity corresponding to the question text and extract multiple candidate relations corresponding to the target entity in a preset knowledge base;
[0240] A similarity score calculation module 304 is configured to input the plurality of candidate relationships and the question text into a similarity calculation module for processing, and obtain a similarity score between each candidate relationship and the question text;
[0241] A feature score calculation module 306 is configured to input the plurality of candidate relationships and the question text into a feature calculation module for processing, and obtain a feature score of each candidate relationship and the question text;
[0242] The answer determination module 308 is configured to determine a target relationship among the multiple candidate relationships based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship.
[0243] In an optional embodiment, the target entity determination module 302 includes:
[0244] A question text acquisition unit is configured to acquire the question text and input the question text into a named entity recognition model for processing to obtain candidate entities of the question text;
[0245] The target entity determination unit is configured to query the knowledge base based on the candidate entity and determine the target entity corresponding to the question text according to the query result.
[0246] In an optional embodiment, the target entity determination module 302 includes:
[0247] A question type determination unit, configured to determine the question type of the question text;
[0248] In the case where the question type is the first question type, running a first extraction unit, wherein the first extraction unit is configured to extract a plurality of head entity first relations and a plurality of tail entity first relations corresponding to the target entity from the knowledge base as the candidate relations;
[0249] When the question type is the second question type, a second extraction unit is run, and the second extraction unit is configured to extract multiple head entity first relations, multiple tail entity first relations, multiple head entity second relations and multiple tail entity second relations corresponding to the target entity in the knowledge base as the candidate relations.
[0250] In an optional embodiment, the similarity score calculation module 304 includes:
[0251] A first similarity score calculation unit is configured to, when the question type is the first question type, input the plurality of first head entity relationships and the question text into the similarity calculation module for processing, and obtain a first similarity score between each first head entity relationship and the question text;
[0252] The second similarity score calculation unit is configured to input the multiple tail entity first relations and the question text into the similarity calculation module for processing, and obtain a second similarity score between each tail entity first relation and the question text.
[0253] In an optional embodiment, the feature score calculation module 306 includes:
[0254] A first preprocessing unit is configured to preprocess the plurality of head entity first relations and the question text to obtain a first feature matrix corresponding to each head entity first relation;
[0255] A first feature calculation unit is configured to input the first feature matrix into the feature calculation module for processing, and obtain a first feature score of each head entity first relationship and the question text;
[0256] A second preprocessing unit is configured to preprocess the plurality of tail entity first relations and the question text to obtain a second feature matrix corresponding to each tail entity first relation;
[0257] The second feature calculation unit is configured to input the second feature matrix into the feature calculation module for processing to obtain the second feature score of each tail entity first relationship and the question text.
[0258] In an optional embodiment, the answer determination module 308 includes:
[0259] a candidate score determining unit configured to determine a first candidate score for each head entity first relationship according to the first similarity score and the first feature score, and to determine a second candidate score for each tail entity first relationship according to the second similarity score and the second feature score;
[0260] The first target relationship determination unit is configured to select a target candidate score from the first candidate scores of each head entity first relationship and the second candidate scores of each tail entity first relationship, and determine the target relationship corresponding to the target candidate score.
[0261] In an optional embodiment, the similarity score calculation module 304 includes:
[0262] a third similarity score determination unit configured to, when the question type is the second question type, determine head entity relationship pairs according to the plurality of head entity first relationships and the plurality of head entity second relationships, and input the head entity relationship pairs and the question text into the similarity calculation module for processing, to obtain a third similarity score between each head entity relationship pair and the question text;
[0263] A sixth similarity score determination unit is configured to determine a tail entity relationship pair according to the plurality of tail entity first relationships and the plurality of tail entity second relationships, and input the tail entity relationship pair and the question text into the similarity calculation module for processing to obtain a sixth similarity score between each tail entity relationship pair and the question text.
[0264] In an optional embodiment, the determining the third similarity score unit includes:
[0265] a first similarity score determination subunit configured to input the plurality of first head entity relationships and the question text into a first similarity calculation model in the similarity calculation module for processing, and obtain a first similarity score between each first head entity relationship and the question text;
[0266] a second candidate relationship screening subunit, configured to screen out a set number of head entity first candidate relationships from the multiple head entity first relationships according to the first similarity score, and screen out a set number of head entity second candidate relationships from the multiple head entity second relationships according to the set number of head entity first candidate relationships;
[0267] a second similarity score determination subunit configured to input the set number of head entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtain a second similarity score between each head entity second candidate relation and the question text;
[0268] The first integration subunit is configured to filter out the head entity second target relationship from the set number of head entity second candidate relationships according to the second similarity score, and integrate the set number of head entity first candidate relationships and the head entity second target relationship to obtain the head entity relationship pair.
[0269] In an optional embodiment, the determining the sixth similarity score unit includes:
[0270] Determine a fourth similarity score subunit, configured to input the plurality of tail entity first relations and the question text into the first similarity calculation model in the similarity calculation module for processing, and obtain a fourth similarity score between each tail entity first relation and the question text;
[0271] a second candidate relationship screening subunit, configured to screen out a set number of tail entity first candidate relationships from the plurality of tail entity first relationships according to the fourth similarity score, and screen out a set number of tail entity second candidate relationships from the plurality of tail entity second relationships according to the set number of tail entity first candidate relationships;
[0272] A fifth similarity score determination subunit is configured to input the set number of tail entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtain a fifth similarity score between each tail entity second candidate relation and the question text;
[0273] The second integration subunit is configured to filter out the tail entity second target relationship from the set number of tail entity second candidate relationships according to the fifth similarity score, and integrate the set number of tail entity first candidate relationships and the tail entity second target relationship to obtain the tail entity relationship pair.
[0274] In an optional embodiment, the feature score calculation module 306 includes:
[0275] A relationship pair determination unit, configured to determine the head entity relationship pair and the tail entity relationship pair according to the plurality of candidate relationships;
[0276] A first feature calculation module processing unit is configured to input the head entity relationship pair and the question text into the feature calculation module for processing, and obtain a first feature score of the head entity relationship pair and the question text;
[0277] The second feature calculation module processing unit is configured to input the tail entity relationship pair and the question text into the feature calculation module for processing to obtain a second feature score of the tail entity relationship pair and the question text.
[0278] In an optional embodiment, the answer determination module 308 includes:
[0279] a first similarity total score calculating unit, configured to calculate a first similarity total score of the head entity relationship pair according to the third similarity score and the first feature score;
[0280] a second similarity total score calculating unit, configured to calculate a second similarity total score of the tail entity relationship pair according to the sixth similarity score and the second feature score;
[0281] The second target relationship determination unit is configured to sort the head entity relationship pair and the tail entity relationship pair based on the first similarity total score and the second similarity total score, and determine the target relationship according to the sorting result.
[0282] In an optional embodiment, the answer determination module 308 is further configured to:
[0283] Determine in the knowledge base the associated entity of the target entity based on the target relationship mapping; and generate an answer to the question text according to the associated entity.
[0284] A text processing device provided in this embodiment determines the target entity of the question text after obtaining the question text, and extracts multiple candidate relationships corresponding to the target entity in a preset knowledge base, then inputs the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text, and also inputs the multiple candidate relationships and the question text into a feature calculation module for processing to obtain a feature score between each candidate relationship and the question text, and finally determines the target relationship among the multiple candidate relationships by integrating the similarity scores and the feature scores, and then determines the answer to the question text based on the target relationship, thereby improving the efficiency of determining the answer by reducing the number of candidate relationships in the process of screening the answer to the question text, and ensuring the accuracy of determining the target relationship by combining the similarity dimension and the feature dimension, further improving the accuracy of determining the answer, and achieving a high-precision answer to the question in a shorter time.
[0285] The above is a schematic scheme of a text processing device of the present embodiment. It should be noted that the technical scheme of the text processing device and the technical scheme of the above-mentioned text processing method belong to the same concept. For details not described in detail in the technical scheme of the text processing device, please refer to the description of the technical scheme of the above-mentioned text processing method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0286] Figure 4 A flowchart of another text processing method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0287] Step S402: determine the target entity corresponding to the question text, and extract multiple first candidate relations and multiple second candidate relations corresponding to the target entity from a preset knowledge base.
[0288] Step S404: determining a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculating a similarity score between each candidate relationship pair and the question text.
[0289] Step S406: input the set number of candidate relationship pairs and the question text into a feature calculation module for processing to obtain a feature score of each candidate relationship pair and the question text.
[0290] Step S408 determines a target relationship pair from the set number of candidate relationship pairs based on the similarity score and the feature score, and determines an answer to the question text according to entities associated with the target relationship pair.
[0291] It should be noted that another text processing method provided in this embodiment is applied to the processing process of the second-degree problem. The specific description content can refer to the corresponding description content in the above-mentioned text processing method, and this embodiment will not be described in detail here.
[0292] Another text processing method provided in this embodiment improves the efficiency of determining answers by reducing the number of candidate relationships in the process of screening answers to question texts, and at the same time ensures the accuracy of determining target relationships by combining similarity dimensions and feature dimensions, thereby further improving the accuracy of determining answers and achieving feedback of highly accurate answers to questions in a shorter period of time.
[0293] The following combines the appended Figure 5 , taking the application of the text processing method provided in this application in the second-degree problem as an example, the text processing method will be further described. Among them, Figure 5 shows a processing flow chart of a text processing method applied to a second-degree problem provided in an embodiment of this application, specifically including the following steps:
[0294] Step S502, obtain the problem text.
[0295] In this embodiment, taking the problem text as a single-entity second-degree problem as an example, the text processing method will be described; among them, the problem text is "What's the weather like at A's address?"; correspondingly, at this time, the answer will be determined and fed back through the KBQA system, and the specific process is as follows.
[0296] Step S504, input the problem text into the named entity recognition model for entity recognition to obtain candidate entities corresponding to the problem text.
[0297] Step S506, query the preset knowledge base according to the candidate entities, and determine the target entities mapped by the candidate entities according to the query results.
[0298] At this time, the problem text "What's the weather like at A's address?" is input into the named entity recognition model for entity extraction, and the candidate entity obtained for the problem text is "A". Then, based on the candidate entity "A", the corresponding knowledge base of the knowledge graph is queried, and it is determined that there are multiple entities with the same name "A" in this library, namely a name entity, a song entity, an address entity, etc. At this time, in order to accurately determine the answer to the problem text, multiple entities will be sorted, and the first n entities will be selected as the target entities for subsequent screening of target relationships according to the sorting results. For the convenience of description in this embodiment, n will be described as 1.
[0299] Correspondingly, after sorting multiple entities, the candidate entity ranked first is selected as the target entity for subsequent determination of the target relationship, that is, after sorting multiple entities, it is determined that the name entity is ranked first, then the name entity "A" is used as the target entity linked by the candidate entity.
[0300] Step S508, extract multiple head entity first-degree relationships, multiple tail entity first-degree relationships, multiple head entity second-degree relationships, and multiple tail entity second-degree relationships corresponding to the target entity in the preset knowledge base.
[0301] After determining that the target entity is the name entity "A", at this time, first-degree relationship extraction and second-degree relationship extraction will be performed on the knowledge base based on the target entity "A"; thus, it is determined that the head entity first-degree relationship and the tail entity first-degree relationship are as Figure 6 Shown: {First-degree relationship ①, Address relationship ②, First-degree relationship ③, First-degree relationship ④}, determine the second-degree relationship of the head entity and the second-degree relationship of the tail entity as follows Figure 6 Shown: {Climate relationship a, Second-degree relationship b, Second-degree relationship c, Second-degree relationship d, Second-degree relationship e, Second-degree relationship f, Second-degree relationship g, Second-degree relationship h}.
[0302] Step S510, input multiple first-degree relationships of head entities and the question text into the first BERT similarity model for similarity calculation, and obtain the first similarity scores of each first-degree relationship of the head entity and the question text.
[0303] Before inputting multiple first-degree relationships of head entities and the question text into the first BERT similarity model, it is necessary to convert each first-degree relationship of the head entity. That is, the relationship sequence corresponding to the address relationship ② (the address of A) is <Address><pad_S1>, and the relationship sequence corresponding to the first-degree relationship ① is <Relationship ①><pad_S2>; then, each converted relationship sequence is combined with the question text "What is the weather like at A's address?" into a group, and input into the first BERT similarity model respectively for calculating the similarity scores between each first-degree relationship of the head entity and the question text. It is determined that the similarity score between the address relationship ② (the address of A) and the question text "What is the weather like at A's address?" is 0.8, and the similarity score between the first-degree relationship ① and the question text "What is the weather like at A's address?" is 0.2.
[0304] Step S512, screen out a set number of first-degree candidate relationships of head entities from multiple first-degree relationships of head entities according to the first similarity scores.
[0305] After determining the first similarity scores between each first-degree relationship of the head entity and the question text, the top 2 first-degree relationships of the head entity are screened out from them in descending order of similarity scores as the first-degree candidate relationships of the head entity. At this time, it can be determined that the first-degree candidate relationships of the head entity are the address relationship ② (the address of A) and the first-degree relationship ① respectively.
[0306] Step S514, screen out a set number of second-degree candidate relationships of head entities from multiple second-degree relationships of head entities according to the set number of first-degree candidate relationships of head entities.
[0307] See Figure 6 Shown, screen out the second-degree candidate relationships of the head entity in the second-degree relationships involved in the target entity according to the address relationship ② (the address of A) and the first-degree relationship ①, and determine that the second-degree relationships of the head entity are: climate relationship a, second-degree relationship b and second-degree relationship h.
[0308] Step S516: Input a set number of second-degree candidate relationships of the head entity and the question text into a second BERT similarity model to perform similarity calculation, and obtain a second similarity score of each second-degree candidate relationship of the head entity and the question text.
[0309] After determining that the second-degree relations of the head entity are climate relation a, second-degree relation b, and second-degree relation h, in order to improve the accuracy of determining the question text, the second BERT similarity model will be used to calculate the similarity between the second-degree candidate relations of the head entity and the question text. Before this, the second-degree candidate relations of the head entity also need to be converted, that is, the relationship sequence corresponding to climate relation a is<pad_S1> <Climate><pad_D1> , the relationship sequence corresponding to the second-degree relationship b is<pad_S2> <Relationship b><pad_D2> , the relationship sequence corresponding to the second-degree relationship h is<pad_S3> <Relationship><pad_D3> .
[0310] Afterwards, each converted relationship sequence is grouped with the question text "What is the weather like at A's address?" and input into the second BERT similarity model to calculate the similarity score between each head entity second-degree candidate relationship and the question text. The similarity score between the climate relationship a and the question text obtained by the model output is 0.5, the similarity score between the second-degree relationship b and the question text is 0.15, and the similarity score between the second-degree relationship h and the question text is 0.2.
[0311] Step S518 , screening out head entity second-degree target relations from a set number of head entity second-degree candidate relations according to the second similarity score, and integrating the head entity first-degree candidate relations and the head entity second-degree target relations to obtain head entity relation pairs.
[0312] After determining that the first-degree candidate relations of the head entity include: address relation ② (A's address) and first-degree relation ①, and the second-degree candidate relations of the head entity include: climate relation a, second-degree relation b and second-degree relation h, the top two second-degree candidate relations of the head entity are selected as the second-degree target relations of the head entity according to the second similarity score, that is, the climate relation a and the second-degree relation h are determined as the second-degree target relations of the head entity; then, the first-degree candidate relations of the head entity and the second-degree target relations of the head entity are integrated according to the association relationship between them, and the obtained head entity relation pairs are respectively {address relation ②, climate relation a} and {first-degree relation ①, second-degree relation h}.
[0313] Step S520: Input the head entity relationship pair and the question text into the third BERT similarity model to perform similarity calculation to obtain a third similarity score between each head entity relationship pair and the question text.
[0314] Before inputting the head entity relationship pair and the question text into the third BERT similarity model, it is necessary to perform a conversion of the relationship sequence for each head entity relationship pair. It is determined that the relationship sequence corresponding to {residential address relationship ②, climate relationship a} is <residential address><pad_S1><pad_S1><climate><pad_D1>, and the relationship sequence corresponding to {first-degree relationship ①, second-degree relationship h} is <relationship ①><pad_S2><pad_S3><relationship h><pad_D3>.
[0315] After that, each converted relationship sequence is combined with the question text "What's the weather like at A's residential address?" into a group and input into the third BERT similarity model to calculate the similarity score between each head entity relationship pair and the question text. The similarity score between {residential address relationship ②, climate relationship a} and the question text obtained from the model output is 0.9, and the similarity score between {first-degree relationship ①, second-degree relationship h} and the question text is 0.3.
[0316] Step S522: Input the head entity relationship pair and the question text into the LGBM classifier to calculate the feature similarity, and obtain the first feature similarity score between each head entity relationship pair and the question text.
[0317] At this time, matrix conversion will be performed to obtain the feature expression matrices of {residential address relationship ②, climate relationship a} and the question text "What's the weather like at A's residential address?", and the feature expression matrices of {first-degree relationship ①, second-degree relationship h} and the question text "What's the weather like at A's residential address?" respectively. After that, each feature expression matrix is input into the LGBM classifier to calculate the feature similarity. The feature similarity score between {residential address relationship ②, climate relationship a} and the question text "What's the weather like at A's residential address?" is 0.8, and the feature similarity score between {first-degree relationship ①, second-degree relationship h} and the question text "What's the weather like at A's residential address?" is 0.3.
[0318] Step S524: Sum the third similarity score and the first feature similarity score to obtain the first total similarity score for each head entity relationship pair.
[0319] Specifically, add the similarity score and the feature similarity score between {residential address relationship ②, climate relationship a} and the question text to determine that the total similarity score between {residential address relationship ②, climate relationship a} and the question text is 0.9 + 0.8 = 1.7; add the similarity score and the feature similarity score between {first-degree relationship ①, second-degree relationship h} and the question text to determine that the total similarity score between {first-degree relationship ①, second-degree relationship h} and the question text is 0.3 + 0.3 = 0.6.
[0320] Step S526: Input the plurality of first-degree tail entity relationships and the question text into the first BERT similarity model to perform similarity calculation, and obtain a fourth similarity score between each first-degree tail entity relationship and the question text.
[0321] Step S528 , selecting a set number of candidate first-degree tail entity relationships from the plurality of first-degree tail entity relationships according to the fourth similarity score.
[0322] Step S530 , screening out a set number of candidate tail entity second-degree relationships from a plurality of tail entity second-degree relationships according to a set number of candidate tail entity first-degree relationships.
[0323] Step S532: Input a set number of tail entity second-degree candidate relations and the question text into a second BERT similarity model to perform similarity calculation, and obtain a fifth similarity score between each tail entity second-degree candidate relation and the question text.
[0324] Step S534 , screening out tail entity second-degree target relations from a set number of tail entity second-degree candidate relations according to the fifth similarity score, and integrating the tail entity first-degree candidate relations and the tail entity second-degree target relations to obtain a tail entity relation pair.
[0325] Step S536: input the tail entity relationship pair and the question text into the third BERT similarity model to perform similarity calculation to obtain the sixth similarity score between each tail entity relationship pair and the question text.
[0326] Step S538, input the tail entity relationship pair and the question text into the LGBM classifier to calculate the feature similarity, and obtain the second feature similarity score of each tail entity relationship pair and the question text.
[0327] Step S540: sum the sixth similarity score and the second feature similarity score to obtain a second total similarity score for each tail entity relationship pair.
[0328] Specifically, the steps S526 to S540 are the process of determining the tail entity relationship pair. The process can refer to the corresponding description of steps S510 to S524. This embodiment will not be described in detail here. Similar parts can refer to each other. In addition, it should be noted that since the tail entity first-degree relationship and the tail entity second-degree relationship are different from the head entity first-degree relationship and the head entity second-degree relationship, when generating the tail entity relationship pair, <pad><Once relationship><Entity> <pad><Second-degree relationship> <pad>The relation sequence is converted and then processed accordingly.
[0329] Step S542 , sorting the plurality of head entity relationship pairs and the plurality of tail entity relationship pairs according to the first similarity total score and the second similarity total score, and selecting a target relationship pair according to the sorting result.
[0330] Specifically, the head entity relationship pair is determined by the total similarity score: {address relationship ②, climate relationship a} is the entity relationship pair with the highest total score, then {address relationship ②, climate relationship a} is determined as the target relationship pair, which is used to determine the answer to the question text "What is the weather like at A's address?" in the knowledge graph corresponding to the KBQA system.
[0331] Step S544, determining the answer to the question text based on the target relationship and the associated entities mapped in the preset knowledge base.
[0332] See also Figure 6 As shown, based on {address relationship ②, climate relationship a}, the mapped associated entity is determined to be sunny in the knowledge graph corresponding to the KBQA system, and the answer to the question text "What is the weather at A's address?" is determined to be "sunny", that is, it is determined that the weather at A's address is sunny.
[0333] In summary, when determining the answer to a single-entity second-degree question based on the KBQA system, the three BERT similarity models and the LGBM classifier are combined to continuously screen entity relationship pairs, thereby reducing the amount of calculation when screening entity relationships, thereby improving the screening efficiency of entity relationship pairs, and through multiple screening methods, the accuracy and efficiency of determining the answer can be effectively improved, further meeting the user's usage needs.
[0334] Corresponding to the above method embodiment, the present application also provides another text processing device embodiment, Figure 7 FIG. 2 shows a schematic diagram of the structure of another text processing device provided by an embodiment of the present application. Figure 7 As shown, the device comprises:
[0335] An extraction module 702 is configured to determine a target entity corresponding to the question text, and extract a plurality of first candidate relations and a plurality of second candidate relations corresponding to the target entity from a preset knowledge base;
[0336] A similarity calculation module 704 is configured to determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text;
[0337] The feature calculation module 706 is configured to input the set number of candidate relationship pairs and the question text into a feature calculation module for processing, and obtain a feature score of each candidate relationship pair and the question text;
[0338] The determination module 708 is configured to determine a target relationship pair from the set number of candidate relationship pairs based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship pair.
[0339] Another text processing device provided in this embodiment improves the efficiency of determining answers by reducing the number of candidate relationships during the process of screening answers to question texts, and at the same time ensures the accuracy of determining target relationships by combining similarity dimensions and feature dimensions, thereby further improving the accuracy of determining answers and achieving feedback of highly accurate answers to questions in a shorter period of time.
[0340] The above is a schematic scheme of another text processing device of this embodiment. It should be noted that the technical scheme of the text processing device and the technical scheme of the above-mentioned another text processing method belong to the same concept. For the details not described in detail in the technical scheme of the text processing device, please refer to the description of the technical scheme of the above-mentioned another text processing method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0341] Figure 8 The structure block diagram of a computing device 800 provided according to an embodiment of the present application is shown. The components of the computing device 800 include but are not limited to a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and the database 850 is used to store data.
[0342] The computing device 800 also includes an access device 840 that enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 840 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0343] In one embodiment of the present application, the above components of the computing device 800 and Figure 8 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 8 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0344] The computing device 800 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 800 may also be a mobile or stationary server.
[0345] The processor 820 is used to execute the following computer executable instructions:
[0346] Determine the target entity corresponding to the question text, and extract multiple candidate relations corresponding to the target entity in a preset knowledge base;
[0347] Inputting the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text;
[0348] Inputting the multiple candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text;
[0349] A target relationship is determined among the multiple candidate relationships based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship.
[0350] or,
[0351] Determine a target entity corresponding to the question text, and extract multiple first candidate relations and multiple second candidate relations corresponding to the target entity from a preset knowledge base;
[0352] Determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text;
[0353] Inputting the set number of candidate relationship pairs and the question text into a feature calculation module for processing to obtain a feature score for each candidate relationship pair and the question text;
[0354] A target relationship pair is determined from the set number of candidate relationship pairs based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship pair.
[0355] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical schemes of the above two text processing methods belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical schemes of the above two text processing methods.
[0356] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used when executed by a processor to:
[0357] Determine the target entity corresponding to the question text, and extract multiple candidate relations corresponding to the target entity in a preset knowledge base;
[0358] Inputting the multiple candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text;
[0359] Inputting the multiple candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text;
[0360] A target relationship is determined among the multiple candidate relationships based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship.
[0361] or,
[0362] Determine a target entity corresponding to the question text, and extract multiple first candidate relations and multiple second candidate relations corresponding to the target entity from a preset knowledge base;
[0363] Determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text;
[0364] Inputting the set number of candidate relationship pairs and the question text into a feature calculation module for processing to obtain a feature score for each candidate relationship pair and the question text;
[0365] A target relationship pair is determined from the set number of candidate relationship pairs based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship pair.
[0366] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above two text processing methods belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above two text processing methods.
[0367] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0368] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0369] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0370] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0371] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.< / pad> < / pad> < / pad> < / pad> < / pad> < / pad> < / pad> < / pad>
Claims
1. A text processing method, It is characterized in that include: Determine the target entity corresponding to the question text, and extract multiple candidate relations corresponding to the target entity in a preset knowledge base; Inputting the multiple candidate relations and the question text into a similarity calculation module for processing, and obtaining a similarity score between each candidate relation and the question text, wherein the similarity score corresponds to a semantic dimension; Inputting the multiple candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text, wherein the feature scores correspond to feature dimensions; A target relationship is determined among the multiple candidate relationships based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship.
2. The text processing method according to claim 1, It is characterized in that The step of determining the target entity corresponding to the question text includes: Obtain the question text, and input the question text into a named entity recognition model for processing to obtain candidate entities of the question text; The knowledge base is queried based on the candidate entity, and the target entity corresponding to the question text is determined according to the query result.
3. The text processing method according to claim 2, It is characterized in that The step of extracting a plurality of candidate relations corresponding to the target entity from a preset knowledge base includes: Determining a question type of the question text; In the case where the question type is the first question type, extracting a plurality of head entity first relations and a plurality of tail entity first relations corresponding to the target entity from the knowledge base as the candidate relations; In the case where the question type is the second question type, a plurality of head entity first relations, a plurality of tail entity first relations, a plurality of head entity second relations and a plurality of tail entity second relations corresponding to the target entity are extracted from the knowledge base as the candidate relations.
4. The text processing method according to claim 3, It is characterized in that The step of inputting the plurality of candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text includes: In the case where the question type is the first question type, the plurality of first head entity relationships and the question text are input into the similarity calculation module for processing to obtain a first similarity score between each first head entity relationship and the question text; The plurality of tail entity first relations and the question text are input into the similarity calculation module for processing to obtain a second similarity score between each tail entity first relation and the question text.
5. The text processing method according to claim 4, It is characterized in that The step of inputting the plurality of candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text includes: Preprocessing the multiple head entity first relations and the question text to obtain a first feature matrix corresponding to each head entity first relation; Inputting the first feature matrix into the feature calculation module for processing to obtain the first feature score of each head entity first relationship and the question text; Preprocessing the plurality of tail entity first relations and the question text to obtain a second feature matrix corresponding to each tail entity first relation; The second feature matrix is input into the feature calculation module for processing to obtain the second feature score of each tail entity first relationship and the question text.
6. The text processing method according to claim 5, It is characterized in that The determining a target relationship among the plurality of candidate relationships based on the similarity score and the feature score comprises: Determine a first candidate score for each head entity first relationship according to the first similarity score and the first feature score, and determine a second candidate score for each tail entity first relationship according to the second similarity score and the second feature score; A target candidate score is selected from the first candidate scores of the first relations of the head entities and the second candidate scores of the first relations of the tail entities, and the target relation corresponding to the target candidate score is determined.
7. The text processing method according to claim 3, It is characterized in that The step of inputting the plurality of candidate relationships and the question text into a similarity calculation module for processing to obtain a similarity score between each candidate relationship and the question text includes: In the case where the question type is the second question type, determining head entity relationship pairs according to the multiple head entity first relationships and the multiple head entity second relationships, and inputting the head entity relationship pairs and the question text into the similarity calculation module for processing to obtain a third similarity score between each head entity relationship pair and the question text; Determine tail entity relationship pairs according to the multiple tail entity first relationships and the multiple tail entity second relationships, and input the tail entity relationship pairs and the question text into the similarity calculation module for processing to obtain the sixth similarity score between each tail entity relationship pair and the question text.
8. The text processing method according to claim 7, It is characterized in that The determining of the head entity relationship pairs according to the plurality of head entity first relationships and the plurality of head entity second relationships comprises: Inputting the plurality of first head entity relationships and the question text into a first similarity calculation model in the similarity calculation module for processing, and obtaining a first similarity score between each first head entity relationship and the question text; Screening out a set number of first candidate head entity relationships from the plurality of first head entity relationships according to the first similarity score, and screening out a set number of second candidate head entity relationships from the plurality of second head entity relationships according to the set number of first candidate head entity relationships; Inputting the set number of head entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a second similarity score between each head entity second candidate relation and the question text; The head entity second target relationship is screened out from the set number of head entity second candidate relationships according to the second similarity score, and the set number of head entity first candidate relationships and the head entity second target relationship are integrated to obtain the head entity relationship pair.
9. The text processing method according to claim 7, It is characterized in that The determining of the tail entity relationship pair according to the plurality of tail entity first relationships and the plurality of tail entity second relationships comprises: Inputting the plurality of tail entity first relations and the question text into the first similarity calculation model in the similarity calculation module for processing, and obtaining a fourth similarity score between each tail entity first relation and the question text; Screening out a set number of tail entity first candidate relations from the plurality of tail entity first relations according to the fourth similarity score, and screening out a set number of tail entity second candidate relations from the plurality of tail entity second relations according to the set number of tail entity first candidate relations; Inputting the set number of tail entity second candidate relations and the question text into the second similarity calculation model in the similarity calculation module for processing, and obtaining a fifth similarity score between each tail entity second candidate relation and the question text; A tail entity second target relationship is screened out from the set number of tail entity second candidate relationships according to the fifth similarity score, and the set number of tail entity first candidate relationships and the tail entity second target relationship are integrated to obtain the tail entity relationship pair.
10. The text processing method according to claim 7, It is characterized in that The step of inputting the plurality of candidate relationships and the question text into a feature calculation module for processing to obtain feature scores of each candidate relationship and the question text includes: Determine the head entity relationship pair and the tail entity relationship pair according to the multiple candidate relationships; Inputting the head entity relationship pair and the question text into the feature calculation module for processing to obtain a first feature score of the head entity relationship pair and the question text; The tail entity relationship pair and the question text are input into the feature calculation module for processing to obtain a second feature score of the tail entity relationship pair and the question text.
11. The text processing method according to claim 10, It is characterized in that The determining a target relationship among the plurality of candidate relationships based on the similarity score and the feature score comprises: Calculate a first total similarity score of the head entity relationship pair according to the third similarity score and the first feature score; Calculate a second total similarity score of the tail entity relationship pair according to the sixth similarity score and the second feature score; The head entity relationship pair and the tail entity relationship pair are sorted based on the first similarity total score and the second similarity total score, and the target relationship is determined according to the sorting result.
12. The text processing method according to claim 6 or 11, It is characterized in that The step of determining the answer to the question text according to the entity associated with the target relationship includes: Determining in the knowledge base an associated entity of the target entity based on the target relationship mapping; An answer to the question text is generated according to the associated entity.
13. A text processing device, It is characterized in that include: A target entity determination module is configured to determine a target entity corresponding to the question text and extract multiple candidate relations corresponding to the target entity from a preset knowledge base; A similarity score calculation module is configured to input the multiple candidate relationships and the question text into the similarity calculation module for processing, and obtain a similarity score between each candidate relationship and the question text, wherein the similarity score corresponds to a semantic dimension; A feature score calculation module is configured to input the plurality of candidate relationships and the question text into the feature calculation module for processing, and obtain a feature score of each candidate relationship and the question text, wherein the feature score corresponds to a feature dimension; The answer determination module is configured to determine a target relationship among the multiple candidate relationships based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship.
14. A text processing method, It is characterized in that include: Determine a target entity corresponding to the question text, and extract multiple first candidate relations and multiple second candidate relations corresponding to the target entity from a preset knowledge base; Determine a set number of candidate relationship pairs based on the multiple first candidate relationships and the multiple second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text, wherein the similarity score corresponds to a semantic dimension; Inputting the set number of candidate relationship pairs and the question text into a feature calculation module for processing, and obtaining a feature score of each candidate relationship pair and the question text, wherein the feature score corresponds to a feature dimension; A target relationship pair is determined from the set number of candidate relationship pairs based on the similarity score and the feature score, and an answer to the question text is determined according to an entity associated with the target relationship pair.
15. A text processing device, It is characterized in that include: An extraction module is configured to determine a target entity corresponding to the question text, and extract a plurality of first candidate relations and a plurality of second candidate relations corresponding to the target entity from a preset knowledge base; A similarity calculation module is configured to determine a set number of candidate relationship pairs based on the plurality of first candidate relationships and the plurality of second candidate relationships, and calculate a similarity score between each candidate relationship pair and the question text, wherein the similarity score corresponds to a semantic dimension; A feature calculation module is configured to input the set number of candidate relationship pairs and the question text into a feature calculation module for processing, and obtain a feature score of each candidate relationship pair and the question text, wherein the feature score corresponds to a feature dimension; The determination module is configured to determine a target relationship pair from the set number of candidate relationship pairs based on the similarity score and the feature score, and determine an answer to the question text according to an entity associated with the target relationship pair.
16. A computing device, It is characterized in that include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the text processing method according to any one of claims 1 to 12 or 14.
17. A computer-readable storage medium storing computer instructions, It is characterized in that When the instruction is executed by the processor, the steps of the text processing method described in any one of claims 1 to 12 or 14 are implemented.
