A Question Answering Method and Device Based on a Knowledge Graph

By combining word segmentation and language processing models, the target entities and intents in question-and-answer statements are identified, solving the problems of inaccurate template matching and slow semantic analysis in existing technologies, and realizing fast and accurate question answering based on knowledge graphs.

CN114880480BActive Publication Date: 2025-08-01BEIJING SINOVOICE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210371151.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-08
Publication Date
2025-08-01
Estimated Expiration
2042-04-08

AI Technical Summary

Technical Problem

Existing knowledge graph-based question answering methods suffer from inaccurate queries due to template matching and slow semantic analysis, making it difficult to meet the demand for fast and accurate question answering.

Method used

By combining word segmentation, entity dictionary matching, and language processing models, the target entities and intents in question-and-answer statements are identified, and the response content is generated quickly and accurately using knowledge graphs.

Benefits of technology

It improves the accuracy of entity matching and the speed of intent recognition, enabling a fast and accurate question-and-answer process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114880480B_ABST
    Figure CN114880480B_ABST
Patent Text Reader

Abstract

The present invention provides a question-and-answer method and device based on a knowledge graph, including: obtaining an input question-and-answer sentence, performing word segmentation on the question-and-answer sentence to obtain a word segmentation result; matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; inputting the question-and-answer sentence and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity; inputting the question-and-answer sentence and the candidate intention into the language processing model for intention recognition to obtain a target intention, and determining a reply content for the question-and-answer sentence according to the target entity and the target intention. The present invention determines the target entity by calculating the similarity between the first candidate entity and the corpus segment obtained by entity recognition, improves the accuracy of entity matching, determines the target intention by calculating the similarity between the candidate intention and the question sentence, improves the accuracy of intention recognition, and can quickly and accurately obtain the reply content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular, to a question and answer method, an electronic device, a computer-readable storage medium, and a computer program product based on a knowledge graph. Background Art

[0002] The knowledge graph technology describes entities and their relationships in the objective world in a structured form. A dialogue system constructed based on the knowledge graph is usually used to solve problems in a certain field, such as product consultation or encyclopedia question and answer.

[0003] Currently, for the question and answer method based on the knowledge graph, a method based on template rule matching is usually adopted to determine the entity of the question sentence and the intention of the question sentence by looking up a dictionary, or a method based on semantic analysis is adopted, that is, to determine the entity and intention of the question sentence by analyzing the syntax of the question sentence.

[0004] However, if the template matching method is adopted, it is difficult to generalize all the intentions expressed by the question and answer sentences, resulting in inaccurate queries. If the semantic analysis method is adopted, the matching speed is relatively slow, and it is difficult to meet the current question and answer requirements. Summary of the Invention

[0005] Embodiments of the present invention provide a question and answer method, an electronic device, a computer-readable storage medium, and a computer program product based on a knowledge graph to solve the problems of inaccurate query of the missing graph, slow matching speed, and low question and answer efficiency caused by template matching or semantic analysis in the prior art.

[0006] In a first aspect, an embodiment of the present invention provides a question and answer method based on a knowledge graph, including:

[0007] Obtain an input question and answer sentence, perform word segmentation on the question and answer sentence to obtain a word segmentation result;

[0008] Match the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationship between keywords, entities, and intentions; the entity is used to represent an object with a preset intention meaning;

[0009] Input the question and answer sentence and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the question and answer sentence;

[0010] Input the question and answer sentence and the candidate intention into the language processing model for intention recognition to obtain a target intention, where the target intention is determined based on the text similarity between the question and answer sentence and the candidate intention;

[0011] Determine a response content for the Q&A statement according to the target entity and the target intent.

[0012] In a second aspect, an embodiment of the present invention provides a Q&A device based on a knowledge graph. The device includes:

[0013] A word segmentation module, configured to obtain an input Q&A statement, perform word segmentation on the Q&A statement, and obtain a word segmentation result;

[0014] A first determination module, configured to match the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intent corresponding to the first candidate entity; the entity dictionary includes a correspondence between keywords and entities; the entity is used to represent an object with a preset intent meaning;

[0015] A second determination module, configured to input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement;

[0016] A third determination module, configured to input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement;

[0017] A response generation module, configured to determine a response content for the Q&A statement according to the target entity and the target intent.

