Knowledge graph generation method and device
By filtering and selecting entities in text shards, calculating information entropy and conditional entropy, and generating edges with the largest gain ratio of information entropy as relationships, the accuracy and adaptability problems of the existing knowledge graph training methods are solved, and efficient and accurate knowledge graph generation is achieved.
Patent Information
- Application Number
- CN202411607100.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-25
AI Technical Summary
The existing knowledge graph training methods have the problems of high accuracy but high cost of rulemaking, strong adaptability, but require a large amount of labeling data and insufficient flexibility.
By filtering entities based on the correlation relationship between entities in text shards, selecting the target entity set using the mutual information of entities, calculating the conditional entropy of the total information entropy and edges, and generating an edge with the largest information entropy gain ratio as a relationship to generate a knowledge graph.
Accurate and efficient generation of knowledge graphs, overcomes the many shortcomings of existing methods, and is able to handle complex relationships and adapt to variable text environments.
Smart Images

Figure CN119692442A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and specifically to a knowledge graph generation method and device. Background Art
[0002] Knowledge Graph is a structured knowledge base that is used to describe concepts, entities and their relationships in the physical world in symbolic form. This representation method enables machines to understand and interpret these complex relationships, thereby supporting richer application scenarios such as semantic search, link analysis, recommendation systems, and question-answering. Its basic components are "entity-relationship-entity" triples, as well as entities and their related attribute-value pairs. Entities are connected to each other through relationships to form a network of knowledge structures.
[0003] Existing knowledge graph training methods include rule-based methods, machine learning-based methods, and graph theory-based methods, as follows:
[0004] Rule-based method: This method usually relies on manually defined rules and templates and is suitable for building knowledge graphs in specific fields or tasks. Its advantage is high accuracy, but its disadvantage is high cost of rule formulation and difficulty in adapting to complex and changing text environments.
[0005] Machine learning-based methods: This method uses statistical learning or deep learning models to automatically identify entities, relationships, and attributes in text. Its advantages are strong adaptability and the ability to process large-scale text data, but its disadvantages are that model training requires a large amount of labeled data, and its performance is affected by data quality and model complexity.
[0006] Graph-theory-based methods: This method regards the knowledge graph as a graph structure and uses graph-theory algorithms to analyze and process the data in the knowledge graph. Its advantages are that it can intuitively represent the relationship between entities and facilitate operations such as graph traversal and path search, but its disadvantage is that it may not be flexible enough to handle complex relationships. Summary of the invention
[0007] In response to the problems in the prior art, an embodiment of the present invention provides a knowledge graph generation method and device, which can at least partially solve the problems existing in the prior art.
[0008] On the one hand, the present invention proposes a knowledge graph generation method, comprising:
[0009] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0010] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0011] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0012] The screening of entities according to the association relationship between entities in the text segments includes:
[0013] Obtain an entity set consisting of all entities in the text segment, and calculate the intersection-and-union ratio corresponding to every two entities in the entity set;
[0014] Entities whose intersection-over-union ratio is greater than the preset intersection-over-union ratio threshold are taken as screening results.
[0015] The selecting entities according to the screening results and using the mutual information of the entities to obtain a target entity set includes:
[0016] Sorting the entities in the screening results in descending order according to the maximum mutual information, and selecting a set of candidate entities that are ranked first and whose number is equal to a first preset number;
[0017] The entities of the candidate entity set are sorted in descending order according to the absolute value of the minimum mutual information, and a target entity set with a top ranking and a number equal to a second preset number is selected.
[0018] The calculating of the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge includes:
[0019] The information entropy gain ratio is calculated according to the following formula:
[0020]
[0021] Among them, G(D,G) is the information entropy gain ratio, H(D,V) is the total information entropy, and H(D|G) is the conditional entropy of the edge.
[0022] Wherein, determining the first preset number includes:
[0023] Classifying the entities in the screening results according to the mutual information size, and determining the first classification center of each first classification;
[0024] Classify each non-first classification center entity according to the difference between the mutual information of each non-first classification center entity and each first classification center, and obtain a first classification cluster corresponding to each first classification;
[0025] Calculate the new first classification center corresponding to each first classification cluster respectively. If the new first classification center is different from the corresponding original first classification center, update the first classification center, and periodically execute the difference between the mutual information of each non-first classification center entity and each first classification center and subsequent steps until the preset convergence condition is met. The number of entities in the first classification cluster with the largest mutual information at this time is taken as the first preset number.
[0026] Wherein, determining the second preset number includes:
[0027] Classify the entities in the candidate entity set according to the absolute value of the mutual information, and determine the second classification center of each second classification;
[0028] Classify each non-second classification center entity according to the difference between the mutual information of each non-second classification center entity and each second classification center, and obtain a second classification cluster corresponding to each second classification;
[0029] Calculate the new second classification center corresponding to each second classification cluster respectively. If the new second classification center is different from the corresponding original second classification center, update the second classification center, and periodically execute the difference between the mutual information of each non-second classification center entity and each second classification center and subsequent steps until the preset convergence condition is met. The number of entities in the second classification cluster with the largest mutual information at this time is taken as the second preset number.
[0030] Wherein, after the step of generating a knowledge graph, the knowledge graph generation method further includes:
[0031] The mutual information between every two nodes in the knowledge graph is calculated, and a knowledge graph label is generated according to the mutual information calculation result to obtain an optimized knowledge graph.
[0032] On the one hand, the present invention proposes a knowledge graph generation device, comprising:
[0033] An acquisition unit is used to filter entities according to the association relationship between entities in the text segment, select entities according to the filtering result and using the mutual information of the entities to obtain a target entity set;
[0034] A calculation unit, used to calculate the total information entropy of the target entity set within a preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0035] A generating unit is used to calculate the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and take the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph.
[0036] In another aspect, an embodiment of the present invention provides an electronic device, including: a processor, a memory, and a bus, wherein:
[0037] The processor and the memory communicate with each other via the bus;
[0038] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the following method:
[0039] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0040] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0041] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0042] An embodiment of the present invention provides a non-transitory computer-readable storage medium, including:
[0043] The non-transitory computer-readable storage medium stores computer instructions, which cause the computer to execute the following method:
[0044] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0045] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0046] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0047] The knowledge graph generation method and device provided by the embodiment of the present invention screen entities according to the association relationship between entities in text segments, select entities according to the screening results and using the mutual information of the entities to obtain a target entity set; calculate the total information entropy of the target entity set in a preset variable value range, and calculate the conditional entropy of the edge between every two variables in the preset variable value range; calculate the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and use the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph, which overcomes many shortcomings in existing knowledge graph training methods and can accurately and efficiently generate knowledge graphs. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0049] Figure 1 It is a flowchart of a knowledge graph generation method provided in one embodiment of the present invention.
[0050] Figure 2 It is a schematic diagram illustrating the knowledge graph provided by an embodiment of the present invention.
[0051] Figure 3 It is a schematic diagram illustrating the optimized knowledge graph provided by an embodiment of the present invention.
[0052] Figure 4 It is a structural diagram of a knowledge graph generating device provided by one embodiment of the present invention.
[0053] Figure 5 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other arbitrarily.
[0055] Explanation of related terms:
[0056] Mutual Information:
[0057] For a given set of two discrete events {X,q(x k )} and {Y,w(y j )}, event y j The occurrence of ∈Y gives the k The amount of information ∈X is defined as I(x k ,y j )=log a p(x k |y j ) / q(x k ). Where X and Y represent two discrete event sets, q(x k ) and w(y j ) represent the probability of the corresponding events occurring.
[0058] Event j The occurrence of ∈Y gives the k The amount of information I(x∈X k ,y j ) and event x k The occurrence of ∈X gives the j The amount of information ∈Y is defined as I(y j ,x k ) are equal and are collectively referred to as the mutual information of two events.
[0059] Bayesian Networks:
[0060] Bayesian network, full name Bayesian belief network, is a probabilistic graphical model that uses a directed acyclic graph to describe random variables and their conditional dependencies. Each node in the network is associated with a conditional probability table (CPT), which defines the probability of the node state given the state of the parent node. Each edge represents a direct connection or causal relationship between nodes. If there is a causal relationship between two nodes, they are connected by a unidirectional arrow, where one node represents the "cause" (or parent node) and the other represents the "effect" (or child node).
[0061] The structural learning algorithms of Bayesian networks mainly include algorithms based on scoring search, algorithms based on dependency analysis, and algorithms based on hybrid learning.
[0062] Figure 1 is a flow chart of a knowledge graph generation method provided by an embodiment of the present invention, such as Figure 1 As shown, the knowledge graph generation method provided by the embodiment of the present invention includes:
[0063] Step S1: Filter entities according to the association relationship between entities in the text segment, select entities according to the screening results and use the mutual information of the entities to obtain a target entity set.
[0064] Step S2: Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range.
[0065] Step S3: Calculate the information entropy gain ratio between every two variables based on the total information entropy and the conditional entropy of the edge, and take the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph.
[0066] In the above step S1, the device screens the entities according to the association relationship between the entities in the text segment, selects the entities according to the screening result and uses the mutual information of the entities to obtain the target entity set. The device can be a computer device that executes the method. It should be noted that the acquisition and analysis of data involved in the embodiment of the present invention is authorized by the user. Acquiring entities in the text segment includes:
[0067] The text is segmented into sentences or paragraphs, and all entities in the text segment are extracted using a large model and prompt words to obtain the entities in the text segment.
[0068] The screening of entities according to the association relationship between entities in the text segment includes:
[0069] Obtain an entity set consisting of all entities in the text segment, and calculate the intersection-and-union ratio corresponding to every two entities in the entity set;
[0070] Entities with an IOR greater than a preset IOR threshold are selected as screening results. The preset IOR threshold can be set independently according to actual conditions and can be selected as 0.5.
[0071] The intersection-over-union ratio (IOU) (a, b) between entity a and entity b is calculated according to the following formula:
[0072]
[0073] Among them, Num(a∩b) represents the number of text fragments containing both entity a and entity b, and Num(a∪b) represents the number of text fragments containing entity a or entity b. When IOU(a,b)>0.5, it means that entity a and entity b are likely to be associated; otherwise, entity a and entity b are considered to be unrelated. The initial screening of entities can be completed through the intersection and union ratio, which reduces the amount of computation required for subsequent structural extraction. The above-mentioned entity a or entity b can be used as the target entity to be analyzed, and other entities with an intersection and union ratio greater than 0.5 with the target entity can be used as the coupling set of the target entity, and the coupling set is initialized. At this time, the coupling set The target entity to be analyzed can be selected and determined according to actual conditions. For example, if the goal of energy conservation and emission reduction is to be achieved, the target entity can be carbon emissions, and the factors affecting carbon emissions can be entities associated with the target entity.
[0074] The entity is selected according to the screening result and using the mutual information of the entity to obtain a target entity set, including:
[0075] The entities in the screening results are sorted in descending order according to the maximum mutual information, and a set of candidate entities with a top ranking and a number equal to a first preset number are selected; the mutual information between entity A1 in the screening results and the target entity M is calculated, and entity A1 is included in the coupling set of the target entity M. The maximum mutual information between entity A2 and the target entity M in all subsets of the coupling set is calculated, and A2 is included in the coupling set. After A1 is included in the coupling set, the subset of the coupling set is A1 at this time, and the maximum mutual information is the mutual information between A2 and M with A1 as the condition. At this time, the subsets of the coupling set are A1 and A2. Then, the mutual information between A3 and M with A1 as the condition, the mutual information between A3 and M with A2 as the condition, and the mutual information between A3 and M with the combination of A1 and A2 as the condition are calculated. The above three mutual information are compared, and the largest mutual information is taken as the maximum mutual information at this time.
[0076] Similarly, all entities whose intersection-over-union ratio with the target entity M is less than 0.5 are included in the coupling set, and sorted in descending order according to the maximum mutual information to obtain a candidate entity set, where the number of entities in the candidate entity set is equal to the first preset number K1. This step is to increase the coupling set, with the purpose of first adopting relaxed conditions to take all related entities into account.
[0077] The entities of the candidate entity set are sorted in descending order according to the absolute value of the minimum mutual information, and a target entity set with a top ranking and a number equal to the second preset number is selected. For each entity in the K1 entities, such as Ax, the minimum mutual information between Ax and the target entity M in all subsets of the coupling set except the subset where Ax is located is calculated, and so on, the minimum mutual information coupling set of the target entity M is obtained, and the entities in this set are sorted from large to small according to the absolute value of the minimum mutual information to obtain the target entity set, and the number of entities in the target entity set is equal to the second preset number K2. After each calculation of the minimum mutual information, Ax can also be put back into the candidate entity set, and the minimum mutual information and the calculation process of the minimum mutual information can refer to the relevant instructions of the above-mentioned maximum mutual information. This step is to reduce the coupling set, and the purpose is to adopt strict conditions later to eliminate all entities with low correlation.
[0078] The present invention makes adjustments to the algorithm for determining the parent-child set of the target entity based on MMPC. The traditional MMPC algorithm uses whether the coupling information is 0 to measure the independence between entities. However, in the case of an incomplete data set, the coupling information between two independent entities is not necessarily 0. To solve the above problems, the present invention, based on the MMPC algorithm, adopts a clustering algorithm based on mutual information as the basis for independence judgment, which effectively improves the accuracy of independence judgment.
[0079] In the above step S2, the device calculates the total information entropy of the target entity set within the preset variable value range, and calculates the conditional entropy of the edge between every two variables within the preset variable value range.
[0080] The total information entropy is calculated according to the following formula:
[0081]
[0082] Among them, H(D,V) is the total information entropy, D is the target entity set, and V is the preset variable value range. Referring to the above example, the technical factors affecting carbon emissions include the proportion of solar energy use in all energy use and the proportion of wind energy use in all energy use. The value ranges of the above two proportions are the preset variable value ranges. i is the i-th variable, p(d i |D\{d i}) is the probability of occurrence of the ith variable under the condition that other variables in the target entity set except the ith variable have occurred.
[0083] The conditional entropy of the edge is calculated according to the following formula:
[0084]
[0085] Where H(D|G) is the total information entropy, d j is the jth variable, p(d j |d i ) is the probability of occurrence of the jth variable under the condition that the ith variable has occurred. The conditional entropy is calculated for any two variables d i and d j The conditional entropy of changing an edge (adding, deleting, or redirecting).
[0086] In the above step S3, the device calculates the information entropy gain ratio between each two variables according to the total information entropy and the conditional entropy of the edge, and uses the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph. The information entropy gain ratio between each two variables calculated according to the total information entropy and the conditional entropy of the edge includes:
[0087] The information entropy gain ratio is calculated according to the following formula:
[0088]
[0089] Wherein, G(D,G) is the information entropy gain ratio, H(D,V) is the total information entropy, and H(D|G) is the conditional entropy of the edge. The step of calculating the conditional entropy of the edge is performed periodically, and each time the operation that maximizes the information entropy gain ratio is selected as the relationship between the two variables until the maximum number of convergences is reached.
[0090] The edge operation type is the above-mentioned adding edge, deleting edge or redirecting edge. The redirection means that the original edge points from entity c to entity d, and the redirected edge points from entity d to entity c. The knowledge graph is as follows Figure 2 As shown in the figure. Traditional Bayesian network structure learning algorithms mostly assume that the prior probability of the network structure follows the Dirichlet distribution, thereby obtaining a scoring function based on BDeu. Then all network structures are traversed to calculate the maximum value of the scoring function. However, the above method has a big problem in terms of computational complexity: as the coupling set of the target variable increases, the number of network structures increases exponentially.
[0091] The present invention adopts a greedy algorithm based on information entropy gain ratio to find the optimal network structure from the parent-child set of the target variable. In each iteration, an attempt is made to select the edge that reduces the current network information entropy the most as the relationship constraint between the two variables. By setting an appropriate number of iterations, the optimal network structure under the current number of iterations is generated.
[0092] Determining the first preset number includes:
[0093] Classifying the entities in the screening results according to the mutual information size, and determining the first classification center of each first classification;
[0094] Classify each non-first classification center entity according to the difference between the mutual information of each non-first classification center entity and each first classification center, and obtain a first classification cluster corresponding to each first classification;
[0095] Calculate the new first classification center corresponding to each first classification cluster respectively. If the new first classification center is different from the corresponding original first classification center, update the first classification center, and periodically execute the difference between the mutual information of each non-first classification center entity and each first classification center and subsequent steps until the preset convergence condition is met. The number of entities in the first classification cluster with the largest mutual information at this time is taken as the first preset number.
[0096] First, the center of the clustering algorithm is initialized: the entities in the coupling set are divided into three categories according to the size of the mutual information. The first category of centers are the entities with the highest mutual information ranking in the coupling set, the second category of centers are the entities with the middle mutual information ranking in the coupling set, and the third category of centers are the entities with the lowest mutual information ranking in the coupling set.
[0097] Then, for each non-central entity, the difference between the mutual information and the three centers is calculated. The entity with the smallest mutual information difference with the center is included in the center, and so on.
[0098] Finally, update the classification center and repeat the above step of "for each non-center entity, calculate the difference between the mutual information of the three centers" until the maximum number of iterations is reached or the classification center converges (that is, the classification center after iteration is the same as the classification center before iteration). Select all entities located in the first classification center as the candidate entity set, whose size is K1.
[0099] Determining the second preset number includes:
[0100] Classify the entities in the candidate entity set according to the absolute value of the mutual information, and determine the second classification center of each second classification;
[0101] Classify each non-second classification center entity according to the difference between the mutual information of each non-second classification center entity and each second classification center, and obtain a second classification cluster corresponding to each second classification;
[0102] Calculate the new second classification center corresponding to each second classification cluster. If the new second classification center is different from the corresponding original second classification center, update the second classification center, and periodically perform the difference between the mutual information of each non-second classification center entity and each second classification center and subsequent steps until the preset convergence condition is met. The number of entities in the second classification cluster with the largest mutual information at this time is taken as the second preset number. The principle of determining the second preset number is the same as the principle of determining the first preset number, and will not be repeated. All entities located in the first classification center are selected as the target entity set, and its size is K2.
[0103] After the step of generating a knowledge graph, the knowledge graph generation method further includes:
[0104] Calculate the mutual information between every two nodes in the knowledge graph, generate a knowledge graph tag based on the mutual information calculation result, and obtain an optimized knowledge graph. Figure 2In the knowledge graph shown in the figure, if the mutual information is greater than 0, it is considered that there is a positive correlation between the two nodes (nodes represent entities), which is represented by +; if the mutual information is less than 0, it is considered that there is a negative correlation between the two nodes, which is represented by -. Each node will record the mutual information of the nodes associated with it, and finally complete the construction of the knowledge graph, such as Figure 3 shown.
[0105] The knowledge graph generation method provided by the embodiment of the present invention screens entities according to the association relationship between entities in text segments, selects entities according to the screening results and uses the mutual information of the entities to obtain a target entity set; calculates the total information entropy of the target entity set in a preset variable value range, and calculates the conditional entropy of the edge between every two variables in the preset variable value range; calculates the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and uses the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph, which overcomes many shortcomings in the existing knowledge graph training methods and can accurately and efficiently generate knowledge graphs.
[0106] Furthermore, the screening of entities according to the association relationship between entities in the text segments includes:
[0107] An entity set consisting of all entities in the text segment is obtained, and an intersection-and-union ratio corresponding to every two entities in the entity set is calculated; this can be described with reference to the above embodiment and will not be repeated here.
[0108] The entities whose intersection-over-union ratio is greater than a preset intersection-over-union ratio threshold are taken as screening results. The above-mentioned embodiments can be referred to for explanation, and no further description is given.
[0109] Furthermore, the selecting entities according to the screening results and using the mutual information of the entities to obtain a target entity set includes:
[0110] The entities in the screening results are sorted in descending order according to the maximum mutual information, and a set of candidate entities with a top ranking and a number equal to a first preset number are selected; the description can be made with reference to the above embodiment and will not be repeated here.
[0111] The entities in the candidate entity set are sorted in descending order according to the absolute value of the minimum mutual information, and a target entity set with a top ranking and a number equal to a second preset number is selected.
[0112] Further, the information entropy gain ratio between every two variables is calculated according to the total information entropy and the conditional entropy of the edge, including:
[0113] The information entropy gain ratio is calculated according to the following formula:
[0114]
[0115] Wherein, G(D, G) is the information entropy gain ratio, H(D, V) is the total information entropy, and H(D|G) is the conditional entropy of the edge. The above embodiments can be referred to for explanation and will not be described in detail.
[0116] Further, determining the first preset number includes:
[0117] The entities in the screening results are classified according to the mutual information size, and the first classification center of each first classification is determined; the above-mentioned embodiment can be referred to for description and will not be repeated here.
[0118] According to the difference in mutual information between each non-first classification center entity and each first classification center, each non-first classification center entity is classified to obtain a first classification cluster corresponding to each first classification; the above embodiment can be referred to for description and will not be repeated here.
[0119] Calculate the new first classification center corresponding to each first classification cluster. If the new first classification center is different from the corresponding original first classification center, update the first classification center, and periodically perform the difference between the mutual information of each non-first classification center entity and each first classification center and subsequent steps until the preset convergence condition is met. The number of entities in the first classification cluster with the largest mutual information at this time is taken as the first preset number. Please refer to the above embodiment for description, which will not be repeated here.
[0120] Further, determining the second preset number includes:
[0121] The entities in the candidate entity set are classified according to the absolute value of the mutual information, and the second classification center of each second classification is determined; the description can be made with reference to the above embodiment and will not be repeated here.
[0122] According to the difference in mutual information between each non-second classification center entity and each second classification center, each non-second classification center entity is classified to obtain a second classification cluster corresponding to each second classification; please refer to the above embodiment for description and will not be repeated here.
[0123] Calculate the new second classification center corresponding to each second classification cluster. If the new second classification center is different from the corresponding original second classification center, update the second classification center, and periodically perform the difference between the mutual information of each non-second classification center entity and each second classification center and subsequent steps until the preset convergence condition is met. The number of entities in the second classification cluster with the largest mutual information at this time is taken as the second preset number. Please refer to the above embodiment for description, which will not be repeated here.
[0124] Furthermore, after the step of generating a knowledge graph, the knowledge graph generation method further includes:
[0125] The mutual information between every two nodes in the knowledge graph is calculated, and a knowledge graph label is generated according to the mutual information calculation result to obtain an optimized knowledge graph. The above-mentioned embodiment can be referred to for explanation and will not be described in detail.
[0126] Figure 4 is a schematic diagram of the structure of a knowledge graph generation device provided by an embodiment of the present invention. Figure 4 As shown, the knowledge graph generation device provided by the embodiment of the present invention includes an acquisition unit 401, a calculation unit 402 and a generation unit 403, wherein:
[0127] The acquisition unit 401 is used to filter entities according to the association relationship between entities in the text segment, select entities according to the filtering results and use the mutual information of the entities to obtain a target entity set; the calculation unit 402 is used to calculate the total information entropy of the target entity set in the preset variable value range, and calculate the conditional entropy of the edge between every two variables in the preset variable value range; the generation unit 403 is used to calculate the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and use the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph.
[0128] Specifically, the acquisition unit 401 in the device is used to screen entities according to the association relationship between entities in the text segment, select entities according to the screening results and use the mutual information of the entities to obtain a target entity set; the calculation unit 402 is used to calculate the total information entropy of the target entity set in the preset variable value range, and calculate the conditional entropy of the edge between every two variables in the preset variable value range; the generation unit 403 is used to calculate the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and use the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph.
[0129] The knowledge graph generation device provided by the embodiment of the present invention screens entities according to the association relationship between entities in text segments, selects entities according to the screening results and uses the mutual information of the entities to obtain a target entity set; calculates the total information entropy of the target entity set in a preset variable value range, and calculates the conditional entropy of the edge between every two variables in the preset variable value range; calculates the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and uses the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph, which overcomes many shortcomings in the existing knowledge graph training method and can accurately and efficiently generate a knowledge graph.
[0130] The embodiment of the knowledge graph generation device provided in the embodiment of the present invention can be specifically used to execute the processing flow of the above-mentioned method embodiments. Its functions will not be repeated here, and reference can be made to the detailed description of the above-mentioned method embodiments.
[0131] Figure 5 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as Figure 5 As shown, the electronic device includes: a processor (processor) 501, a memory (memory) 502 and a bus 503;
[0132] The processor 501 and the memory 502 communicate with each other via a bus 503;
[0133] The processor 501 is used to call the program instructions in the memory 502 to execute the methods provided by the above method embodiments, for example, including:
[0134] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0135] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0136] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0137] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can perform the methods provided by the above method embodiments, for example, including:
[0138] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0139] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0140] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0141] This embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program enables the computer to execute the methods provided by the above method embodiments, for example, including:
[0142] Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set;
[0143] Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range;
[0144] The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
[0145] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0146] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0147] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0149] In the description of this specification, the description with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0150] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A knowledge graph generation method, characterized in that: include: Entities are screened according to the associations between entities in the text segments, and entities are selected based on the screening results and using the mutual information of the entities to obtain a target entity set; Calculate the total information entropy of the target entity set within the preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range; The information entropy gain ratio between every two variables is calculated based on the total information entropy and the conditional entropy of the edge, and the edge operation type that maximizes the information entropy gain ratio is used as the relationship between the corresponding two entities to generate a knowledge graph.
2. The knowledge graph generation method according to claim 1, characterized in that: The screening of entities according to the association relationship between entities in the text segment includes: Obtain an entity set consisting of all entities in the text segment, and calculate the intersection-and-union ratio corresponding to every two entities in the entity set; Entities whose intersection-over-union ratio is greater than the preset intersection-over-union ratio threshold are taken as screening results.
3. The knowledge graph generation method according to claim 1, characterized in that: The entity is selected according to the screening result and using the mutual information of the entity to obtain a target entity set, including: Sorting the entities in the screening results in descending order according to the maximum mutual information, and selecting a set of candidate entities that are ranked first and whose number is equal to a first preset number; The entities of the candidate entity set are sorted in descending order according to the absolute value of the minimum mutual information, and a target entity set with a top ranking and a number equal to a second preset number is selected.
4. The knowledge graph generation method according to claim 1, characterized in that: The calculating the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge includes: The information entropy gain ratio is calculated according to the following formula: Among them, G(D,G) is the information entropy gain ratio, H(D,V) is the total information entropy, and H(D|G) is the conditional entropy of the edge.
5. The knowledge graph generation method according to claim 3, characterized in that: Determining the first preset number includes: Classifying the entities in the screening results according to the mutual information size, and determining the first classification center of each first classification; Classify each non-first classification center entity according to the difference between the mutual information of each non-first classification center entity and each first classification center, and obtain a first classification cluster corresponding to each first classification; Calculate the new first classification center corresponding to each first classification cluster respectively. If the new first classification center is different from the corresponding original first classification center, update the first classification center, and periodically execute the difference between the mutual information of each non-first classification center entity and each first classification center and subsequent steps until the preset convergence condition is met. The number of entities in the first classification cluster with the largest mutual information at this time is taken as the first preset number.
6. The knowledge graph generation method according to claim 3, characterized in that: Determining the second preset number includes: Classify the entities in the candidate entity set according to the absolute value of the mutual information, and determine the second classification center of each second classification; Classify each non-second classification center entity according to the difference between the mutual information of each non-second classification center entity and each second classification center, and obtain a second classification cluster corresponding to each second classification; Calculate the new second classification center corresponding to each second classification cluster respectively. If the new second classification center is different from the corresponding original second classification center, update the second classification center, and periodically execute the difference between the mutual information of each non-second classification center entity and each second classification center and subsequent steps until the preset convergence condition is met. The number of entities in the second classification cluster with the largest mutual information at this time is taken as the second preset number.
7. The knowledge graph generation method according to any one of claims 1 to 6, characterized in that: After the step of generating a knowledge graph, the knowledge graph generation method further includes: The mutual information between every two nodes in the knowledge graph is calculated, and a knowledge graph label is generated according to the mutual information calculation result to obtain an optimized knowledge graph.
8. A knowledge graph generation device, characterized in that: include: An acquisition unit is used to filter entities according to the association relationship between entities in the text segment, select entities according to the filtering result and using the mutual information of the entities to obtain a target entity set; A calculation unit, used to calculate the total information entropy of the target entity set within a preset variable value range, and calculate the conditional entropy of the edge between every two variables within the preset variable value range; A generating unit is used to calculate the information entropy gain ratio between every two variables according to the total information entropy and the conditional entropy of the edge, and take the edge operation type that maximizes the information entropy gain ratio as the relationship between the corresponding two entities to generate a knowledge graph.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.