Knowledge graph processing method, device, electronic device and storage medium
By using Q&A data to extract and compare entity relationships in the process of knowledge graph filling, the problems of difficulty in data collection and poor effectiveness are solved, and the comprehensiveness and effectiveness of the knowledge graph are achieved.
Patent Information
- Application Number
- CN202210642117.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-06-08
AI Technical Summary
In the process of filling the knowledge graph, data collection is difficult and has poor effectiveness. Especially in different fields, the exclusivity of data increases the difficulty of data collection and there is a lag, resulting in poor data validity.
By obtaining the Q&A data of the target field for entity relationship extraction, obtaining the target triple, and comparing the target head entity and tail entity with the knowledge graph, marking the target entity based on the comparison results and entity relationship, determining its type, and adding it to the knowledge graph.
It effectively reduces the difficulty of data collection, ensures the comprehensiveness and effectiveness of the knowledge graph, and uses the content asked by users as the source of knowledge to fill in the knowledge graph, improving the effectiveness of the data.
Smart Images

Figure CN115098693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method for processing a knowledge graph, a device for processing a knowledge graph, an electronic device, and a computer-readable storage medium. Background Art
[0002] Knowledge graphs, known in the library and information science community as knowledge domain visualization or knowledge domain mapping, are a series of diverse graphs that display the development process and structural relationships of knowledge. They use visualization techniques to describe knowledge resources and their carriers, and to mine, analyze, construct, map, and display knowledge and its interconnections. Knowledge graphs are a modern theory that achieves multidisciplinary integration by combining theories and methods from disciplines such as applied mathematics, graphics, information visualization, and information science with methods like citation analysis and co-occurrence analysis. The knowledge graph uses visual graphs to vividly display the core structure, development history, cutting-edge fields, and overall knowledge architecture of a discipline. This provides a practical and valuable reference for disciplinary research.
[0003] Among them, knowledge graph completion is one of the important subtasks in the knowledge graph direction. In the process of completing the knowledge graph, in order to dynamically add new entities, it is necessary to establish an association between the new entity and the existing knowledge graph, and then complete the knowledge graph based on the new entity. However, in the process of completing the knowledge graph, a lot of manpower is required to collect and organize data. The exclusivity of data between different fields further exacerbates the difficulty of data collection and organization. At the same time, there is a lag in the collection process, resulting in poor data validity. Summary of the Invention
[0004] An embodiment of the present invention provides a method, device, electronic device, and computer-readable storage medium for processing a knowledge graph to solve or partially solve the problems of difficulty in data collection and poor data validity in the process of completing the knowledge graph.
[0005] An embodiment of the present invention discloses a method for processing a knowledge graph, comprising:
[0006] Obtaining a knowledge graph of a target domain and question-answering data corresponding to the target domain;
[0007] Performing entity relationship extraction on the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity;
[0008] Compare the target head entity and the target tail entity with the knowledge graph respectively, and mark the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the second entity type corresponding to the target tail entity;
[0009] According to the target entity relationship and the first entity type and / or the second entity type, the target head entity and / or the target tail entity are added to the knowledge graph.
[0010] Optionally, the knowledge graph includes several preset entity relationships, each of which links a head entity and a tail entity, and the method further includes:
[0011] Obtaining, from the knowledge graph, a head entity type corresponding to a head entity and a tail entity type corresponding to a tail entity in each of the preset entity relationships;
[0012] Relationship mapping is performed using each of the preset entity relationships and the corresponding head entity type and tail entity type to generate an entity type mapping table corresponding to the knowledge graph.
[0013] Optionally, the marking the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain a first entity type corresponding to the target head entity and / or a second entity type corresponding to the target tail entity includes:
[0014] Obtaining a preset entity relationship that is the same as the target entity relationship from the entity type mapping table, and obtaining a target head entity type and a target tail entity type corresponding to the preset entity relationship;
[0015] If the comparison result is that the target header entity is not included in the knowledge graph, and the target header entity successfully matches the target header entity type, then the target header entity type is used as the first entity type corresponding to the target header entity;
[0016] If the comparison result is that the target tail entity is not included in the knowledge graph, and the target tail entity successfully matches the target tail entity type, then the target tail entity type is used as the second entity type corresponding to the target tail entity;
[0017] If the comparison result is that the target head entity and the target tail entity are not included in the knowledge graph, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then the target head entity type is used as the first entity type corresponding to the target head entity and the target tail entity type is used as the second entity type corresponding to the target tail entity.
[0018] Optionally, adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type includes:
[0019] Searching for a first target entity corresponding to the first entity type from the knowledge graph, and entity linking the target header entity with the first target entity;
[0020] And / or, searching the knowledge graph for a second target entity corresponding to the second entity type, and entity linking the target tail entity with the second target entity.
[0021] Optionally, the adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type further includes:
[0022] If the comparison result is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity.
[0023] Optionally, the question-answer data includes at least question-answer sentences, and extracting entity relationships from the question-answer data to obtain target triples includes:
[0024] Obtaining an entity relationship extraction model corresponding to the knowledge graph;
[0025] The question-answer sentence is input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question-answer sentence, at least one target triple corresponding to the question-answer sentence is output.
[0026] Optionally, the entity relationship extraction model is generated in the following manner:
[0027] Obtaining training sentences corresponding to the target domain, and obtaining an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes current entity relationships between existing entities in the knowledge graph;
[0028] Model training is performed based on the training statements and the current entity relationship to generate an entity relationship extraction model corresponding to the knowledge graph.
[0029] The embodiment of the present invention further discloses a knowledge graph processing device, including:
[0030] A data acquisition module is used to acquire the knowledge graph of the target domain and the question-answering data corresponding to the target domain;
[0031] A triple acquisition module is used to extract entity relationships from the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity;
[0032] An entity type determination module is configured to compare the target head entity and the target tail entity with the knowledge graph respectively, and mark the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain a first entity type corresponding to the target head entity and / or a second entity type corresponding to the target tail entity;
[0033] A graph processing module is used to add the target head entity and / or the target tail entity to the knowledge graph based on the target entity relationship and the first entity type and / or the second entity type.
[0034] Optionally, the knowledge graph includes several preset entity relationships, each of which links a head entity and a tail entity, and the device further includes:
[0035] A type acquisition module, configured to acquire, from the knowledge graph, the head entity type corresponding to the head entity and the tail entity type corresponding to the tail entity in each of the preset entity relationships;
[0036] A mapping table generation module is used to use each of the preset entity relationships and the corresponding head entity type and tail entity type to perform relationship mapping to generate an entity type mapping table corresponding to the knowledge graph.
[0037] Optionally, the entity type determination module is specifically configured to:
[0038] Obtaining a preset entity relationship that is the same as the target entity relationship from the entity type mapping table, and obtaining a target head entity type and a target tail entity type corresponding to the preset entity relationship;
[0039] If the comparison result is that the target header entity is not included in the knowledge graph, and the target header entity successfully matches the target header entity type, then the target header entity type is used as the first entity type corresponding to the target header entity;
[0040] If the comparison result is that the target tail entity is not included in the knowledge graph, and the target tail entity successfully matches the target tail entity type, then the target tail entity type is used as the second entity type corresponding to the target tail entity;
[0041] If the comparison result is that the target head entity and the target tail entity are not included in the knowledge graph, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then the target head entity type is used as the first entity type corresponding to the target head entity and the target tail entity type is used as the second entity type corresponding to the target tail entity.
[0042] Optionally, the graph processing module is specifically used to:
[0043] Searching for a first target entity corresponding to the first entity type from the knowledge graph, and entity linking the target header entity with the first target entity;
[0044] And / or, searching the knowledge graph for a second target entity corresponding to the second entity type, and entity linking the target tail entity with the second target entity.
[0045] Optionally, the graph processing module is further configured to:
[0046] If the comparison result is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity.
[0047] Optionally, the question-and-answer data includes at least question-and-answer sentences, and the triple acquisition module is specifically configured to:
[0048] Obtaining an entity relationship extraction model corresponding to the knowledge graph;
[0049] The question-answer sentence is input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question-answer sentence, at least one target triple corresponding to the question-answer sentence is output.
[0050] Optionally, the entity relationship extraction model is generated by the following modules:
[0051] A training data acquisition module, configured to acquire training sentences corresponding to the target domain and to acquire an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes current entity relationships between existing entities in the knowledge graph;
[0052] The model training module is used to perform model training based on the training statements and the current entity relationship to generate an entity relationship extraction model corresponding to the knowledge graph.
[0053] An embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0054] The memory is used to store computer programs;
[0055] The processor is configured to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0056] An embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method according to the embodiment of the present invention.
[0057] The embodiments of the present invention include the following advantages:
[0058] In an embodiment of the present invention, in the process of completing the knowledge graph of the target domain, the question and answer data corresponding to the target domain can be obtained, and then the entity relationship extraction can be performed on the question and answer data to obtain the corresponding target triples, wherein the target triples can include the target head entity, the target tail entity and the target entity relationship between the target head entity and the target tail entity. Then, the target head entity and the target tail entity can be compared with the knowledge graph respectively, and the target head entity and / or the target tail entity can be marked according to the comparison result and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the second entity type corresponding to the target tail entity. type, and then add the target head entity and / or target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type. Therefore, when completing the knowledge graph, by extracting the corresponding target triples from the question and answer data, and using the content of the user's question as the knowledge source for completing the knowledge graph, the validity of the data is effectively guaranteed. At the same time, data collection is carried out based on vertical fields, which effectively reduces the difficulty of data collection. Moreover, by matching the acquired entity data with the knowledge graph, the knowledge graph is completed when the knowledge graph does not contain the corresponding entity, which effectively guarantees the comprehensiveness and validity of the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 This is a flowchart of a method for processing a knowledge graph provided in an embodiment of the present invention;
[0060] Figure 2 is a schematic diagram of a knowledge graph provided in an embodiment of the present invention;
[0061] Figure 3 is a schematic diagram of a knowledge graph provided in an embodiment of the present invention;
[0062] Figure 4 is a schematic diagram of a knowledge graph provided in an embodiment of the present invention;
[0063] Figure 5 This is a flowchart of a knowledge graph completion provided in an embodiment of the present invention;
[0064] Figure 6 This is a structural block diagram of a knowledge graph processing device provided in an embodiment of the present invention;
[0065] Figure 7 is a block diagram of an electronic device provided in an embodiment of the present invention;
[0066] Figure 8 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0067] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0068] As an example, knowledge graph completion is one of the important subtasks in the knowledge graph direction. For knowledge graph completion, it can be: given a knowledge graph G = {E, R, F}, where E represents the set of all entities, R represents the set of all relations, and F represents the set of all triples. The task of knowledge graph completion is to predict the missing triples in the current knowledge graph. h stands for head, which indicates the head entity in the triple, t stands for tail, which indicates the tail entity in the triple, and r stands for relation, which indicates the relationship between the head and tail entities in the triple. Depending on whether the completed entity is in E, knowledge graph completion can be divided into two subtasks:
[0069] 1. In closed domain knowledge graph completion, the entities of the triples to be completed are restricted to be in E, that is, static knowledge graph completion; 2. In open domain knowledge graph completion, there is no restriction that the entities must be in E, that is, dynamic knowledge graph completion.
[0070] For dynamic knowledge graph completion, in order to dynamically add new entities, it is necessary to establish an association between the new entity and the existing knowledge graph. This association requires the integration of additional information and the classification of the attributes of the additional information of the new entity. This can only be achieved in two specific scenarios:
[0071] Scenario 1: A new entity has rich textual information, such as entity name, entity description, and entity type. By comparing the similarities in textual expressions between known and unknown entities, we can establish an association between the two and learn the knowledge representation of the unknown entity.
[0072] Scenario 2: The new entity contains rich structural information, that is, there are a large number of triples containing the new entity and the known entities in the knowledge graph. The knowledge representation of the new entity can be output by propagating the knowledge representation of the known entity.
[0073] Based on the knowledge representation corresponding to the new entities learned in the above two scenarios, the missing triples are predicted to complete the knowledge graph. However, in the existing technology, both scenarios need to be met at the same time to complete the knowledge graph. In reality, for general fields, a lot of manpower is required to collect and organize the data required for the two sub-scenarios. In addition, the exclusivity of data between different fields further exacerbates the difficulty of data collection and organization. At the same time, there is a lag in the collection process, resulting in poor data validity.
[0074] In this regard, one of the core invention points of the present invention is that in the process of completing the knowledge graph of the target field, the question and answer data corresponding to the target field can be obtained, and then the entity relationship extraction of the question and answer data can be performed to obtain the corresponding target triples, wherein the target triples can include the target head entity, the target tail entity and the target entity relationship between the target head entity and the target tail entity, and then the target head entity and the target tail entity can be compared with the knowledge graph respectively, and the target head entity and / or the target tail entity can be marked according to the comparison results and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the first entity type corresponding to the target tail entity. The target entity type is a second entity type, and then the target head entity and / or target tail entity are added to the knowledge graph according to the target entity relationship with the first entity type and / or the second entity type. Therefore, when completing the knowledge graph, the corresponding target triples are extracted from the question and answer data, and the content of the user's question is used as the knowledge source for completing the knowledge graph, which effectively ensures the validity of the data. At the same time, data collection is carried out based on vertical fields, which effectively reduces the difficulty of data collection. Moreover, by matching the acquired entity data with the knowledge graph, the knowledge graph is completed when the knowledge graph does not contain the corresponding entity, which effectively ensures the comprehensiveness and validity of the knowledge graph.
[0075] Specifically, refer to Figure 1 , which shows a flowchart of a method for processing a knowledge graph provided in an embodiment of the present invention, which may specifically include the following steps:
[0076] Step 101: Obtain a knowledge graph of a target domain and question-answer data corresponding to the target domain;
[0077] Optionally, the target field may include industrial fields such as entertainment, medical care, environmental protection, education, and sports. In an embodiment of the present invention, the target field is the game field, and the knowledge graph is the knowledge base corresponding to a certain game as an example for illustrative explanation, so as to complete the corresponding knowledge graph based on the vertical field.
[0078] The knowledge graph can be an existing knowledge base in the target domain. It can be a knowledge base with a directed graph structure corresponding to the target domain, a data structure composed of entities, relationships, and attributes. As the knowledge content of the target domain increases, the knowledge graph needs to be supplemented to ensure the integrity and validity of the knowledge content contained in the knowledge graph.
[0079] The question and answer data may be data of user questions recorded in a question and answer system corresponding to the target field, for example, questions asked by players recorded in a question system corresponding to a certain game, etc. The present invention does not limit this.
[0080] Step 102: extract entity relationships from the question-answer data to obtain target triples, where the target triples include a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity.
[0081] For the knowledge graph of the target domain, when new content appears in the target domain, the new content cannot be automatically synchronized to the corresponding knowledge graph in a timely manner, which easily leads to the knowledge graph containing incomplete and inaccurate content. Moreover, as the knowledge base of the question-answering system corresponding to the target domain, the graph is the main source of knowledge to support question-answering. If the knowledge graph is not updated in a timely manner, the question-answering system will be unable to answer users' questions about the content. To this end, by utilizing the question-answering data in the question-answering system corresponding to the target domain, entity relationships are extracted to obtain corresponding target triples, and the knowledge graph is supplemented with target triples, so that the question-answering data contains the characteristics of new content in the target domain. When users ask questions about new content on the question-answering system, the target triples can be extracted and processed accordingly to update the knowledge graph, thereby ensuring that the knowledge base of the question-answering system is automatically updated and that users' questions can be processed more effectively.
[0082] In a specific implementation, the question and answer data may include different question and answer statements. The entity relationship extraction model corresponding to the knowledge graph may be obtained first, and then the question and answer statements may be input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question and answer statement, at least one target triple corresponding to the question and answer statement is output; if no triple is identified in the question and answer statement, processing is stopped. Thus, by performing entity relationship extraction on the question and answer data, it is possible to effectively identify whether a corresponding target triple exists in the question and answer data, so that if a target triple exists, the knowledge graph may be updated according to the obtained target triple to ensure the comprehensiveness and effectiveness of the content in the knowledge graph.
[0083] In an optional embodiment, an entity relationship extraction model can be generated by obtaining training sentences corresponding to the target domain and obtaining an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes the current entity relationships between existing entities in the knowledge graph. Then, a model can be trained based on the training sentences and the current entity relationships to generate an entity relationship extraction model corresponding to the knowledge graph. The entity relationship set can be a set of entity relationships between existing entities in the knowledge base of the target domain. For example, for a knowledge base of a game, its corresponding entity relationship set can include entity relationships such as voice actor, artist, planner, belonging, and instance.
[0084] Specifically, assuming that the existing relationship set in a vertical field knowledge graph is R, the relationship set R can include entity relationships between existing entities in the knowledge graph. Then, we can further obtain training sentences corresponding to the target field, and then use the training sentences as the input of the preset model, and use the entity relationship as the output of the preset model to perform model training and obtain an entity relationship extraction model. For the entity relationship extraction model, by inputting the corresponding question and answer sentences into the model, if there is one or several entity relationships in the relationship set R in the question and answer sentences, the model can output corresponding triples, such as (head entity, tail entity, r1), (head entity, tail entity, r2), etc. For example, assuming that there is an entity relationship in R called "voice actor", then "Is xxx voiced by yyy?" can be input into the model, and the entity relationship extraction model recognizes that the sentence contains the entity relationship "voice actor", and then can output target triples such as (xxx, yyy, voice actor). In the target triples, the head entity can be "xxx", the tail entity can be "yyy", and the entity relationship can be "voice actor". Therefore, when completing the knowledge graph, the corresponding target triples can be extracted from the question and answer data, so that the content of the user's question can be used as the knowledge source for completing the knowledge graph, thereby ensuring the comprehensiveness and effectiveness of the knowledge graph.
[0085] Step 103: Compare the target head entity and the target tail entity with the knowledge graph respectively, and mark the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the second entity type corresponding to the target tail entity;
[0086] After obtaining the corresponding target triplet through question and answer data, the target head entity and target tail entity in the target triplet need to be compared with the knowledge graph to determine whether the target head entity and / or target tail entity already exist in the knowledge graph. If so, there is no need to complete the knowledge graph; if not, the knowledge graph can be completed.
[0087] Specifically, if the comparison result shows that the knowledge graph does not contain at least one of the target head entity or the target tail entity, the non-existent entity can be marked according to the target entity relationship in the target triple to obtain the corresponding entity type. For example, when the target head entity does not exist in the knowledge graph corresponding to the target field, the target head entity can be marked according to the target entity relationship to obtain the first entity type corresponding to the target head entity; when the target tail entity does not exist in the knowledge graph, the target tail entity can be marked according to the target entity relationship to obtain the second entity type corresponding to the target tail entity; when both are not in the knowledge graph, the processing process is the same, so that by performing an entity link check on the entities in the target triple, it is identified whether the head entity and the tail entity in the triple already exist in the existing knowledge graph. If the entity in the target triple does not exist in the knowledge graph, it can be indicated that the content corresponding to the question and answer data is newly proposed and does not exist in the knowledge graph. Then, the knowledge graph is supplemented and updated with the new content contained in the question and answer data, which can effectively ensure the comprehensiveness and effectiveness of the content in the knowledge graph.
[0088] Optionally, the knowledge graph corresponding to the target domain may include several preset entity relationships, each preset entity relationship links a head entity and a tail entity. Before determining the entity types of the head entity and the tail entity in the target triple, the head entity type corresponding to the head entity and the tail entity type corresponding to the tail entity in each preset entity relationship can be obtained from the knowledge graph. Then, each preset entity relationship and the head entity type (of the head entity) and the tail entity type (of the tail entity) corresponding to the preset entity relationship can be used to perform relationship mapping to generate an entity type mapping table corresponding to the knowledge graph. When it is determined that the target head entity and / or target tail entity in the target triple does not exist in the knowledge graph, the target entity relationship that is the same as the target entity relationship can be obtained from the entity type mapping table, and the target head entity type and target tail entity type corresponding to the preset entity relationship can be obtained. If the target head entity matches the target head entity type successfully, the target head entity type is used as the first entity type corresponding to the target head entity; and / or, if the target tail entity matches the target tail entity type successfully, the target tail entity type is used as the second entity type corresponding to the target tail entity, thereby extracting the entity type of the entity in the target triple from the entity type mapping table corresponding to the knowledge graph through the target entity relationship in the target triple, so as to link the entities that do not exist in the knowledge graph according to the entity type, thereby completing the knowledge graph.
[0089] In one example, referring to Figure 2 , shows a schematic diagram of a knowledge graph provided in an embodiment of the present invention, which represents the knowledge base corresponding to a certain game, wherein the set E of all entities includes: game, character, producer, xx-A, and A, etc.; the set R of all entity relationships includes: belongs to, instance, voice actor, etc.; the set F of all triples includes: game-role-belongs to, game-producer-belongs to, character-xx-A-instance, producer-A-instance, xx-A-A-voice actor, etc. Then, based on the entities in the above knowledge graph and the entity relationships between entities, the corresponding entity type mapping table can be constructed as follows. In the entity type mapping table, the entity types of the head entity and tail entity corresponding to a certain entity relationship can be recorded:
[0090] Entity Relationships Header Entity Tail Entity belong game Role belong game Production staff Examples Role xx-A Examples Production staff First voice actor xx-A First
[0091] Among them, under the entity relationship of "belongs to", the entity type of the head entity is "game" and the entity type of the tail entity is "role", or the head entity is "game" and the tail entity is "production staff", etc. Assuming that the target triplet obtained from the question and answer data is (xx-B, B, voice actor), by performing entity linking on "xx-B" and "B", it is recognized that both do not exist in the knowledge graph. Then, according to the entity relationship of "voice actor", the head entity is obtained as "xx-A" and the tail entity is "A" from the entity type mapping table, and the entity type "role" to which "xx-A" belongs and the entity type "production staff" to which "A" belongs are found. It can be determined that the entity type corresponding to "xx-B" is also "role" and the entity type corresponding to "B" is "production staff". Therefore, the entity type of the entity in the target triplet is extracted from the entity type mapping table corresponding to the knowledge graph through the target entity relationship in the target triplet, so that the entities that do not exist in the knowledge graph can be linked according to the entity type, thereby completing the knowledge graph.
[0092] Step 104: Add the target head entity and / or the target tail entity to the knowledge graph based on the target entity relationship and the first entity type and / or the second entity type.
[0093] For entities that do not exist in the knowledge graph, they can be added to the knowledge graph based on the target entity relationship and the entity type corresponding to the entity, thereby updating the content of the knowledge graph. Specifically, the first target entity corresponding to the first entity type can be found from the knowledge graph, and the target head entity can be entity-linked to the first target entity; and / or, the second target entity corresponding to the second entity type can be found from the knowledge graph, and the target tail entity can be entity-linked to the second target entity. Moreover, if the comparison result between the entity in the target triple and the knowledge graph is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity, and the target entity relationship is added to the entity link.
[0094] In one case, if only the target head entity in the target triple does not exist in the knowledge graph, then only the target head entity can be added to the knowledge graph, and the target tail entity will not be processed; in another case, if only the target tail entity in the target triple does not exist in the knowledge graph, then only the target tail entity can be added to the knowledge graph, and the target head entity will not be processed; in another case, if both the target head entity and the target tail entity in the target triple do not exist in the knowledge graph, then both can be added to the knowledge graph, and the entity relationship corresponding to the two can be added to the knowledge graph together to construct a new triple in the knowledge graph.
[0095] Specifically, assuming that the target head entity in the target triple does not exist in the knowledge graph, after determining the first entity type of the target head entity, the first target entity corresponding to the first entity type can be determined from the knowledge graph, and the first target entity is used as the head node, and the target head entity is used as the tail node to link the target head entity to the first target entity, thereby adding the target head entity to the knowledge graph to complete the knowledge graph. For the target tail entity, the processing process is similar and will not be repeated here. When both the target head entity and the target tail entity do not exist in the knowledge graph, after linking the two to the corresponding entities, an entity link between the target head entity and the target tail entity can also be constructed, thereby adding the target triple to the knowledge graph.
[0096] For example, refer to Figure 3 , shows a schematic diagram of a knowledge graph provided in an embodiment of the present invention. Assuming that the target triple is (xx-B, Yi, voice actor), and both the head entity and the tail entity do not exist in the knowledge graph, then according to the entity type determined by the aforementioned process, the entity type of "xx-B" is "role", and the entity type of "Yi" is "production staff". Then, the entity corresponding to "role" can be found in the knowledge graph ("role" itself is an entity in the knowledge graph), and then "role" (this entity) is used as the head node and "xx-B" as the tail node, and the two are linked to add "xx-B" to the knowledge graph; similarly, "Yi" can be linked to "production staff" (this entity) to add "Yi" to the knowledge graph. And, referring to Figure 4 , showing a schematic diagram of a knowledge graph provided in an embodiment of the present invention. Since neither the target head entity nor the target tail entity in the target triplet exists in the knowledge graph, after linking the two to the knowledge graph, entity linking can also be performed between the two to construct the entity relationship of "voice actor", thereby adding the target triplet to the knowledge graph. By matching the acquired entity data with the knowledge graph, the knowledge graph is completed when the knowledge graph does not contain the corresponding entity, thereby effectively ensuring the comprehensiveness and effectiveness of the knowledge graph.
[0097] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention does not limit this.
[0098] In an embodiment of the present invention, in the process of completing the knowledge graph of the target domain, the question and answer data corresponding to the target domain can be obtained, and then the entity relationship extraction can be performed on the question and answer data to obtain the corresponding target triples, wherein the target triples can include the target head entity, the target tail entity and the target entity relationship between the target head entity and the target tail entity. Then, the target head entity and the target tail entity can be compared with the knowledge graph respectively, and the target head entity and / or the target tail entity can be marked according to the comparison result and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the second entity type corresponding to the target tail entity. type, and then add the target head entity and / or target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type. Therefore, when completing the knowledge graph, by extracting the corresponding target triples from the question and answer data, and using the content of the user's question as the knowledge source for completing the knowledge graph, the validity of the data is effectively guaranteed. At the same time, data collection is carried out based on vertical fields, which effectively reduces the difficulty of data collection. Moreover, by matching the acquired entity data with the knowledge graph, the knowledge graph is completed when the knowledge graph does not contain the corresponding entity, which effectively guarantees the comprehensiveness and validity of the knowledge graph.
[0099] In order to help those skilled in the art better understand the technical solutions of the embodiments of the present invention, an example is given below to illustrate:
[0100] Reference Figure 5 , shows a flow chart of a knowledge graph completion method provided in an embodiment of the present invention, which may specifically include the following process:
[0101] 1. Preparation work: complete the entity relationship extraction model; complete the relationship <-> entity type mapping table.
[0102] 2. Detect the questions submitted by users and extract them using the entity relationship extraction model.
[0103] 3. If no triplet is extracted in step 2, exit; if a triplet is extracted, go to step 4.
[0104] 4. Perform entity linking between the head and tail entities of the triples extracted in step 3 and the existing graph to check whether the extracted entities already exist in the graph; save the relationship between the triples extracted in step 3.
[0105] 5. Based on the results of entity linking in step 4, if all the extracted entities are in the graph, exit; if all or part of the extracted entities are not in the graph, proceed to step 6.
[0106] 6. Entities not in the graph obtained in step 5 are considered new entities. Combined with the relationship <-> entity type mapping table from step 1 and the triple relationship obtained in step 4, the head and tail entity types of the relationship are found. Based on whether the new entity is the head or tail entity in the triple, the corresponding entity type of the new entity is determined.
[0107] 7. Add new entities to the graph.
[0108] 8. Use the new entity as the tail node and the node of the type to which the new entity belongs as the head node, and link the two with a "belongs to" relationship.
[0109] 9. Check whether the head and tail entities in the extracted triple are both new entities. If they are both new entities, proceed to step 10; otherwise, proceed to step 11.
[0110] 10. In the graph, link the two new entities based on the head-tail relationship in the extracted triples, that is, the relationship between the triples saved in step 4. Complete the graph.
[0111] 11. Save the non-new entity in the triple and search for it in the graph. In the graph, link the non-new entity with the new entity based on the head-tail relationship in the extracted triple, i.e., the relationship between the triples saved in step 4. This completes the graph.
[0112] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0113] Reference Figure 6 , shows a structural block diagram of a knowledge graph processing device provided in an embodiment of the present invention, which may specifically include the following modules:
[0114] Data acquisition module 601, used to acquire the knowledge graph of the target domain and the question-answer data corresponding to the target domain;
[0115] A triple acquisition module 602 is configured to extract entity relationships from the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity;
[0116] An entity type determination module 603 is configured to compare the target head entity and the target tail entity with the knowledge graph, respectively, and mark the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain a first entity type corresponding to the target head entity and / or a second entity type corresponding to the target tail entity;
[0117] A graph processing module is used to add the target head entity and / or the target tail entity to the knowledge graph based on the target entity relationship and the first entity type and / or the second entity type.
[0118] In an optional embodiment, the knowledge graph includes several preset entity relationships, each of which links a head entity and a tail entity, and the apparatus further includes:
[0119] A type acquisition module, configured to acquire, from the knowledge graph, the head entity type corresponding to the head entity and the tail entity type corresponding to the tail entity in each of the preset entity relationships;
[0120] A mapping table generation module is used to use each of the preset entity relationships and the corresponding head entity type and tail entity type to perform relationship mapping to generate an entity type mapping table corresponding to the knowledge graph.
[0121] In an optional embodiment, the entity type determination module 603 is specifically configured to:
[0122] Obtaining a preset entity relationship that is the same as the target entity relationship from the entity type mapping table, and obtaining a target head entity type and a target tail entity type corresponding to the preset entity relationship;
[0123] If the comparison result is that the target header entity is not included in the knowledge graph, and the target header entity successfully matches the target header entity type, then the target header entity type is used as the first entity type corresponding to the target header entity;
[0124] If the comparison result is that the target tail entity is not included in the knowledge graph, and the target tail entity successfully matches the target tail entity type, then the target tail entity type is used as the second entity type corresponding to the target tail entity;
[0125] If the comparison result is that the target head entity and the target tail entity are not included in the knowledge graph, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then the target head entity type is used as the first entity type corresponding to the target head entity and the target tail entity type is used as the second entity type corresponding to the target tail entity.
[0126] In an optional embodiment, the graph processing module is specifically configured to:
[0127] Searching for a first target entity corresponding to the first entity type from the knowledge graph, and entity linking the target header entity with the first target entity;
[0128] And / or, searching the knowledge graph for a second target entity corresponding to the second entity type, and entity linking the target tail entity with the second target entity.
[0129] In an optional embodiment, the graph processing module is further configured to:
[0130] If the comparison result is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity.
[0131] In an optional embodiment, the question-answer data includes at least question-answer sentences, and the triple acquisition module 602 is specifically configured to:
[0132] Obtaining an entity relationship extraction model corresponding to the knowledge graph;
[0133] The question-answer sentence is input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question-answer sentence, at least one target triple corresponding to the question-answer sentence is output.
[0134] In an optional embodiment, the entity relationship extraction model is generated by the following modules:
[0135] A training data acquisition module 601 is configured to acquire training sentences corresponding to the target domain and to acquire an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes current entity relationships between existing entities in the knowledge graph;
[0136] The model training module is used to perform model training based on the training statements and the current entity relationship to generate an entity relationship extraction model corresponding to the knowledge graph.
[0137] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0138] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 7As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.
[0139] Memory 703, for storing computer programs;
[0140] The processor 701 is configured to execute the program stored in the memory 703, and implement the following steps:
[0141] Obtaining a knowledge graph of a target domain and question-answering data corresponding to the target domain;
[0142] Performing entity relationship extraction on the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity;
[0143] Compare the target head entity and the target tail entity with the knowledge graph respectively, and mark the target head entity and / or the target tail entity according to the comparison result and the target entity relationship to obtain the first entity type corresponding to the target head entity and / or the second entity type corresponding to the target tail entity;
[0144] According to the target entity relationship and the first entity type and / or the second entity type, the target head entity and / or the target tail entity are added to the knowledge graph.
[0145] In an optional embodiment, the knowledge graph includes several preset entity relationships, each of which links a head entity and a tail entity, and the method further includes:
[0146] Obtaining, from the knowledge graph, a head entity type corresponding to a head entity and a tail entity type corresponding to a tail entity in each of the preset entity relationships;
[0147] Relationship mapping is performed using each of the preset entity relationships and the corresponding head entity type and tail entity type to generate an entity type mapping table corresponding to the knowledge graph.
[0148] In an optional embodiment, a preset entity relationship that is the same as the target entity relationship is obtained from the entity type mapping table, and a target head entity type and a target tail entity type corresponding to the preset entity relationship are obtained;
[0149] If the comparison result is that the target header entity is not included in the knowledge graph, and the target header entity successfully matches the target header entity type, then the target header entity type is used as the first entity type corresponding to the target header entity;
[0150] If the comparison result is that the target tail entity is not included in the knowledge graph, and the target tail entity successfully matches the target tail entity type, then the target tail entity type is used as the second entity type corresponding to the target tail entity;
[0151] If the comparison result is that the target head entity and the target tail entity are not included in the knowledge graph, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then the target head entity type is used as the first entity type corresponding to the target head entity and the target tail entity type is used as the second entity type corresponding to the target tail entity.
[0152] In an optional embodiment, adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type includes:
[0153] Searching for a first target entity corresponding to the first entity type from the knowledge graph, and entity linking the target header entity with the first target entity;
[0154] And / or, searching the knowledge graph for a second target entity corresponding to the second entity type, and entity linking the target tail entity with the second target entity.
[0155] In an optional embodiment, the adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type further includes:
[0156] If the comparison result is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity.
[0157] In an optional embodiment, the question-answer data includes at least question-answer sentences, and extracting entity relationships from the question-answer data to obtain target triples includes:
[0158] Obtaining an entity relationship extraction model corresponding to the knowledge graph;
[0159] The question-answer sentence is input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question-answer sentence, at least one target triple corresponding to the question-answer sentence is output.
[0160] In an optional embodiment, the entity relationship extraction model is generated in the following manner:
[0161] Obtaining training sentences corresponding to the target domain, and obtaining an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes current entity relationships between existing entities in the knowledge graph;
[0162] Model training is performed based on the training statements and the current entity relationship to generate an entity relationship extraction model corresponding to the knowledge graph.
[0163] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0164] The communication interface is used for communication between the above terminal and other devices.
[0165] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0166] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0167] like Figure 8 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 801 is also provided, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the knowledge graph processing method described in the above embodiment.
[0168] In another embodiment provided by the present invention, a computer program product containing instructions is also provided, which, when run on a computer, enables the computer to execute the knowledge graph processing method described in the above embodiment.
[0169] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0170] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0171] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0172] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A method for processing a knowledge graph, characterized in that: include: Obtaining a knowledge graph of a target domain and question-answering data in a question-answering system corresponding to the target domain; wherein the knowledge graph includes several preset entity relationships, each of which links a head entity and a tail entity; Obtaining, from the knowledge graph, a head entity type corresponding to a head entity and a tail entity type corresponding to a tail entity in each of the preset entity relationships; Perform relationship mapping using each of the preset entity relationships and the corresponding head entity type and tail entity type to generate an entity type mapping table corresponding to the knowledge graph; Performing entity relationship extraction on the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity; Obtaining a preset entity relationship that is the same as the target entity relationship from the entity type mapping table, and obtaining a target head entity type and a target tail entity type corresponding to the preset entity relationship; Compare the target head entity and the target tail entity with the knowledge graph respectively; If the comparison result is that the target header entity is not included in the knowledge graph, and the target header entity successfully matches the target header entity type, then the target header entity type is used as the first entity type corresponding to the target header entity; If the comparison result is that the target tail entity is not included in the knowledge graph, and the target tail entity successfully matches the target tail entity type, then the target tail entity type is used as the second entity type corresponding to the target tail entity; If the comparison result is that the target head entity and the target tail entity are not included in the knowledge graph, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then the target head entity type is used as the first entity type corresponding to the target head entity, and the target tail entity type is used as the second entity type corresponding to the target tail entity; According to the target entity relationship and the first entity type and / or the second entity type, the target head entity and / or the target tail entity are added to the knowledge graph.
2. The method according to claim 1, characterized in that The adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type includes: Searching for a first target entity corresponding to the first entity type from the knowledge graph, and entity linking the target header entity with the first target entity; And / or, searching the knowledge graph for a second target entity corresponding to the second entity type, and entity linking the target tail entity with the second target entity.
3. The method according to claim 2, characterized in that The adding the target head entity and / or the target tail entity to the knowledge graph according to the target entity relationship and the first entity type and / or the second entity type further includes: If the comparison result is that the target head entity and the target tail entity do not exist in the knowledge graph, the target entity relationship is used to construct an entity link from the target head entity to the target tail entity.
4. The method according to claim 1, wherein The question-answer data includes at least question-answer sentences, and extracting entity relationships from the question-answer data to obtain target triples includes: Obtaining an entity relationship extraction model corresponding to the knowledge graph; The question-answer sentence is input into the entity relationship extraction model for entity relationship recognition. If a triple is identified in the question-answer sentence, at least one target triple corresponding to the question-answer sentence is output.
5. The method according to claim 4, characterized in that The entity relationship extraction model is generated in the following way: Obtaining training sentences corresponding to the target domain, and obtaining an existing entity relationship set from the knowledge graph, wherein the entity relationship set includes current entity relationships between existing entities in the knowledge graph; Model training is performed based on the training statements and the current entity relationship to generate an entity relationship extraction model corresponding to the knowledge graph.
6. A knowledge graph processing device, characterized in that: include: A data acquisition module is configured to acquire a knowledge graph of a target domain and question-answering data in a question-answering system corresponding to the target domain; wherein the knowledge graph includes a plurality of preset entity relationships, each of which links a head entity and a tail entity; A type acquisition module, configured to acquire, from the knowledge graph, the head entity type corresponding to the head entity and the tail entity type corresponding to the tail entity in each of the preset entity relationships; A mapping table generation module is used to use each of the preset entity relationships and the corresponding head entity type and tail entity type to perform relationship mapping to generate an entity type mapping table corresponding to the knowledge graph; A triple acquisition module is used to extract entity relationships from the question-answer data to obtain a target triple, wherein the target triple includes a target head entity, a target tail entity, and a target entity relationship between the target head entity and the target tail entity; an entity type determination module, configured to obtain a preset entity relationship identical to the target entity relationship from the entity type mapping table, and obtain a target head entity type and a target tail entity type corresponding to the preset entity relationship; compare the target head entity and the target tail entity with the knowledge graph respectively; if the comparison result is that the knowledge graph does not contain the target head entity, and the target head entity successfully matches the target head entity type, then use the target head entity type as the first entity type corresponding to the target head entity; if the comparison result is that the knowledge graph does not contain the target tail entity, and the target tail entity successfully matches the target tail entity type, then use the target tail entity type as the second entity type corresponding to the target tail entity; if the comparison result is that the knowledge graph does not contain the target head entity and the target tail entity, and the target head entity successfully matches the target head entity type, and the target tail entity successfully matches the target tail entity type, then use the target head entity type as the first entity type corresponding to the target head entity, and use the target tail entity type as the second entity type corresponding to the target tail entity; A graph processing module is used to add the target head entity and / or the target tail entity to the knowledge graph based on the target entity relationship and the first entity type and / or the second entity type.
7. An electronic device, characterized in that: comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 5 when executing a program stored in the memory.
8. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Knowledge graph expansion method, electronic equipment and storage medium
CN112100343A
Knowledge graph detection method and related device, electronic equipment and storage medium
CN113407736A