[0018] In a third aspect, an embodiment of the present invention further provides an electronic device, which includes: a processor; a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the instructions to implement the above-mentioned Q&A method based on a knowledge graph.

[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which is characterized in that when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the Q&A method provided by the present invention.

[0020] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which is characterized in that when the computer program is executed by a processor, the Q&A method based on a knowledge graph is implemented.

[0021] In an embodiment of the present invention, by obtaining an input Q&A statement, performing word segmentation on the Q&A statement to obtain a word segmentation result; matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationships of keywords, entities, and intentions; the entity is used to represent an object with a preset intention meaning; inputting the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, and the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement; inputting the Q&A statement and the candidate intention into the language processing model for intention recognition to obtain a target intention, and the target intention is determined based on the text similarity between the Q&A statement and the candidate intention; determining a reply content for the Q&A statement according to the target entity and the target intention. In the present invention, the first candidate entity obtained by word segmentation is used to calculate the similarity with the corpus fragment obtained by entity recognition through the language model to determine the target entity, which improves the accuracy of entity matching. The candidate intention obtained by word segmentation is used to calculate the similarity with the question sentence to determine the target intention, which improves the accuracy of intention recognition. The reply content of the Q&A statement based on the knowledge graph is determined through the determined target entity and target intention, so that the reply content of the Q&A statement can be quickly and accurately obtained by querying the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a schematic diagram of a knowledge graph provided by an embodiment of the present invention;

[0023] Figure 2 is a flowchart of the steps of a method for answering questions based on a knowledge graph provided by an embodiment of the present invention;

[0024] Figure 3 is an execution flowchart of a method for answering questions based on a knowledge graph provided by an embodiment of the present invention;

[0025] Figure 4 is a flowchart of the steps of another method for answering questions based on a knowledge graph provided by an embodiment of the present invention;

[0026] Figure 5 is a block diagram of a terminal provided by an embodiment of the present invention;

[0027] Figure 6 is a block diagram of an electronic device provided by an embodiment of the present invention;

[0028] Figure 7 is a block diagram of another electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0029] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present invention can be more thoroughly understood and the scope of the present invention can be completely conveyed to those skilled in the art.

[0030] A knowledge graph is a structured semantic knowledge base used to quickly describe concepts and their relationships in the physical world. By processing, handling, and integrating complex document data, the knowledge graph transforms it into simple and clear triples of "entity-relationship-entity" or "entity-attribute-attribute value". Finally, by aggregating a large number of indicators, it realizes the rapid response and reasoning of knowledge.

[0031] Reference Figure 1 , Figure 1 shows the composition structure of a knowledge graph. In the figure, if there is a relationship between two circular nodes, then these two nodes are connected by an undirected edge. This node is the entity, and the edge connecting the two entities represents the relationship between the entities. As shown in the figure, "Country A" and "City A" represent two entities, and the relationship between "Country A" and "City A" is that the capital of Country A is City A. This structure is the triple structure of "entity-relationship-entity". Another example is that the entity "City A" has attributes such as area and population. According to the shown knowledge graph, the area of City A is 16,140 square kilometers, and the population of City A is 20 million. That is, the structure of "City A, area, 16,140 square kilometers" or "City A, population, 20 million" is the triple structure of "entity-attribute-attribute value". The knowledge graph of the present invention is constructed by these two triple relationships, and different knowledge graphs are constructed according to data and relationships in different fields to meet different usage requirements.

[0032] Figure 2 is a flowchart of the steps of a question-and-answer method based on a knowledge graph provided by an embodiment of the present invention. The method may include:

[0033] Step 101, obtain the input question-and-answer statement, perform word segmentation on the question-and-answer statement, and obtain the word segmentation result.

[0034] In an embodiment of the present invention, the Q&A statement can be in the form of a question sentence, specifically, it can be the text information input by the user. For example, when the user inputs the question sentence: "How much is the ticket for the National Museum?", the word segmentation result obtained after processing is "National Museum / ticket / how much / money". If the question sentence input by the user is "What's the weather like tomorrow?", the word segmentation result is "tomorrow / weather / what's it like". The obtained Q&A statement can also be the voice information input by the user. For example, if the user asks the intelligent robot a question in voice mode "", the word segmentation result obtained is "Can it be shipped tomorrow?". Specifically, after obtaining the Q&A statement input by the user, natural language processing technology can be used to parse the statement to obtain the word segmentation included in the Q&A statement.

[0035] A further method for word segmentation of the question sentence can be through a dictionary-based word segmentation algorithm, that is, the string to be matched (Q&A statement) is matched with the words in a pre-established "sufficiently large" dictionary according to a certain strategy. If a certain entry is found, it means the match is successful and the word is recognized, and this word is used as a word segmentation result. Or through a statistics-based word segmentation method, on the premise of a large number of already segmented texts given, a statistical machine learning model is used to learn the rules of word segmentation to achieve the segmentation of unknown texts. Specifically, word segmentation can also be achieved based on deep learning methods and other approaches, which will not be elaborated in this embodiment of the present invention.

[0036] Step 102: Match the word segmentation result with a preset entity dictionary to obtain the first candidate entity corresponding to the word segmentation result and the candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationships of keywords, entities, and intentions; the entity is used to represent an object with a preset intention meaning.

[0037] In an embodiment of the present invention, after obtaining the word segmentation result of the Q&A statement, the word segmentation result can be matched with a preset entity dictionary. The candidate entity is determined by matching the word segmentation result with the keywords in the entity dictionary. If the word segmentation result successfully matches the keywords in the entity dictionary, the word segmentation result is determined as the first candidate entity. Through the analysis of the candidate entity, the domain information of the entity related to the candidate entity can be obtained. The domain information of the entity includes the attributes of the entity or the relationships between entities. For example, if "City A" is taken as the first candidate entity after matching, by analyzing the attributes of "City A" such as population and area, questions such as "How many people are there in City A?" or "How large is the area of City A?" can be used as the candidate intentions of the Q&A statement. If it is found that there is a relationship between "City A" and "Country A", the question "Which country's capital is City A?" can be used as the candidate intention.

[0038] Step 103: Input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing entities in the Q&A statement.

[0039] In the embodiment of the present invention, a corpus segment regarding an entity in the Q&A statement is extracted by means of entity recognition. The language processing model of the present invention can extract an entity corpus segment from unstructured input text. The entities recognized by entity recognition are entities with specific meanings or strong referentiality in the text of the Q&A statement, which may include: entities of types such as person names, place names, organization names, date and time, proper nouns, etc. For example, if the input text is "Xiaoming goes to school for class at 8 o'clock in the morning", the information that can be extracted after entity recognition is: person name: Xiaoming, time: 8 o'clock in the morning, place: school.

[0040] Furthermore, calculate the word similarity between the corpus segment obtained by entity recognition and the candidate entity obtained in step 102, then the target entity of the Q&A statement can be determined. In the embodiment of the present invention, the candidate entity obtained by dictionary matching is compared with the entity corpus segment obtained by the language processing model to obtain the target entity. The method of determining the target entity by combining dictionary matching and a deep learning model is adopted, making the process of determining the target entity faster and more accurate.

[0041] Step 104: Input the Q&A statement and the candidate intent into the language processing model for intent recognition to obtain a target intent, where the target intent is determined based on the text similarity between the Q&A statement and the candidate intent.

[0042] In the embodiment of the present invention, after obtaining the candidate intent in step 102, input the Q&A statement and the obtained candidate intent into the language processing model. The language processing model can output vectors corresponding to the Q&A statement and each candidate intent respectively. By calculating the text similarity between the Q&A statement and each obtained candidate intent, the target intent of the Q&A statement is determined. For example: referring to step 102, if the Q&A statement is "What is the population of City A", the candidate intents obtained through analysis are: "How many people are there in City A", "What is the area of City A", etc. By calculating the similarity between the Q&A statement and each candidate intent, one of the multiple candidate intents is determined as the target intent of the Q&A statement.

[0043] Step 105: Determine a reply content for the Q&A statement according to the target entity and the target intent.

[0044] In an embodiment of the present invention, after obtaining the target entity and the target intent, the obtained entity and intent are matched with the triples in the knowledge graph to obtain the reply content for the Q&A statement. For example: If the obtained target entity is "City A" and the target intent is "population", by querying the knowledge graph, it can be known that there is a triple in the knowledge graph: City A - population - 20 million, then 20 million is the answer to the Q&A statement.

[0045] In summary, an embodiment of the present invention provides a Q&A method based on a knowledge graph, including: obtaining an input Q&A statement, performing word segmentation on the Q&A statement to obtain a word segmentation result; matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intent corresponding to the first candidate entity; the entity dictionary includes the corresponding relationship between keywords, entities, and intents; the entity is used to represent an object with a preset intent meaning; inputting the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement; inputting the Q&A statement and the candidate intent into the language processing model for intent recognition to obtain a target intent, where the target intent is determined based on the text similarity between the Q&A statement and the candidate intent; determining the reply content for the Q&A statement according to the target entity and the target intent. In the present invention, the target entity is determined by calculating the similarity between the first candidate entity obtained by word segmentation and the corpus fragment obtained by entity recognition using a language model, improving the accuracy of entity matching. The target intent is determined by calculating the similarity between the candidate intent obtained by word segmentation and the question sentence, improving the accuracy of intent recognition. The reply content of the Q&A statement based on the knowledge graph is determined by the determined target entity and target intent, so that the reply content of the Q&A statement can be quickly and accurately obtained by querying the knowledge graph.

[0046] Figure 3 is the execution flowchart of a Q&A method based on a knowledge graph provided by an embodiment of the present invention, Figure 4 is the step flowchart of another Q&A method based on a knowledge graph provided by an embodiment of the present invention. Refer to Figure 3 can be used to Figure 4 supplement and explain the embodiments shown in Figure 4 The method shown in the embodiment may include:

[0047] Step 201, obtain an input Q&A statement, and perform word segmentation on the Q&A statement to obtain a word segmentation result.

[0048] This step can refer to the above step 101 and will not be elaborated here.

[0049] Step 202: Match the word segmentation result with a preset entity dictionary to obtain the first candidate entity corresponding to the word segmentation result and the candidate intent corresponding to the first candidate entity.

[0050] This step can refer to the above-mentioned step 102 and will not be elaborated here.

[0051] Optionally, in an implementation manner of the embodiment of the present invention, step 202 may specifically include:

[0052] Sub-step 2021: The entity dictionary includes a first dictionary having a corresponding relationship between sub-words and the entity, where the sub-words are the words obtained after segmenting the entity; match the segmented words in the word segmentation result with the sub-words in the first dictionary, and determine the entity corresponding to the sub-word that matches the segmented word as the first candidate entity, and determine the candidate intent corresponding to the first candidate entity.

[0053] In the embodiment of the present invention, the first dictionary may be a sub-word - entity dictionary. The construction method of the sub-word - entity dictionary is as follows: segment each entity in the graph to obtain sub-words, then use the sub-words as keys in the dictionary and the original entity words as values. If a sub-word in the sub-word - entity dictionary appears in the word segmentation result after segmenting the question sentence, then the entity corresponding to the sub-word is used as the candidate entity. For example, if there is "ticket - train ticket" in the sub-word - entity dictionary, and after segmenting the Q&A sentence, the word segmentation result contains "ticket", then the entity "train ticket" corresponding to the sub-word "ticket" in the sub-word - entity dictionary can be used as the candidate entity of the Q&A sentence.

[0054] Optionally, in another implementation manner of the embodiment of the present invention, step 202 may specifically include:

[0055] Sub-step 2022: The entity dictionary further includes a second dictionary having a corresponding relationship between aliases and entities, where the aliases are the aliases of the entities; match the segmented words in the word segmentation result with the aliases in the second dictionary, and determine the entity corresponding to the alias that matches the segmented word as the first candidate entity, and determine the candidate intent corresponding to the first candidate entity.

[0056] In an embodiment of the present invention, the second dictionary may be an entity alias dictionary. The construction method of the entity alias dictionary is as follows: taking the alias as the key in the dictionary and the entity as the value. If an alias in the entity alias dictionary appears in the word segmentation result obtained after segmenting the question sentence, then the entity corresponding to the alias is regarded as a candidate entity. For example, if there is a corresponding relationship of "National Museum - The National Museum" in the entity alias dictionary, and if the Q&A sentence is "How much is the ticket for the National Museum", and the word segmentation result obtained after segmentation has "National Museum", when matching the word segmentation result with the entity alias dictionary, the word segmentation "National Museum" successfully matches the alias "National Museum" in the entity alias dictionary. At this time, the entity "The National Museum" corresponding to the alias "National Museum" can be determined as the candidate entity.

[0057] Step 203: The language processing model includes a corpus recognition module and an alignment module; input the Q&A sentence into the corpus recognition module to obtain the entity corpus fragment of the second candidate entity included in the Q&A sentence.

[0058] In an embodiment of the present invention, a language processing model is used to process different tasks. After inputting the Q&A sentence into the language processing model, the language processing model can perform entity recognition on the Q&A sentence to obtain a corpus fragment about the entity.

[0059] Specifically, before obtaining the corpus fragment about the entity through the corpus recognition module, the language processing model is trained by using the entity corpus that has been labeled with types as the training corpus, so that the language processing model can accurately identify the corpus fragment about the entity included in the question sentence during entity recognition, without performing syntactic analysis on the question sentence, saving the time of entity recognition and improving the efficiency of determining the target entity. By combining the result of entity recognition with the result of dictionary matching to determine the target entity, the efficiency and accuracy of determining the target entity are improved.

[0060] Step 204: Input the first combination composed of the entity corpus fragment and the first candidate entity into the alignment module, determine the text similarity between the first candidate entity and the entity corpus fragment in the first combination, and determine the target entity from the first combination with the maximum text similarity.

[0061] In an embodiment of the present invention, after obtaining the first candidate entity and the entity corpus fragment, the target entity can be determined by calculating the similarity between the two through the language processing model. For example, the cosine similarity between the vector obtained by transforming the first candidate entity and the vector obtained by transforming the entity corpus fragment is calculated to determine.

[0062] Furthermore, cosine similarity measures the similarity between two vectors by measuring the cosine value of the angle between them. In the cosine function, the cosine value of an angle of zero degrees is 1, and the cosine values of the remaining angles are all less than 1. The value range of the cosine function is [-1, 1]. Thus, it is determined whether two vectors generally point in the same direction by the cosine value of the angle between the two vectors. When two vectors have the same direction, the value of cosine similarity is 1; when the included angle between the two vectors is 90°, the value of cosine similarity is 0; when the two vectors point in exactly opposite directions, the value of cosine similarity is -1. By judging the value of the cosine similarity between the vector transformed from the first candidate entity and the vector transformed from the entity corpus segment, the first combination with the highest text similarity can be determined.

[0063] For example: If the input question sentence is "How much is the ticket for the National Museum", the result after word segmentation is "National Museum / ticket / how much / money". After matching the word segmentation result with the entity alias dictionary, the first candidate entity is "National Museum". When the question sentence is input into the language processing model for entity recognition, the obtained entity corpus segment contains "National Museum". At this time, the similarity between "National Museum" and "National Museum" can be calculated to determine whether "National Museum" is the target entity of the Q&A sentence.

[0064] Optionally, step 204 may specifically include:

[0065] Sub-step 2041: Determine the first candidate entity in the first combination with the highest text similarity as the target entity.

[0066] In the embodiment of the present invention, after judging the text similarity of all the first combinations, the first candidate entity in the first combination with the highest text similarity is selected as the target entity.

[0067] Step 205: Input the second combination composed of the Q&A sentence and the candidate intention into the language processing model, determine the text similarity between the Q&A sentence and the candidate intention in the second combination, and determine the candidate intention in the second combination with the highest text similarity as the target intention.

[0068] In the embodiment of the present invention, multiple candidate intentions and the Q&A sentence can be combined into multiple second combinations. Through the calculation of the language processing model, the candidate intention and the Q&A sentence are converted into vectors. The target intention can be determined by calculating the cosine similarity between the two vectors. The specific implementation method is as described in step 204 above. Furthermore, the method for judging the similarity between the candidate intention and the Q&A sentence can also be: calculating the Euclidean distance, Hamming distance or minimum edit distance between the vectors, etc. The embodiment of the present invention does not limit this.

[0069] Further, referring to step 204, after determining that the "National Museum" is a candidate entity, by analyzing the "National Museum", attributes related to the National Museum are obtained, such as ticket price, geographical location, etc. At this time, "National Museum ticket price" and "National Museum geographical location" can be used as candidate intents. By calculating the similarity between the question sentence "How much is the ticket of the National Museum" and the candidate intents "National Museum ticket price" and "National Museum geographical location" respectively, the intent with the highest similarity is determined as the target intent. For example, if the candidate intent with the highest similarity obtained after calculation is "National Museum ticket price", then "National Museum ticket price" is used as the target intent.

[0070] Step 206, generate a graph query statement based on the target entity and the target intent.

[0071] In the embodiment of the present invention, after obtaining the target entity and the target intent, a query statement for querying the knowledge graph database can be generated by combining the target entity and the target intent.

[0072] Step 207, query the knowledge graph using the graph query statement to obtain a query result.

[0073] In the embodiment of the present invention, the target entity and the target intent are retrieved and compared with the triples stored in the knowledge graph, and the answer to the query statement is calculated according to the comparison result. This answer is used as the answer to the Q&A statement, referring to step 105.

[0074] Step 208, construct a reply content according to the query result.

[0075] In the embodiment of the present invention, the query statement obtains an answer by querying the knowledge graph database, but the obtained answer may be a single word, making the Q&A conversation unnatural. Therefore, before presenting the reply content to the user, the present invention needs to process the answer to make the reply content a complete reply to the Q&A statement, making it more in line with the conversation context and improving the user experience. The text generation method used to construct the answer into a complete reply content can be: a method based on rule template matching. According to the template for generating sentences pre-constructed, the answer is filled in the appropriate position of the sentence components of the template, and then output. For example: if the input Q&A statement is "What is the capital city of Country A", and the answer obtained by querying the graph is "City A", at this time, the reply content generated after processing the answer in combination with the question sentence and the rule template is "The capital city of Country A is City A". Text generation can also adopt semantic analysis or a method based on model generation, and the embodiment of the present invention does not limit this.

[0076] In summary, in combination with Figure 3Further explain the data input and output in the overall implementation process of the solution: First, after obtaining the Q&A statement, perform word segmentation on the Q&A statement. From the obtained word segmentation results, the candidate intents and candidate entities of the Q&A statement can be determined. At the same time, input the Q&A statement into the language processing model for entity recognition to obtain the corpus fragments related to the entities. Then, one branch is to input the Q&A statement and the candidate intent into the language processing model for intent matching to determine the target intent, and the other branch is to perform entity alignment operations on the obtained candidate entities and the entity corpus fragments to determine the target entity. Further, generate a query statement through the obtained target entity and target intent, query the knowledge graph, and finally obtain the reply content of the Q&A statement.

[0077] In summary, another Q&A method based on a knowledge graph provided by an embodiment of the present invention includes: obtaining an input Q&A statement, performing word segmentation on the Q&A statement to obtain a word segmentation result; matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intent corresponding to the first candidate entity; the entity dictionary includes the corresponding relationships between keywords, entities, and intents; the entity is used to represent an object with a preset intent meaning; input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, and the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement; input the Q&A statement and the candidate intent into the language processing model for intent recognition to obtain a target intent, and the target intent is determined based on the text similarity between the Q&A statement and the candidate intent; determine the reply content for the Q&A statement according to the target entity and the target intent. The present invention calculates the similarity between the first candidate entity obtained by word segmentation and the corpus fragment obtained by entity recognition through the language model to determine the target entity, improving the accuracy of entity matching, calculates the similarity between the candidate intent obtained by word segmentation and the question sentence to determine the target intent, improving the accuracy of intent recognition, and determines the reply content of the Q&A statement based on the knowledge graph through the determined target entity and target intent, so that the reply content of the Q&A statement can be quickly and accurately obtained by querying the knowledge graph.

[0078] Figure 5 is a block diagram of a terminal provided by an embodiment of the present invention, as Figure 5 shown, the terminal includes:

[0079] A word segmentation module, configured to obtain an input Q&A statement, perform word segmentation on the Q&A statement, and obtain a word segmentation result;

[0080] A first determination module, configured to match the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationship between keywords and entities; the entity is used to represent an object with a preset intention meaning;

[0081] A second determination module, configured to input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement;

[0082] A third determination module, configured to input the Q&A statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the Q&A statement;

[0083] A reply generation module, configured to determine a reply content for the Q&A statement according to the target entity and the target intention.

[0084] Optionally, the language processing model includes a corpus recognition module and an alignment module, and the second determination module further includes:

[0085] A second recognition sub-module, configured to input the Q&A statement into the corpus recognition module to obtain an entity corpus segment of a second candidate entity included in the Q&A statement;

[0086] A second determination sub-module, configured to input a first combination formed by the entity corpus segment and the first candidate entity into the alignment module, determine the text similarity between the first candidate entity and the entity corpus segment in the first combination, and determine the target entity from the first combination with the largest text similarity.

[0087] Optionally, the second determination sub-module includes:

[0088] Determining the first candidate entity in the first combination with the largest text similarity as the target entity.

[0089] Optionally, the third determination module includes:

[0090] A third determination sub-module: configured to input a second combination formed by the Q&A statement and the candidate intention into the language processing model, determine the text similarity between the Q&A statement and the candidate intention in the second combination, and determine the candidate intention in the second combination with the largest text similarity as the target intention.

[0091] Optionally, the entity dictionary includes: a first dictionary having a correspondence between sub-words and the entity, where the sub-words are words obtained after word segmentation of the entity; the first determination module includes:

[0092] A first matching sub-module: configured to match the word segments in the word segmentation result with the sub-words in the first dictionary, determine the entity corresponding to the sub-word that matches the word segment as the first candidate entity, and determine the candidate intent corresponding to the first candidate entity.

[0093] Optionally, the entity dictionary further includes: a second dictionary having a correspondence between aliases and entities, where the aliases are aliases of the entities; the first determination module further includes:

[0094] A second matching sub-module: configured to match the word segments in the word segmentation result with the aliases in the second dictionary, determine the entity corresponding to the alias that matches the word segment as the first candidate entity, and determine the candidate intent corresponding to the first candidate entity.

[0095] Optionally, the response determination module includes:

[0096] A statement generation sub-module: configured to generate a graph query statement based on the target entity and the target intent;

[0097] A query result sub-module: configured to query the knowledge graph using the graph query statement to obtain a query result;

[0098] A content generation sub-module: configured to construct a response content according to the query result.

[0099] In summary, a question-answering method, an electronic device, a computer-readable storage medium, and a computer program product based on a knowledge graph provided by an embodiment of the present invention include obtaining an input question-answering statement, performing word segmentation on the question-answering statement to obtain a word segmentation result; matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationship between keywords, entities, and intentions; the entity is used to represent an object with a preset intention meaning; inputting the question-answering statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, and the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the question-answering statement; inputting the question-answering statement and the candidate intention into the language processing model for intention recognition to obtain a target intention, and the target intention is determined based on the text similarity between the question-answering statement and the candidate intention; determining a reply content for the question-answering statement according to the target entity and the target intention. By calculating the similarity between the first candidate entity obtained by word segmentation and the corpus segment obtained by entity recognition through a language model to determine the target entity, the present invention improves the accuracy of entity matching. By calculating the similarity between the candidate intention obtained by word segmentation and the question sentence to determine the target intention, the accuracy of intention recognition is improved. By determining the target entity and the target intention to determine the reply content of the question-answering statement based on the knowledge graph, the reply content of the question-answering statement can be quickly and accurately obtained by querying the knowledge graph.

[0100] Figure 6 FIG. 4 is a block diagram of an electronic device 600 shown according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0101] Referring Figure 6 to FIG. 4, the electronic device 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.

[0102] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0103] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0104] The power component 606 provides power to various components of the electronic device 600. The power component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 600.

[0105] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.

[0106] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC) that is used to receive external audio signals when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 604 or transmitted via the communication component 616. In some embodiments, the audio component 610 further includes a speaker for outputting audio signals.

[0107] The I / O interface 612 provides an interface between the processing component 602 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0108] The sensor assembly 614 includes one or more sensors for providing status assessments of various aspects for the electronic device 600. For example, the sensor assembly 614 can detect the on / off state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600. The sensor assembly 614 can also detect a change in the position of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0109] The communication component 616 is used to facilitate communication between the electronic device 600 and other devices in a wired or wireless manner. The electronic device 600 can access a wireless network based on communication standards, such as WiFi, a carrier network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0110] In an exemplary embodiment, the electronic device 600 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for implementing a question-answering method based on a knowledge graph provided by the embodiments of the present disclosure.

[0111] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by a processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0112] Figure 7is a block diagram of an electronic device 700 shown in accordance with an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Referring to Figure 5 , the electronic device 700 includes a processing component 722, which further includes one or more processors, and memory resources represented by a memory 732 for storing instructions executable by the processing component 722, such as application programs. The application programs stored in the memory 732 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform a question-answering method based on a knowledge graph provided by an embodiment of the present disclosure.

[0113] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSD TM or the like.

[0114] The embodiments of the present disclosure also provide a computer program product, including a computer program, which when executed by a processor implements the question-answering method based on a knowledge graph.

[0115] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the disclosure herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0116] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes may be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A question-answering method based on a knowledge graph, characterized in that, Including: Obtain the input question-and-answer statement, perform word segmentation on the question-and-answer statement to obtain a word segmentation result; Match the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; The entity dictionary includes the corresponding relationships of keywords, entities, and intentions; The entity is used to represent an object with a preset intention meaning; Input the question-and-answer statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the question-and-answer statement; Input the question-and-answer statement and the candidate intention into the language processing model for intention recognition to obtain a target intention, where the target intention is determined based on the text similarity between the question-and-answer statement and the candidate intention; Determine a reply content for the question-and-answer statement according to the target entity and the target intention; The language processing model includes a corpus recognition module and an alignment module; The step of inputting the question-and-answer statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity includes: inputting the question-and-answer statement into the corpus recognition module to obtain an entity corpus segment of a second candidate entity included in the question-and-answer statement; Input a first combination composed of the entity corpus segment and the first candidate entity into the alignment module, determine the text similarity between the first candidate entity and the entity corpus segment in the first combination, and determine the target entity from the first combination with the largest text similarity.

2. The method according to claim 1, characterized in that, The step of determining the target entity from the first combination with the largest text similarity includes: Determine the first candidate entity in the first combination with the largest text similarity as the target entity.

3. The method according to claim 1, wherein The step of inputting the question-and-answer statement and the candidate intention into the language processing model for intention recognition to obtain a target intention includes: Input a second combination composed of the question-and-answer statement and the candidate intention into the language processing model, determine the text similarity between the question-and-answer statement and the candidate intention in the second combination, and determine the candidate intention in the second combination with the largest text similarity as the target intention.

4. The method according to claim 1, characterized in that The entity dictionary includes a first dictionary having the corresponding relationship between sub-words and the entity, where the sub-words are the words obtained after word segmentation of the entity; The step of matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity includes: Match the words in the word segmentation result with the sub-words in the first dictionary, and determine the entity corresponding to the sub-word that matches the word as the first candidate entity, and determine the candidate intention corresponding to the first candidate entity.

5. The method according to claim 1, characterized in that The entity dictionary further includes a second dictionary having the corresponding relationship between aliases and entities, where the aliases are the aliases of the entities; Matching the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention included in the first candidate entity, including: Matching the word segments in the word segmentation result with the aliases in the second dictionary, and determining the entity corresponding to the alias that matches the word segment as the first candidate entity, and determining the candidate intention corresponding to the first candidate entity.

6. The method according to claim 1, wherein Determining a reply content for the question-and-answer statement according to the target entity and the target intention, including: Generating a graph query statement based on the target entity and the target intention; Querying the knowledge graph with the graph query statement to obtain a query result; Constructing a reply content according to the query result.

7. A question answering device based on a knowledge graph, characterized in that, The device includes: A word segmentation module, configured to obtain an input question-and-answer statement, perform word segmentation on the question-and-answer statement, and obtain a word segmentation result; A first determination module, configured to match the word segmentation result with a preset entity dictionary to obtain a first candidate entity corresponding to the word segmentation result and a candidate intention corresponding to the first candidate entity; the entity dictionary includes the corresponding relationship between keywords and entities; the entity is used to represent an object with a preset intention meaning; A second determination module, configured to input the question-and-answer statement and the first candidate entity into a preset language processing model for entity recognition to obtain a target entity, where the target entity is determined based on the text similarity between the first candidate entity and the corpus containing the entity in the question-and-answer statement; A third determination module, configured to input the question-and-answer statement and the candidate intention into the language processing model for intention recognition to obtain a target intention, where the target intention is determined based on the text similarity between the question-and-answer statement and the candidate intention; A reply generation module, configured to determine a reply content for the question-and-answer statement according to the target entity and the target intention; The language processing model includes a corpus recognition module and an alignment module; The second determination module further includes: A second recognition sub-module, configured to input the question-and-answer statement into the corpus recognition module to obtain an entity corpus segment of a second candidate entity included in the question-and-answer statement; A second determination sub-module, configured to input a first combination formed by the entity corpus segment and the first candidate entity into the alignment module, determine the text similarity between the first candidate entity and the entity corpus segment in the first combination, and determine the target entity from the first combination with the largest text similarity.

8. An electronic device, characterized in that, Including: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can execute the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, The computer program, when executed by the processor, implements the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge graph driving type law intelligent consultation system

    CN110765257A

  • Automatic question and answer method and system, intelligent equipment and storage medium

    CN111897930A