Spectrum inspection method, device, computer, readable storage medium and program product
By clustering and generating abstract maps of entity objects in the knowledge graph, the problems of low efficiency and high labor cost of knowledge graph consistency checking in the existing technology are solved, and efficient and accurate knowledge graph inspection is achieved.
Patent Information
- Application Number
- CN202210718936.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2042-06-23
AI Technical Summary
In the prior art, the consistency checking of the knowledge graph is inefficient and labor costs are high, so it is impossible to effectively quantify the quality of the knowledge graph.
By obtaining the target entity vector of entity objects in the knowledge graph, clustering is performed to obtain the entity cluster, generate an abstract map, and conduct consistency checks on it to determine the inspection results of the knowledge graph.
It improves the efficiency of knowledge graph inspection, reduces labor costs, and reduces the scale of knowledge graphs that need to be inspected while ensuring the accuracy of the inspection.
Smart Images

Figure CN115114449B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a spectrum inspection method, device, computer, readable storage medium and program product. Background Art
[0002] The Knowledge Graph is a semantic network that reveals the relationships between entities and is also a graph-based data structure. Among them, the Knowledge Graph can help downstream artificial intelligence (AI) and other algorithms achieve better performance, for example, medical knowledge question and answer in the medical field, but in the process of automatically constructing and using the Knowledge Graph, how to quantitatively evaluate the quality of the Knowledge Graph is a difficult problem. In other words, it has become an important task to check the consistency of the Knowledge Graph. Among them, the Knowledge Graph Consistency Checking refers to the mining and discovery of contradictory knowledge that may exist in the Knowledge Graph. This consistency check usually does not include dependence on external knowledge or information sources. At present, the consistency check of the Knowledge Graph is generally carried out through manual annotation, which leads to low efficiency of graph checking and high labor costs. Summary of the invention
[0003] The embodiments of the present application provide a spectrum inspection method, device, computer, readable storage medium and program product, which can improve the efficiency of spectrum inspection.
[0004] On the one hand, an embodiment of the present application provides a method for checking a spectrum, the method comprising:
[0005] Obtain target entity vectors of n entity objects included in the target knowledge graph; n is a positive integer; the target entity vectors of n entity objects are obtained by training the original triples included in the target knowledge graph;
[0006] Based on the target entity vectors of n entity objects, cluster the n entity objects to obtain p entity clusters, and obtain cluster entity objects from the p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster;
[0007] Obtain the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generate an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters;
[0008] Perform consistency check on the abstract graph, and determine the target check result of the target knowledge graph based on the check result of the abstract image.
[0009] In one aspect, an embodiment of the present application provides a spectrum inspection device, the device comprising:
[0010] A vector acquisition module is used to acquire target entity vectors of n entity objects included in the target knowledge graph; n is a positive integer; the target entity vectors of n entity objects are obtained by training the original triples included in the target knowledge graph;
[0011] An entity clustering module is used to cluster n entity objects based on their target entity vectors to obtain p entity clusters;
[0012] The object selection module is used to obtain cluster entity objects from p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster;
[0013] A graph generation module is used to obtain the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generate an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters;
[0014] The graph detection module is used to perform consistency check on the abstract graph and determine the target inspection result of the target knowledge graph based on the inspection result of the abstract image.
[0015] The device further comprises:
[0016] A data acquisition module is used to acquire n entity objects included in the target knowledge graph and entity relationships corresponding to the n entity objects; the entity relationships include cluster entity relationships;
[0017] A tuple construction module is used to construct an original triple according to n entity objects and entity relationships corresponding to the n entity objects;
[0018] The vector adjustment module is used to adjust the initial entity vectors of the n entity objects based on the vector conversion relationship corresponding to the original triplet, so as to obtain the target entity vectors corresponding to the n entity objects respectively.
[0019] The original triplet includes a first entity object, a second entity object, and an entity relationship between the first entity object and the second entity object; the n entity objects include the first entity object and the second entity object;
[0020] The vector adjustment module includes:
[0021] An initial acquisition unit, used to acquire an initial entity vector of the first entity object, an initial entity vector of the second entity object, and an initial relationship vector of the entity relationship between the first entity object and the second entity object;
[0022] A vector mapping unit, used to map an initial entity vector of a first entity object to a relational space where an initial relational vector is located, to obtain a first mapping vector of the first entity object, and to map an initial entity vector of a second entity object to the relational space, to obtain a second mapping vector of the second entity object;
[0023] A loss generating unit, configured to generate a first loss function according to the first mapping vector, the second mapping vector, the initial relationship vector, and the vector conversion relationship corresponding to the original triple;
[0024] The vector adjustment unit is used to adjust the initial entity vector of the first entity object and the initial entity vector of the second entity object based on the first loss function to obtain the target entity vector of the first entity object and the target entity vector of the second entity object.
[0025] Among them, the number of original triplets is m, and m is a positive integer;
[0026] The vector adjustment module includes:
[0027] A type division unit is used to obtain k types of relationship included in the target knowledge graph, and divide the m original triples into k triple clusters based on the k types of relationship; k is a positive integer; each triple cluster includes at least one original triple;
[0028] The vector adjustment unit is also used to adjust the initial entity vectors of n entity objects based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type, so as to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained; i is a positive integer less than or equal to k.
[0029] The vector adjustment module includes:
[0030] A negative sample acquisition unit, used to construct a negative sample entity object corresponding to the entity relationship in the original triple;
[0031] A positive distance acquisition unit, used for acquiring the positive sample distance corresponding to the original triplet based on the vector conversion relationship corresponding to the original triplet;
[0032] A negative distance acquisition unit, used to acquire a negative sample distance between a negative sample entity object and an entity relationship in the original triplet based on a vector conversion relationship corresponding to the original triplet;
[0033] The loss adjustment unit is used to generate a second loss function according to the positive sample distance and the negative sample distance, and adjust the initial entity vectors of the n entity objects according to the second loss function to obtain the target entity vectors corresponding to the n entity objects respectively.
[0034] The entity clustering module includes:
[0035] A center processing unit, used to obtain p initial cluster centers, and based on the target entity vectors of the n entity objects, obtain the initial cluster distances of the n entity objects to the p initial cluster centers respectively;
[0036] An initial clustering unit, used to divide the n entity objects into initial sets corresponding to the p initial clustering centers based on the initial clustering distances from the n entity objects to the p initial clustering centers respectively;
[0037] An update clustering unit, used to obtain update cluster centers corresponding to the p initial sets respectively, and divide the n entity objects into update sets corresponding to the p update cluster centers based on update cluster distances from the n entity objects to the update cluster centers corresponding to the p initial sets respectively;
[0038] A clustering iteration unit, for determining the p updated sets as p initial sets if the p updated sets do not satisfy the node clustering condition, and returning to execute the process of obtaining the updated cluster centers corresponding to the p initial sets respectively;
[0039] The cluster determination unit is used to determine the p update sets as p entity clusters if the p update sets meet the node clustering condition; each entity cluster includes at least one entity object.
[0040] The entity clustering module includes:
[0041] The to-be-processed acquisition unit is used to acquire the to-be-processed entity object from the n entity objects; the to-be-processed entity object refers to the entity object that has not been subjected to node clustering processing;
[0042] A quantity acquisition unit is used to acquire the number of adjacencies of entity objects located in the neighborhood of the entity object to be processed; the entity objects located in the neighborhood of the entity object to be processed refer to entity objects whose vector distance with the entity object to be processed is less than or equal to the neighborhood radius; the vector distance refers to the distance between the target entity vector of the corresponding entity object and the target entity vector of the entity object to be processed;
[0043] A node expansion unit is used for, if the number of adjacent nodes is greater than or equal to the minimum number of set nodes, performing node expansion based on the entity object to be processed and the entity objects located in the neighborhood of the entity object to be processed, obtaining the density-reachable entity corresponding to the entity object to be processed, forming an entity cluster with the entity object to be processed and the density-reachable entity, returning to execute the process of obtaining the entity object to be processed from the n entity objects, until the entity object to be processed does not exist in the n entity objects, and p entity clusters are obtained;
[0044] The node processing unit is used to return to the process of obtaining the entity object to be processed from the n entity objects if the number of adjacent nodes is less than the minimum number of set nodes.
[0045] The target entity vectors of n entity objects include target entity vectors of n entity objects under k types of relationships; k is a positive integer;
[0046] The entity clustering module includes:
[0047] A type acquisition unit, used to acquire k types of relationship types included in the target knowledge graph;
[0048] The type clustering unit is used to cluster the n entity objects based on their target entity vectors under the i-th relationship type to obtain the entity cluster corresponding to the i-th relationship type, until entity clusters corresponding to k relationship types are obtained; the entity clusters corresponding to the k relationship types constitute p entity clusters; i is a positive integer less than or equal to k.
[0049] The graph generation module includes:
[0050] A relationship determination unit, used to obtain, from the target knowledge graph, the cluster entity relationship between the cluster entity objects corresponding to the entity cluster under the i-th relationship type;
[0051] A graph generation unit, used to form an abstract graph corresponding to the i-th relationship type by combining the cluster entity objects and cluster entity relationships corresponding to the entity cluster under the i-th relationship type;
[0052] The graph generation unit is also used to obtain abstract graphs corresponding to k types of relationship types when i is k.
[0053] The graph detection module includes:
[0054] A graph induction unit is used to obtain entity attributes corresponding to cluster entity objects in the abstract graph, replace the cluster entity objects in the abstract graph with corresponding entity attributes, and obtain an ontology attribute graph;
[0055] The knowledge acquisition unit is used to acquire the knowledge set in the ontology attribute graph and obtain standard knowledge;
[0056] The knowledge detection unit is used to perform consistency check on the knowledge set based on standard knowledge and determine the target check result of the target knowledge graph.
[0057] Among them, the knowledge set includes the knowledge to be tested; the standard knowledge includes the wrong knowledge;
[0058] The knowledge detection unit comprises:
[0059] The anomaly detection subunit is used to compare the knowledge to be detected with the standard knowledge. If there is knowledge to be detected that matches the wrong knowledge in the knowledge set, the target inspection result of the target knowledge graph is determined to be a graph contradiction result;
[0060] The abnormal output subunit is used to map the knowledge to be detected that conforms to the erroneous knowledge into the target knowledge graph, obtain the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge, determine the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge as abnormal triples, and output the graph abnormality message.
[0061] Wherein, the knowledge detection unit comprises:
[0062] The detection subunit is used to compare the knowledge set with the standard knowledge. If there is undetected knowledge in the knowledge set that is not related to the standard knowledge, the undetected knowledge is sent to the management object so that the management object detects the undetected knowledge.
[0063] The knowledge adding subunit is used to obtain the test results sent by the management object and the supplementary knowledge corresponding to the test results, determine the test results as the target inspection results of the target knowledge graph, and add the supplementary knowledge to the standard knowledge.
[0064] On the one hand, an embodiment of the present application provides a computer device, including a processor, a memory, and an input and output interface;
[0065] The processor is connected to the memory and the input / output interface respectively, wherein the input / output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that a computer device including the processor executes the spectrum inspection method in one aspect of an embodiment of the present application.
[0066] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the spectrum inspection method in one aspect of the embodiment of the present application.
[0067] In one aspect, an embodiment of the present application provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional ways in one aspect of the embodiment of the present application. In other words, when the computer instruction is executed by the processor, the method provided in various optional ways in one aspect of the embodiment of the present application is implemented.
[0068] Implementing the embodiments of the present application will have the following beneficial effects:
[0069] In an embodiment of the present application, target entity vectors of n entity objects included in the target knowledge graph can be obtained; n is a positive integer; the target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph; based on the target entity vectors of the n entity objects, the n entity objects are clustered to obtain p entity clusters, and cluster entity objects are obtained from the p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster; the cluster entity relationship between the cluster entity objects corresponding to the p entity clusters is obtained from the target knowledge graph, and an abstract graph is generated based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters respectively; a consistency check is performed on the abstract graph, and based on the inspection result of the abstract image, the target inspection result of the target knowledge graph is determined. Through the above process, clustering processing can be performed based on the target entity vector of the entity object, and the target entity vector can represent the characteristics of the corresponding entity object, and the target entity vector is obtained based on triple training, so that the target entity vector of each entity object can represent the relationship between each entity object in the target knowledge graph, and the entity objects are clustered based on the target entity vector, and similar entity objects can be clustered together, so that when the target knowledge graph is downsampled based on the entity cluster obtained by clustering, that is, when cluster entity objects are extracted from the entity cluster to form an abstract graph, the abstract graph conforms to the distribution of the original graph (that is, the target knowledge graph), that is, the abstract graph can maintain the same consistent distribution as the target knowledge graph, while reducing the scale of the knowledge graph that needs to be checked, thereby improving the inspection efficiency of the target knowledge graph while ensuring the accuracy of the inspection of the target knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0071] Figure 1 This is a network interaction architecture diagram of a graph inspection provided in an embodiment of the present application;
[0072] Figure 2 It is a schematic diagram of a graph inspection scenario provided in an embodiment of the present application;
[0073] Figure 3 It is a flow chart of a method for spectrum inspection provided in an embodiment of the present application;
[0074] Figure 4 It is a schematic diagram of a graph application scenario provided in an embodiment of the present application;
[0075] Figure 5 The embodiment of the present application provides a schematic diagram of a graph reduction scenario;
[0076] Figure 6 It is a schematic diagram of a graph processing flow provided in an embodiment of the present application;
[0077] Figure 7 It is a schematic diagram of a graph inspection scenario provided in an embodiment of the present application;
[0078] Figure 8 is a schematic diagram of a vector conversion scenario provided by an embodiment of the present application;
[0079] Fig. 9 It is a schematic diagram of a spectrum inspection device provided in an embodiment of the present application;
[0080] Fig.10 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0081] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0082] Among them, if it is necessary to collect object (such as user, etc.) data in this application, a prompt interface or pop-up window will be displayed before and during the collection. The prompt interface or pop-up window is used to prompt the user that XXXX data is currently being collected. Only after the user confirms the prompt interface or pop-up window, the relevant steps for data acquisition will be started, otherwise the process will end. Moreover, the acquired user data will be used in reasonable and legal scenarios or purposes. Optionally, in some scenarios where user data needs to be used but has not been authorized by the user, authorization can be requested from the user, and the user data can be used when the authorization is passed.
[0083] In the examples of this application, see Figure 1 , Figure 1It is a network interaction architecture diagram of a graph inspection provided by an embodiment of the present application. In an embodiment of the present application, a computer device 101 can obtain a target knowledge graph that needs to be inspected, wherein the computer device 101 can obtain the target knowledge graph from its own storage space, or obtain the target knowledge graph from any electronic device (such as electronic device 102a, electronic device 102b or electronic device 102c, etc.), etc., without limitation. For example, the computer device 101 can respond to a graph inspection request sent by an electronic device 102b, obtain the target knowledge graph carried by the graph inspection request, inspect the target knowledge graph, and send the target inspection result of the target knowledge graph to the electronic device 102b. Similarly, the computer device 101 can respond to a graph inspection request sent by any electronic device, or respond to a graph inspection request triggered in the computer device 101, etc. In other words, any device with a graph inspection function in the present application can execute the present application embodiment to realize the inspection of the target knowledge graph that exists in itself or is obtained from other devices.
[0084] For details, see Figure 2 , Figure 2 Schematic diagram of a graph inspection scenario provided by an embodiment of the present application. Figure 2 As shown, the computer device can obtain the target knowledge graph 201 and obtain n entity objects included in the target knowledge graph 201, where n is a positive integer, such as Figure 2 , obtain the target entity vectors corresponding to the n entity objects respectively. Based on the target entity vectors of the n entity objects, cluster the n entity objects to obtain p entity clusters, where p is a positive integer, such as Figure 2 Entity cluster 2021, entity cluster 2022, and entity cluster 2023, etc., shown in Figure 2In the example shown, the entity cluster 2021 includes the entity object 2011, the entity cluster 2022 includes the entity object 2012, the entity cluster 2013 includes the entity object 2013, etc. Further, the computer device obtains cluster entity objects from the p entity clusters respectively. For example, it is assumed that the cluster entity object obtained from the entity cluster 2021 is the entity object 2011, the cluster entity object obtained from the entity cluster 2022 is the entity object 2012, the cluster entity object obtained from the entity cluster 2023 is the entity object 2013, etc. By clustering the n entity objects, similar entity objects can be divided into one entity cluster, that is, the entity objects in each entity cluster have certain similarities, and the distribution in the target knowledge graph 201 also has certain similarities. The cluster entity objects can be obtained from each entity cluster to refer to the corresponding entity cluster, thereby reducing the number of entity objects that need to be detected, that is, achieving reasonable downsampling of the target knowledge graph 201. The computer device can generate an abstract graph 203 based on the target knowledge graph 201 and the cluster entity objects corresponding to the p entity clusters. The abstract graph composed of entity objects obtained based on reasonable downsampling can conform to the distribution of the original graph (i.e., the target knowledge graph) and can also maintain the same consistency distribution as the original graph, so that the abstract graph can be checked for consistency to obtain the target inspection result of the target knowledge graph 201, thereby improving the efficiency of the target knowledge graph inspection on the basis of ensuring the accuracy of the target knowledge graph inspection.
[0085] in, Figure 2 This is only an optional knowledge graph inspection embodiment. The specific clustering process and the architecture of the abstract graph are determined based on the target knowledge graph to be inspected. Figure 2 Only for Figure 2 A possible inspection process of the target knowledge graph 201 shown in .
[0086] It is understandable that the computer devices or electronic devices mentioned in the embodiments of the present application include but are not limited to terminal devices or servers. In other words, the computer device or electronic device can be a server or a terminal device, or it can be a system composed of a server and a terminal device. Among them, the terminal devices mentioned above include but are not limited to mobile phones, tablet computers, desktop computers, laptop computers, PDAs, vehicle-mounted devices, augmented reality / virtual reality (AR / VR) devices, helmet displays, smart TVs, wearable devices, smart speakers, digital cameras, cameras and other mobile Internet devices (mobile internet device, MID) with network access capabilities, or terminal devices in scenarios such as trains, ships, and flights. As Figure 1 As shown in , the terminal device may be a laptop computer (as shown in electronic device 102b), a mobile phone (as shown in electronic device 102c) or a vehicle-mounted device (as shown in electronic device 102a), etc. Figure 1 Only some of the devices are listed, and optionally, the electronic device 102a refers to a device located in the vehicle 103. The server mentioned above may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, vehicle-road collaboration, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0087] Optionally, the data involved in the embodiments of the present application may be stored in a computer device, or may be stored based on cloud storage technology or a blockchain network, without limitation. For example, in one case, assuming that the target knowledge graph is checked and triggered based on a blockchain network, the electronic device (which may be Figure 1 Any electronic device or computer device shown in the figure can add the target knowledge graph to the blockchain network, trigger the smart contract for graph checking based on the target knowledge graph, and execute the above-mentioned Figure 2 The process shown implements a graph check on the target knowledge graph. Alternatively, in one case, the electronic device can respond to a graph check request for the target knowledge graph, and based on the graph identifier or block identifier carried by the graph check request, search for the target block from the blockchain network. If the graph check request carries a graph identifier, the target block is the block associated with the graph identifier. If the graph check request carries a block identifier, the target block refers to the block indicated by the block identifier, etc., obtain the target knowledge graph from the target block, and perform a graph check on the target knowledge graph, etc. The specific method for obtaining the target knowledge graph and the method for triggering the graph check are implemented based on the actual scenario and are not limited here.
[0088] For further information, see Figure 3 , Figure 3 This is a flow chart of a method for spectrum inspection provided by an embodiment of the present application. Figure 3 As shown, the spectrum inspection process includes the following steps:
[0089] Step S301, obtain the target entity vectors of n entity objects included in the target knowledge graph.
[0090] In an embodiment of the present application, a computer device can obtain a target knowledge graph, obtain n entity objects included in the target knowledge graph from the target knowledge graph, and obtain target entity vectors corresponding to the n entity objects, where n is a positive integer. The target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph, so that the target entity vectors of each entity object can represent the structural relationship of the corresponding entity object in the target knowledge graph, including the relationship with other entity objects, the relationship between entity relationships in the target knowledge graph, and the architectural position in the target knowledge graph, etc., so that when clustering is performed based on the target entity vector in the future, the knowledge distribution and consistency distribution of the target knowledge graph can be retained to ensure the accuracy of the graph inspection. Specifically, the computer device can obtain the initial entity vectors of n entity objects, obtain the initial relationship vectors of the entity relationships in the target knowledge graph, map the initial entity vectors of the n entity objects to the relationship space where the entity relationships are located, and obtain the mapping vectors corresponding to the n entity objects respectively, and further adjust the initial entity vectors corresponding to the n entity objects respectively based on the original triples included in the target knowledge graph, and the mapping vectors and initial relationship vectors corresponding to the n entity objects respectively, to obtain the target entity vectors corresponding to the n entity objects respectively. For example, taking the target knowledge graph as the medical knowledge graph, see Figure 4 The target knowledge graph 403 shown in Figure 4 It is a schematic diagram of a graph application scenario provided in an embodiment of the present application. The target knowledge graph 403 cites some entity objects and entity relationships. For example, the n entity objects in the target knowledge graph 403 include "throat pain tablets, sesame seeds, quail eggs, fever, vinegar-fried potato shreds, internal medicine examination, mung bean and barley rice, cold, anti-inflammatory tablets, respiratory medicine, blood routine, bronchitis...", and the entity relationships in the target knowledge graph 403 include "suitable food, applicable medicines, recommended recipes, symptoms, diagnostic examinations, complications..." and so on.
[0091] Optionally, the computer device can directly train the n entity objects based on the original triples included in the target knowledge graph to obtain the target entity vectors corresponding to the n entity objects. Figure 4 For example, the target knowledge graph 403 shown in the target knowledge graph 403 includes "<cold, suitable to eat, sesame>, <cold, suitable to eat, quail eggs>, <cold, symptoms, fever>, <cold, recommended recipe, vinegar-fried potato shreds>, <cold, diagnostic examination, internal examination>, <cold, symptoms, fever with chills>, <cold, complications, bronchitis>...", and training can be performed based on the original triples in the target knowledge graph 403 to obtain target entity vectors of n entity objects. Further, the computer device can obtain the target entity vectors corresponding to the n entity objects respectively.
[0092] Alternatively, the computer device can obtain k types of relationships included in the target knowledge graph, where k is a positive integer. Under each relationship type, n entity objects are trained based on the original triples included in the target knowledge graph to obtain the target relationship vectors of the n entity objects under each relationship type. That is, under each relationship type, there are target entity vectors of n entity objects. Further, the computer device can obtain the k types of relationships included in the target knowledge graph, and obtain the target entity vectors of the n entity objects under the k types of relationships. That is, the target entity vectors of each entity object under the k types of relationships, respectively, where k is a positive integer. In other words, it is equivalent to obtaining n*k target entity vectors in the target knowledge graph. For example, assuming k is 3, each entity object can include 3 target entity vectors. If Figure 4 As shown in the target knowledge graph 403, the k types of relationship types include but are not limited to "suitable to eat, applicable drugs, symptoms, recommended recipes, diagnostic examinations, complications, affiliated departments..." The computer device can train n entity objects based on the original triples corresponding to the k types of relationship types, and obtain the target entity vectors of the n entity objects under each relationship type, such as under the "suitable to eat" relationship type, the target entity vectors corresponding to the n entity objects respectively; under the "applicable drugs" relationship type, the target entity vectors corresponding to the n entity objects respectively; under the "symptoms" relationship type, the target entity vectors corresponding to the n entity objects respectively..., that is, n*k target entity vectors are obtained, and each entity object corresponds to k target entity vectors.
[0093] Step S302 , clustering the n entity objects based on their target entity vectors to obtain p entity clusters, and obtaining cluster entity objects from the p entity clusters respectively, the cluster entity objects being used to refer to the corresponding entity clusters.
[0094] In an embodiment of the present application, a computer device can perform clustering processing on n entity objects based on their target entity vectors to obtain p entity clusters, so that the entity objects included in each entity cluster are similar in the target knowledge graph, such as the architecture in the target knowledge graph and the distribution in the target knowledge graph, so that the entity objects in the entity cluster can be used to refer to the corresponding entity cluster. Furthermore, cluster entity objects can be obtained from the p entity clusters respectively, and the cluster entity objects can be used to refer to the corresponding entity cluster.
[0095] Optionally, the present application does not limit the above-mentioned clustering method for entity objects. For example, in an entity clustering method ①, p initial clustering centers are obtained, and based on the target entity vectors of the n entity objects, the initial clustering distances of the n entity objects to the p initial clustering centers are obtained. Based on the initial clustering distances of the n entity objects to the p initial clustering centers, the n entity objects are divided into initial sets corresponding to the p initial clustering centers. Update clustering centers corresponding to the p initial sets are obtained, and based on the update clustering distances of the n entity objects to the update clustering centers corresponding to the p initial sets, the n entity objects are divided into update sets corresponding to the p update clustering centers. If the p update sets do not meet the node clustering condition, the p update sets are determined as the p initial sets, and the process of obtaining the update clustering centers corresponding to the p initial sets is returned; if the p update sets meet the node clustering condition, the p update sets are determined as p entity clusters; each entity cluster includes at least one entity object.
[0096] Optionally, the node clustering condition may be that when the cluster centers of p update sets change, the degree of change of the p update sets is less than or equal to the cluster convergence threshold, that is, if the cluster centers of the p update sets are updated, and the degree of difference between the updated p sets corresponding to the updated cluster centers and the p update sets is less than or equal to the cluster convergence threshold, then the p update sets are determined to meet the node clustering condition, otherwise, the p update sets are determined to not meet the node clustering condition; or, if the degree of difference between the p update sets and the p initial sets is less than or equal to the cluster convergence threshold, then the p update sets are determined to meet the node clustering condition, and if the degree of difference between the p update sets and the p initial sets is greater than the cluster convergence threshold, then the p update sets are determined to not meet the node clustering condition, etc., and no limitation is made here.
[0097] Alternatively, the node clustering condition may be that the sum of the distances from the entity objects included in the update set to the set vector of the update set is less than or equal to the distance convergence threshold, and the set vector may be the mean, median or mid-range number of the target entity vectors of the entity objects included in the corresponding update set, which is not limited here. Wherein, the median refers to the arithmetic mean of the upper and lower limits of the group distance. When the number of entity objects included in the update set is an odd number, the target entity vector at the middle position of the target entity vectors of the entity objects included in the update set is the set vector of the update set; when the number of entity objects included in the update set is an even number, the average of the two target entity vectors at the middle position of the target entity vectors of the entity objects included in the update set is the set vector of the update set, etc. Wherein, the mid-range number refers to the average of the maximum value and the minimum value. Specifically, the maximum entity vector and the minimum entity vector can be obtained from the target entity vectors of the entity objects included in the update set, and the average value of the maximum entity vector and the minimum entity vector is determined as the set vector of the update set. Specifically, the computer device may obtain the set vectors corresponding to the p update sets, and obtain the single set total distance between the entity objects included in each update set and the set vector of the update set (i.e., the sum of the distances between the entity objects included in each update set and the set vector of the update set). If the single set total distances corresponding to the p update sets are all less than or equal to the distance convergence threshold, it is determined that the p update sets meet the node clustering condition; if there is an update set in the p update sets whose single set total distance is greater than the distance convergence threshold, it is determined that the p update sets do not meet the node clustering condition. Alternatively, if the sum of the single set total distances corresponding to the p update sets is less than or equal to the distance convergence threshold, it is determined that the p update sets meet the node clustering condition; if the sum of the single set total distances corresponding to the p update sets is greater than the distance convergence threshold, it is determined that the p update sets do not meet the node clustering condition.
[0098] Alternatively, the node clustering condition may be that the update set satisfies the set convergence function, that is, if p update sets satisfy the set convergence function, then it is determined that the p update sets satisfy the node clustering condition. For example, the target entity vectors of the n entity objects are recorded as “x1, x2, x3, …, x n ", the set vector of the jth update set among the p update sets is denoted as μ j , j is a positive integer less than or equal to p. Among them, an optional set convergence function is shown in formula (1):
[0099]
[0100] As shown in formula (1), S is used to represent p update sets, S jis used to represent the jth update set, and x in formula (1) is used to represent the target entity vector of the entity object in the jth update set, “|||| 2 " is used to represent the distance operator, and argmin is used to represent the distance operator. When the minimum value is obtained, the value of x can be considered here to make When the minimum value is obtained, the entity objects respectively included in the p update sets are: wherein the above formula (1) is an optional set convergence function, and does not limit the use of other set convergence functions.
[0101] Optionally, in an entity clustering method ②, an entity object to be processed is obtained from n entity objects; the entity object to be processed refers to an entity object that has not been subjected to node clustering processing. The number of neighbors of the entity object located in the neighborhood of the entity object to be processed is obtained; the entity object located in the neighborhood of the entity object to be processed refers to an entity object whose vector distance with the entity object to be processed is less than or equal to the neighborhood radius; the vector distance refers to the distance between the target entity vector of the corresponding entity object and the target entity vector of the entity object to be processed. If the number of neighbors is greater than or equal to the minimum number of nodes in the set, node expansion is performed based on the entity object to be processed and the entity objects located in the neighborhood of the entity object to be processed to obtain the density reachable entity corresponding to the entity object to be processed, and the entity object to be processed and the density reachable entity are formed into an entity cluster, and the process of obtaining the entity object to be processed from the n entity objects is returned until the entity object to be processed does not exist in the n entity objects, and p entity clusters are obtained; if the number of neighbors is less than the minimum number of nodes in the set, the process of obtaining the entity object to be processed from the n entity objects is returned.
[0102] Among them, the above are only several possible entity clustering methods listed as examples, and other entity clustering methods can also be used to implement clustering processing of n entity objects. For example, a computer device can initialize p Gaussian distribution parameters (such as mean and variance) for initializing p initial clusters, wherein the p Gaussian distribution parameters can be randomly initialized, or the p Gaussian distribution parameters can be determined based on the target entity vectors of the n entity objects; based on the Gaussian distribution parameters of the p initial clusters, the Gaussian distributions of the p initial clusters are determined, and based on the target entity vectors of the n entity objects, the association probability of each entity object belonging to the p initial clusters is determined, wherein the closer an entity object is to the center of the Gaussian distribution of an initial cluster, the more likely the entity object belongs to the initial cluster. For example, based on the target entity vector of the d-th entity object, the distance between the d-th entity object and the center of the Gaussian distribution of the p initial clusters can be calculated, and based on the Gaussian distribution of the d-th entity object and the Gaussian distribution of the p initial clusters, the probability of each entity object belonging to the p initial clusters can be determined. The distance between the centers is determined, and the association probability of the d-th entity object with the p initial clusters is determined, where d is a positive integer less than or equal to n; based on the association probability of each entity object with the p initial clusters, p update clusters are obtained; based on the association probability of each entity object with the p initial clusters, the update Gaussian parameters corresponding to the p update clusters are calculated, and the update Gaussian distributions corresponding to the p update clusters are determined; if the update association probability between each entity object and the p update clusters meets the Gaussian clustering condition, the p update clusters are determined as p entity clusters; if the update association probability between each entity object and the p update clusters does not meet the Gaussian clustering condition, the p update clusters are determined as p initial clusters, and the process of obtaining p update clusters based on the association probability of each entity object with the p initial clusters is returned.
[0103] Optionally, the computer device can perform clustering processing on n entity objects under k types of relationship, respectively, to obtain entity clusters under each type of relationship. Specifically, the target entity vectors of the n entity objects include the target entity vectors of the n entity objects under k types of relationship; k is a positive integer. The computer device can obtain the k types of relationship included in the target knowledge graph. Taking the i-th relationship type as an example, the computer device can perform clustering processing on the n entity objects based on the target entity vectors of the n entity objects under the i-th relationship type, to obtain the entity cluster corresponding to the i-th relationship type, until the entity clusters corresponding to the k types of relationship types are obtained; the entity clusters corresponding to the k types of relationship types constitute p entity clusters; i is a positive integer less than or equal to k. Among them, the clustering process of n entity objects under any relationship type can refer to the above-mentioned process of clustering n entity objects based on the target entity vectors of n entity objects, such as entity clustering method ① or entity clustering method ②, etc., wherein, in this method, the number of entity clusters corresponding to k types of relationship types is denoted as p, and the number of entity clusters corresponding to the i-th relationship type can be denoted as c, where c is a positive integer. When entity clustering method ① is used, c initial clustering centers are obtained until c entity clusters corresponding to the i-th relationship type are obtained; when entity clustering method ② is used, c entity clusters corresponding to the i-th relationship type are obtained, etc. Taking the i-th relationship type as an example, entity clusters corresponding to k types of relationship types can be obtained. Figure 4 The target knowledge graph 403 shown can obtain the entity cluster corresponding to the relationship type "suitable to eat", the entity cluster corresponding to the relationship type "applicable medicines", the entity cluster corresponding to the relationship type "symptoms"...
[0104] Furthermore, cluster entity objects can be obtained from p entity clusters respectively, and the cluster entity objects are used to refer to the corresponding entity clusters, thereby reducing the entity objects that need to be checked in the target knowledge graph to about p, reducing the amount of data that needs to be checked, and at the same time, cluster entity objects are selected by clustering based on the target entity vectors of n entity objects, thereby achieving appropriate and reasonable downsampling of the target knowledge graph, so that the obtained cluster entity objects can represent the target knowledge graph and retain the triple structure in the target knowledge graph as much as possible, thereby improving the efficiency of graph inspection while ensuring the accuracy of graph inspection.
[0105] Specifically, the computer device can obtain the entity object located at the cluster center position in the jth entity cluster, and determine the entity object located at the cluster center position in the jth entity cluster as the cluster entity object of the jth entity cluster. Similarly, the cluster entity objects corresponding to the p entity clusters can be obtained. The cluster center position can be the centroid, moment centroid or gravity centroid of the entity cluster.
[0106] For example, see Figure 5 , Figure 5 Schematic diagram of a graph reduction scenario provided by an embodiment of the present application. Figure 5 As shown, in a graph reduction method ①, the computer device performs clustering processing on n entity objects based on the target entity vectors of the n entity objects included in the target knowledge graph 501 to obtain p entity clusters 502, and further obtains cluster entity objects from the p entity clusters 502. In a graph reduction method ②, the computer device can perform clustering processing on n entity objects under k types of relationship types based on the target entity vectors of the n entity objects under each relationship type to obtain entity clusters corresponding to k types of relationship types, such as entity cluster 5041 under relationship type 1, ..., entity cluster 504k under relationship type k, etc., and further obtain cluster entity objects from the entity clusters corresponding to each relationship type.
[0107] Step S303, obtaining the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters respectively from the target knowledge graph, and generating an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters respectively.
[0108] In an embodiment of the present application, a computer device may obtain cluster entity relationships between cluster entity objects corresponding to p entity clusters from a target knowledge graph. Specifically, the computer device may determine cluster entity objects corresponding to p entity clusters from a target knowledge graph, and obtain cluster entity relationships associated with cluster entity objects corresponding to p entity clusters from the target knowledge graph. Further, an abstract graph is generated based on the cluster entity objects and cluster entity relationships corresponding to the p entity objects.
[0109] Optional, such as Figure 5 As shown, in a graph reduction method ①, a computer device can use cluster entity objects corresponding to p entity clusters as nodes, and cluster entity relationships between cluster entity objects corresponding to p entity clusters as edges to generate an abstract graph 503.
[0110] In a graph reduction method ②, the computer device can use the cluster entity objects corresponding to the p entity clusters as nodes, and the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters as edges to generate an abstract graph. Alternatively, from the target knowledge graph, obtain the cluster entity relationships between the cluster entity objects corresponding to the entity clusters under the i-th relationship type; use the cluster entity objects and cluster entity relationships corresponding to the entity clusters under the i-th relationship type to form an abstract graph corresponding to the i-th relationship type; when i is k, obtain the abstract graphs corresponding to the k relationship types. Figure 5As shown, from the target knowledge graph 501, the cluster entity relationships between the cluster entity objects corresponding to the entity cluster 5041 under the relationship type 1 are obtained, and the cluster entity objects and cluster entity relationships corresponding to the entity cluster 5041 under the relationship type 1 are combined into an abstract graph 5051 corresponding to the relationship type 1; ...; from the target knowledge graph 501, the cluster entity relationships between the cluster entity objects corresponding to the entity cluster 504k under the relationship type k are obtained, and the cluster entity objects and cluster entity relationships corresponding to the entity cluster 504k under the relationship type k are combined into an abstract graph 505k corresponding to the relationship type k.
[0111] Step S304, perform a consistency check on the abstract graph, and determine the target check result of the target knowledge graph based on the check result of the abstract image.
[0112] In an embodiment of the present application, a computer device can obtain entity attributes corresponding to cluster entity objects in an abstract graph, replace the cluster entity objects in the abstract graph with corresponding entity attributes, and obtain an ontology attribute graph. A consistency check is performed on the ontology attribute graph, and a target check result of the target knowledge graph is determined based on the check result of the ontology attribute graph. Among them, the entity attribute can be considered as the knowledge graph ontology (Ontology) of the corresponding cluster entity object, which refers to the category and attribute information of the entity object with a hierarchical structure, which can be used to represent the superordinate concept of the entity object. For example, in a medical knowledge graph, entity attributes may include but are not limited to "disease", "drug" and "symptoms"; in a film and television knowledge graph, entity attributes may include but are not limited to "actors", "film and television types (such as movies, TV series or short plays, etc.)" and "film and television information (such as film and television posters or plot introductions, etc.)"; in a book knowledge graph, entity attributes may include but are not limited to "author", "book type" and "publisher". The above are just some of the optional knowledge graphs and some entity attributes that may be mapped in the knowledge graph. In specific implementations, the knowledge graph or entity attributes can be determined based on actual conditions and are not limited here.
[0113] Optionally, the computer device can obtain the knowledge set in the abstract graph, obtain the standard knowledge, perform a consistency check on the knowledge set based on the standard knowledge, and determine the target check result of the target knowledge graph. Optionally, the computer device can obtain the knowledge set in the ontology attribute graph, obtain the standard knowledge, perform a consistency check on the knowledge set based on the standard knowledge, and determine the target check result of the target knowledge graph. Among them, standard knowledge can be considered to refer to a kind of program logic, an assertion, such as a logical judgment formula with a result of true or false, which is equivalent to a judgment standard. Among them, the knowledge set includes knowledge to be tested; standard knowledge includes erroneous knowledge. Specifically, when the consistency check of the knowledge set is performed based on the standard knowledge to determine the target check result of the target knowledge graph, the computer device can compare the knowledge to be detected with the standard knowledge. If there is knowledge to be detected that conforms to the wrong knowledge in the knowledge set, the target check result of the target knowledge graph is determined to be a graph contradiction result; the knowledge to be detected that conforms to the wrong knowledge is mapped to the target knowledge graph, and the original triple corresponding to the knowledge to be detected that conforms to the wrong knowledge is obtained, and the original triple corresponding to the knowledge to be detected that conforms to the wrong knowledge is determined as an abnormal triple, and the graph abnormality message is output. If there is no knowledge to be detected that conforms to the wrong knowledge in the knowledge set, the target check result of the target knowledge graph is determined to be a normal result of the graph. Optionally, the knowledge set is compared with the standard knowledge. If there is undetected knowledge that is not related to the standard knowledge in the knowledge set, the undetected knowledge is sent to the management object so that the management object detects the undetected knowledge; the detection result sent by the management object and the supplementary knowledge corresponding to the detection result are obtained, the detection result is determined as the target check result of the target knowledge graph, and the supplementary knowledge is added to the standard knowledge.
[0114] like Figure 5 As shown, in the graph reduction method ①, the abstract graph 503 can be checked for consistency to obtain the target check result of the target knowledge graph. In the graph reduction method ②, the abstract graphs corresponding to the k types of relationship types can be checked for consistency, i.e., the abstract graphs 5051 to 505k, to obtain the target check result of the target knowledge graph.
[0115] Optionally, the computer device may respond to a graph check request for a target knowledge graph and perform Figure 3 The steps shown are to obtain the target knowledge graph and perform a graph check on the target knowledge graph. Optionally, the graph check request may be triggered directly for the target knowledge graph, or may be triggered based on an upload request for the target knowledge graph, which is not limited here. For example, a computer device may respond to a graph upload request in a target application, obtain the target knowledge graph uploaded by the graph upload request, and perform a graph check on the target knowledge graph (i.e., Figure 3The target inspection result of the target knowledge graph is obtained by performing the steps shown in the figure; if the target inspection result of the target knowledge graph is a graph-contradictory result, a graph-abnormal message is output; if the target inspection result of the target knowledge graph is a graph-normal result, the target knowledge graph is uploaded to the target application, and optionally, a graph-upload success message can be output. The target application can refer to any application (Application, App), website, webpage or applet applied to the knowledge graph, and is not limited here.
[0116] Furthermore, it is possible to respond to an information consultation request in a target application, obtain the information to be processed carried by the information consultation request, obtain entity information associated with the information to be processed, obtain an associated knowledge graph associated with the information to be processed from the target application, for example, assuming that the associated knowledge graph is the above-mentioned target knowledge graph, obtain associated triples from the associated knowledge graph based on the entity information, generate a consultation response message based on the associated triples, and output the consultation response message.
[0117] Optionally, assuming that the entity information includes consulting entity objects and consulting entity relationships, then an associated triplet can be obtained from the associated knowledge graph based on the consulting entity objects and consulting entity relationships, and the associated triplet includes the consulting entity objects and consulting entity relationships. Figure 4As shown, assuming that the information to be processed 401 is "What can I eat for a cold", entity information can be obtained based on the information to be processed 401, and the entity information includes the consulting entity object "cold" (i.e., the "cold" included in the information to be processed 401), and the consulting entity relationship "suitable food, recommended recipes and applicable medicines, etc." (i.e., obtained based on the "eat" included in the information to be processed 401), and the associated triples including the consulting entity object "cold" and the consulting entity relationship "suitable food, recommended recipes and applicable medicines, etc." are obtained from the associated knowledge graph, such as "<cold, suitable food, quail eggs>, <cold, recommended recipes, mung bean and barley rice>...", etc., and a consulting response message 402 is generated based on the associated triples, and the consulting response message 402 is output, such as "suitable food for a cold includes: sesame, quail eggs...; recommended recipes include: vinegar-fried potato shreds, mung bean and barley rice, barley and lotus seed porridge...; commonly used medicines for colds include: anti-inflammatory tablets, Ganmaoling granules...". Assuming that the entity information includes consulting entity objects, consulting entity relationships and consulting entity attributes, associated triples can be obtained from the associated knowledge graph based on the consulting entity objects, consulting entity relationships and consulting entity attributes. The associated triples include consulting entity objects and consulting entity relationships, and the associated triples include entity objects belonging to the consulting entity attributes. For example, assuming that the information to be processed is "What medicine should I take for a cold", entity information can be obtained based on the information to be processed, and the entity information includes the consulting entity object "cold" (i.e., the "cold" included in the information to be processed), the consulting entity relationship "applicable medicines, etc." (i.e., obtained based on the "what medicine to take" included in the information to be processed), and the consulting entity attribute "medicine". An associated triplet including the consulting entity object "cold" and the consulting entity relationship "applicable medicines, etc.", and including entity objects belonging to the consulting entity attribute "medicine" is obtained from the associated knowledge graph, such as "<cold, applicable medicines, anti-inflammatory tablets>, <cold, applicable medicines, sore throat tablets>...", etc., a consulting response message is generated based on the associated triplet, and the consulting response message is output, such as "Common medicines for colds include: anti-inflammatory tablets, cold spirit granules..."
[0118] Optionally, assuming that the entity information includes a triple consisting of a consulting entity object and a consulting entity relationship, an associated triple can be obtained from the associated knowledge graph based on the triple consisting of the consulting entity object and the consulting entity relationship, and the associated triple includes the consulting entity object and the consulting entity relationship. The associated triple is compared with the triple consisting of the consulting entity object and the consulting entity relationship to obtain a consulting response message, and the consulting response message is output. Optionally, if the associated triple is not found, the consulting response message is a negative message; if the associated triple is found, and the triple consisting of the consulting entity object and the consulting entity relationship meets the associated triple, the consulting response message is a confirmation message. For example, assuming that the information to be processed is "Should I take anti-inflammatory tablets for a cold?", entity information can be obtained based on the information to be processed, and the entity information includes the consulting entity object "cold" (i.e. the "cold" included in the information to be processed) and the consulting entity object "anti-inflammatory tablets" (i.e. the "anti-inflammatory tablets" included in the information to be processed), and the consulting entity relationship "applicable medicines" (i.e. obtained based on the "you can take anti-inflammatory tablets" included in the information to be processed). An associated triplet including the consulting entity object "cold", the consulting entity object "anti-inflammatory tablets" and the consulting entity relationship "applicable medicines" is obtained from the associated knowledge graph, such as "<cold, applicable medicines, anti-inflammatory tablets>", etc., and a consulting response message is generated based on the associated triplet, and the consulting response message is output, such as "you can take it".
[0119] In an embodiment of the present application, target entity vectors of n entity objects included in the target knowledge graph can be obtained; n is a positive integer; the target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph; based on the target entity vectors of the n entity objects, the n entity objects are clustered to obtain p entity clusters, and cluster entity objects are obtained from the p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster; the cluster entity relationship between the cluster entity objects corresponding to the p entity clusters is obtained from the target knowledge graph, and an abstract graph is generated based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters respectively; a consistency check is performed on the abstract graph, and based on the inspection result of the abstract image, the target inspection result of the target knowledge graph is determined. Through the above process, clustering processing can be performed based on the target entity vector of the entity object, and the target entity vector can represent the characteristics of the corresponding entity object, and the target entity vector is obtained based on triple training, so that the target entity vector of each entity object can represent the relationship between each entity object in the target knowledge graph, and the entity objects are clustered based on the target entity vector, and similar entity objects can be clustered together, so that when the target knowledge graph is downsampled based on the entity cluster obtained by clustering, that is, when cluster entity objects are extracted from the entity cluster to form an abstract graph, the abstract graph conforms to the distribution of the original graph (that is, the target knowledge graph), that is, the abstract graph can maintain the same consistent distribution as the target knowledge graph, while reducing the scale of the knowledge graph that needs to be checked, thereby improving the inspection efficiency of the target knowledge graph while ensuring the accuracy of the inspection of the target knowledge graph.
[0120] Further, see Figure 6 , Figure 6 This is a schematic diagram of a graph processing flow provided in an embodiment of the present application. Figure 6 As shown, the process may include the following steps:
[0121] Step S601, training the target knowledge graph to obtain target entity vectors of n entity objects included in the target knowledge graph.
[0122] In the embodiment of the present application, the target knowledge graph can be any type of knowledge graph, such as a medical knowledge graph, a film and television knowledge graph, a book knowledge graph, or a science and technology knowledge graph, etc. The computer device can obtain the n entity objects included in the target knowledge graph and the entity relationships corresponding to the n entity objects; the entity relationships include the cluster entity relationships mentioned above; construct original triples according to the n entity objects and the entity relationships corresponding to the n entity objects; based on the vector conversion relationship corresponding to the original triples, adjust the initial entity vectors of the n entity objects to obtain the target entity vectors corresponding to the n entity objects.
[0123] For example, see Figure 7 , Figure 7 Schematic diagram of a graph inspection scenario provided by an embodiment of the present application. Figure 7 As shown, it is assumed that the target knowledge graph 701 includes n entity objects, such as the entity object "amoxicillin", the entity object "bronchitis" and the entity object "chronic cough", etc., and the target knowledge graph 701 includes entity relationships corresponding to the n entity objects, such as the entity relationship "therapeutic drugs" and the entity relationship "recommended recipes", etc. According to the n entity objects and the entity relationships corresponding to the n entity objects, original triples are constructed, such as the original triple "<bronchitis, therapeutic drugs, amoxicillin>", and the original triple "<amoxicillin, therapeutic drugs, chronic cough>", etc.
[0124] Further, taking an original triple as an example, the original triple includes a first entity object, a second entity object, and an entity relationship between the first entity object and the second entity object, which can be recorded as <first entity object, entity relationship, second entity object>; the n entity objects include the first entity object and the second entity object. Based on the vector conversion relationship corresponding to the original triple, the initial entity vectors of the n entity objects can be adjusted to obtain the target entity vectors corresponding to the n entity objects. The initial entity vector of the first entity object, the initial entity vector of the second entity object, and the initial relationship vector of the entity relationship between the first entity object and the second entity object are obtained. Optionally, the computer device can randomly initialize the initial entity vector of the first entity object, the initial entity vector of the second entity object, and the initial relationship vector of the entity relationship between the first entity object and the second entity object. That is, n entity objects can be randomly initialized to obtain initial entity vectors corresponding to the n entity objects respectively; or, the computer device can add entity identifiers to the n entity objects, perform sequence initialization based on the entity identifiers of the n entity objects, obtain initial entity vectors corresponding to the n entity objects respectively, initialize the entity relationship between the n entity objects, and obtain the initial relationship vector of the entity relationship between the n entity objects, including the initial entity vector of the first entity object, the initial entity vector of the second entity object, and the initial relationship vector of the entity relationship between the first entity object and the second entity object; or, a vector conversion model can be used to perform vector conversion on n entity objects and the entity relationship between n entity objects to obtain initial entity vectors corresponding to the n entity objects respectively, and the initial relationship vector of the entity relationship between the n entity objects. The vector conversion model can be but is not limited to a word vector conversion (word2vec) model and one-hot encoding, etc. Optionally, the vector space where the initial entity vectors of the n entity objects are located can be recorded as the entity space, and the vector space where the initial relationship vectors are located can be recorded as the relationship space. Figure 8 As shown, Figure 8 is a schematic diagram of a vector conversion scenario provided by an embodiment of the present application, taking an original triple as an example, recorded as<h,r,t> In the entity space 801, h can be used to represent the initial entity vector of the first entity object, r is used to represent the initial relationship vector of the entity relationship between the first entity object and the second entity object, and t is used to represent the initial entity vector of the second entity object.
[0125] Furthermore, the computer device may map the initial entity vector of the first entity object to the relational space where the initial relational vector is located to obtain a first mapping vector of the first entity object, and map the initial entity vector of the second entity object to the relational space (relation-specific) to obtain a second mapping vector of the second entity object. Figure 8 As shown, the initial entity vector h of the first entity object is mapped to the relationship space 802 where the initial relationship vector r is located, and the first mapping vector h of the first entity object is obtained. r , the initial entity vector t of the second entity object is mapped to the relational space 802, and a second mapping vector t of the second entity object is obtained. r Optionally, the computer device may obtain a vector mapping parameter and record the vector mapping parameter as M r Based on the vector mapping parameter, the initial entity vector of the first entity object is mapped to the relationship space where the initial relationship vector is located, and the first mapping vector of the first entity object is obtained; based on the vector mapping parameter, the initial entity vector of the second entity object is mapped to the relationship space, and the second mapping vector of the second entity object is obtained. Among them, it can be denoted as h r =hM r , t r =tM r .
[0126] Furthermore, the first loss function can be generated according to the vector conversion relationship corresponding to the first mapping vector, the second mapping vector, the initial relationship vector, and the original triple. Specifically, the vector conversion relationship corresponding to the original triple is “h r +r≈t r ", that is, the first mapping vector, the second mapping vector and the initial relationship vector should satisfy the vector conversion relationship as much as possible. For example, the transfer vector between the first mapping vector and the initial relationship vector can be obtained, and the first loss function is generated based on the vector distance between the transfer vector and the second mapping vector; or the entity mapping distance between the first mapping vector and the second mapping vector can be obtained, and the first loss function is generated based on the difference between the entity mapping distance and the initial relationship vector. Based on the first loss function, the initial entity vector of the first entity object and the initial entity vector of the second entity object are adjusted to obtain the target entity vector of the first entity object and the target entity vector of the second entity object.
[0127] Optionally, a negative sample entity object corresponding to the entity relationship in the original triple can be constructed. Figure 8As shown, construct the negative sample entity object corresponding to the entity relationship in the original triplet, for example, negative sample entity object 8031 or negative sample entity object 8032, etc. Based on the vector conversion relationship corresponding to the original triplet, obtain the positive sample distance corresponding to the original triplet; based on the vector conversion relationship corresponding to the original triplet, obtain the negative sample distance between the negative sample entity object and the entity relationship in the original triplet. Optionally, the negative sample entity object can replace an entity object in the original triplet to obtain a negative sample triplet, and obtain the negative sample distance of the negative sample triplet. For example, the negative sample entity object 8031 can replace the first entity object in the original triplet to obtain a negative sample triplet, or the negative sample entity object 8032 can replace the second entity object in the original triplet to obtain a negative sample triplet, etc. Generate a second loss function based on the positive sample distance and the negative sample distance, adjust the initial entity vectors of the n entity objects according to the second loss function, and obtain the target entity vectors corresponding to the n entity objects respectively. Optionally, a possible second loss function can be shown in formula (2):
[0128]
[0129] As shown in formula (2), the subscript pos is used to represent positive samples, that is, the original triples included in the corresponding target knowledge graph, the subscript neg is used to represent negative samples, that is, the triples that do not exist in the target knowledge graph, and margin is used to represent the sample adjustment parameter, which is used to move the negative sample entity object away from the original triples, so that the trained target entity vector is as consistent as possible with the distribution of the corresponding entity object in the target knowledge graph, thereby improving the accuracy of graph inspection. pos Used to represent the positive sample distance, d neg Used to represent the negative sample distance.
[0130] Through the above process, the target entity vectors of n entity objects, the target relationship vectors of entity relationships in the target knowledge graph, and the trained vector mapping parameters can be trained.
[0131] Optionally, the target entity vectors of n entity objects under k types of relationship can be obtained. Specifically, the number of original triples is m, where m is a positive integer. The k types of relationship included in the target knowledge graph can be obtained, and the m original triples are divided into k triple clusters based on the k types of relationship; k is a positive integer; and each triple cluster includes at least one original triple. Based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type, the initial entity vectors of the n entity objects are adjusted to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k types of relationship types are obtained; i is a positive integer less than or equal to k. Specifically, there are relationship spaces corresponding to k types of relationship types. Taking the i-th relationship type as an example, the initial entity vector of the first entity object, the initial entity vector of the second entity object, and the initial relationship vector of the entity relationship between the first entity object and the second entity object can be obtained. The initial entity vector of the first entity object is mapped to the relationship space corresponding to the i-th relationship type to obtain the first mapping vector i of the first entity object, and the initial entity vector of the second entity object is mapped to the relationship space corresponding to the i-th relationship type to obtain the second mapping vector i of the second entity object. Specifically, the vector mapping parameters corresponding to the i-th relationship type can be obtained, and vector mapping is performed based on the vector mapping parameters corresponding to the i-th relationship type to obtain the first mapping vector i of the first entity object and the second mapping vector i of the second entity object. According to the vector conversion relationship corresponding to the first mapping vector i, the second mapping vector i, the initial relationship vector and the original triple, a first loss function i is generated; based on the first loss function i, the initial entity vector of the first entity object and the initial entity vector of the second entity object are adjusted to obtain the target entity vector of the first entity object and the target entity vector of the second entity object under the i-th relationship type, that is, the target entity vectors corresponding to the n entity objects under the i-th relationship type are obtained. Alternatively, based on the positive sample distance and negative sample distance methods shown above, the target entity vectors corresponding to the n entity objects under the i-th relationship type are obtained. Similarly, the target entity vector of each entity object under k types of relations can be obtained. For example, for an entity object e, the target entity vector of the entity object e under each type of relation can be obtained, which can be denoted as e r1 、e r2 , … and e rk .
[0132] Through the above process, we can train and obtain the target entity vectors of n entity objects under each relationship type, the target relationship vectors of the entity relationships in the target knowledge graph, and the trained vector mapping parameters under each relationship type.
[0133] Step S602, obtaining the target entity vectors of the n entity objects included in the target knowledge graph.
[0134] In the embodiments of this application, please refer to Figure 3 The specific description of step S301 is omitted here.
[0135] Step S603 , clustering the n entity objects based on their target entity vectors to obtain p entity clusters, and obtaining cluster entity objects from the p entity clusters respectively.
[0136] In the embodiments of this application, please refer to Figure 3 The specific description of step S302 is omitted here. The entity objects included in each entity cluster can be considered to be semantically similar, and one entity object in the entity cluster can be used to refer to the entity cluster to reduce the target knowledge graph and reduce the amount of data required for detection.
[0137] Step S604, obtaining the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters respectively from the target knowledge graph, and generating an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters respectively.
[0138] In the embodiments of this application, please refer to Figure 3 The specific description of step S303 is omitted here. In the graph reduction method ②, the target knowledge graph can be downsampled and abstracted from the dimensions of different relationship types, so that the consistent distribution of each relationship type can be retained, and different relationship types are abstracted separately, which further reduces the possibility that the abstract graph does not meet the consistent distribution and improves the accuracy of graph detection. Figure 7 As shown, in the graph reduction method ②, taking the abstraction of k types of relationship as an example, the abstract graphs corresponding to the k types of relationship can be obtained, such as abstract graph 7021, abstract graph 7022, ... and abstract graph 702k.
[0139] Through the above process, appropriate and reasonable downsampling of the target knowledge graph can be achieved to obtain an abstract graph that conforms to the distribution of the target knowledge graph, and the abstract graph maintains the same consistent distribution as the target knowledge graph, thereby ensuring the accuracy of the graph inspection.
[0140] Step S605, perform a consistency check on the abstract graph, and determine the target check result of the target knowledge graph based on the check result of the abstract image.
[0141] In the embodiments of this application, please refer to Figure 3The computer device can obtain the entity attributes corresponding to the cluster entity objects in the abstract graph, replace the cluster entity objects in the abstract graph with the corresponding entity attributes, and obtain the ontology attribute graph. Figure 7 As shown, entity attributes are replaced for the abstract graphs corresponding to k types of relationship types, and ontology attribute graphs corresponding to k types of relationship types are obtained, such as ontology attribute graph 7031, ontology attribute graph 7032, ... and ontology attribute graph 703k. For example, taking an abstract graph as an example, assuming that the abstract graph includes entity objects "bronchitis", "amoxicillin" and "chronic cough", the entity attributes of the abstract graph are replaced, such as replacing the entity object "bronchitis" with the corresponding entity attribute "disease", replacing the entity object "amoxicillin" with the corresponding entity attribute "drug", replacing the entity object "chronic cough" with the corresponding entity attribute "symptom", etc. The obtained ontology attribute graph is more compact and more representative, and is easier to check, thereby improving the efficiency of graph inspection.
[0142] Furthermore, the knowledge set in the ontology attribute graph can be obtained, such as Figure 7 The knowledge set 704 shown includes the knowledge to be tested "disease -> therapeutic drug -> drug" and the knowledge to be tested "drug -> therapeutic drug -> symptom", etc. Acquire standard knowledge, which may include wrong knowledge and correct knowledge, such as Figure 7 The standard knowledge 705 shown, such as "u1—>r1—>v1", "u2!—>r2—>v2" and "u3—>r3!—>v2", etc., among which the standard knowledge including "!" is wrong knowledge, and the standard knowledge not including "!" is correct knowledge. For example, for the standard knowledge "u2!—>r2—>v2", it means that u2 should not have a relationship with r2, then the knowledge to be tested in the knowledge set 704 that satisfies "u2—>r2—>vX" does not meet the consistency, that is, the knowledge to be tested that satisfies "u2—>r2—>vX" can be considered as the knowledge to be tested that meets the wrong knowledge; for example, for the standard knowledge "u3—>r3!—>v2", it means that the r3 relationship of u3 cannot correspond to v2, then the knowledge to be tested "u3—>r3—>v2" in the knowledge set 704 is the knowledge to be tested that meets the wrong knowledge, etc.
[0143] For example, assuming that u1 is a disease, r1 is a therapeutic drug, v1 is a drug, u2 is a drug, r2 is a therapeutic drug, v2 is a symptom, etc., that is, the standard knowledge 705 includes "disease->therapeutic drug->drug" and "drug->therapeutic drug!->symptom", etc., compare the knowledge to be tested in the knowledge set 704 with the standard knowledge 705, and assume that the knowledge to be tested "drug->therapeutic drug->symptom" is found to be consistent with the erroneous knowledge "drug->therapeutic drug!->symptom", then determine that the target inspection result of the target knowledge graph is a graph contradiction result. Optionally, the knowledge to be tested that conforms to the erroneous knowledge can be mapped to the target knowledge graph to obtain the original triples corresponding to the knowledge to be tested that conforms to the erroneous knowledge, determine the original triples corresponding to the knowledge to be tested that conforms to the erroneous knowledge as abnormal triples, and output the graph abnormality message. For example, the knowledge to be detected "drugs -> therapeutic drugs -> symptoms" that conforms to the erroneous knowledge "drugs -> therapeutic drugs! -> symptoms" is mapped to the target knowledge graph to obtain abnormal triples, including "amoxicillin -> therapeutic drugs -> chronic cough", etc., and the graph abnormality message is output. Optionally, the device that provides the target knowledge graph can modify the abnormal triples, such as updating or deleting them. Optionally, if the knowledge to be detected included in the knowledge set does not conform to the erroneous knowledge and conforms to the correct knowledge, the target inspection result of the target knowledge graph can be determined to be a normal graph result.
[0144] Step S606: If the target inspection result is a normal graph result, the target knowledge graph is used.
[0145] In the embodiment of the present application, if the target inspection result is a normal result of the graph, the target knowledge graph can be used. For example, the target knowledge graph can be used in any application scenario where a knowledge graph can be used, such as knowledge question answering or relationship extraction. Figure 4 Application scenarios shown, etc.
[0146] For example, in response to an upload request for a target knowledge graph, a consistency check is performed on the target knowledge graph based on the upload request, that is, the above Figure 3 or Figure 6According to the steps shown, the target inspection result of the target knowledge graph is obtained. If the target inspection result is a normal result of the graph, the target knowledge graph is uploaded to the target application requested by the upload request. Optionally, a message indicating that the graph has been successfully uploaded can also be output. Furthermore, when responding to an information consultation request for a target application, the information to be processed carried by the information consultation request can be obtained, and the associated knowledge graph corresponding to the information to be processed can be obtained, and the associated knowledge graph belongs to the knowledge graph that has passed the consistency check and is included in the target application. For example, if the information to be processed is medical-related information, then the associated knowledge graph can be a medical knowledge graph; if the information to be processed is film and television-related information, then the associated knowledge graph can be a film and television knowledge graph, etc. The entity information associated with the information to be processed can be obtained, and a consultation response message corresponding to the entity information can be obtained based on the associated knowledge graph, and the consultation response message can be output. For example, taking the use of the target knowledge graph for knowledge question and answer as an example, please refer to the above Figure 4 Examples shown, etc. Of course, this application is mainly used for consistency checking of knowledge graphs. After the consistency check of the knowledge graph is passed, the application scenarios of the knowledge graph are not limited to the several application scenarios listed in this application, but can also be applied to other scenarios where knowledge graphs can be used, which are not limited here. Optionally, the device that performs graph checking on the target knowledge graph and the device that uses the target knowledge graph (such as initiating an information consultation request, etc.) can be the same device or a different device. For example, if the target knowledge graph is uploaded to a target application, all devices that use the target application can use the target knowledge graph, such as performing knowledge questions and answers or relationship extraction based on the target knowledge graph.
[0147] Among them, in the above process, the acquisition of target entity vectors and the clustering of n entity objects are unsupervised, which saves the cost of manual labeling, further reduces labor costs and improves the efficiency of graph inspection.
[0148] For further information, see Fig. 9 , Fig. 9 Schematic diagram of a spectrum inspection device provided in an embodiment of the present application. The spectrum inspection device may be a computer program (including program code, etc.) running in a computer device, for example, the spectrum inspection device may be an application software; the device may be used to execute the corresponding steps in the method provided in an embodiment of the present application. Fig. 9 As shown, the spectrum inspection device 900 can be used for Figure 3 The computer device in the corresponding embodiment, specifically, the device may include: a vector acquisition module 11, an entity clustering module 12, an object selection module 13, a graph generation module 14 and a graph detection module 15.
[0149] The vector acquisition module 11 is used to acquire the target entity vectors of the n entity objects included in the target knowledge graph; n is a positive integer; the target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph;
[0150] An entity clustering module 12, configured to perform clustering processing on the n entity objects based on the target entity vectors of the n entity objects to obtain p entity clusters;
[0151] The object selection module 13 is used to obtain cluster entity objects from p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster;
[0152] A graph generation module 14 is used to obtain the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generate an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters;
[0153] The graph detection module 15 is used to perform consistency check on the abstract graph and determine the target inspection result of the target knowledge graph based on the inspection result of the abstract image.
[0154] The device 900 further includes:
[0155] The data acquisition module 16 is used to acquire n entity objects included in the target knowledge graph and entity relationships corresponding to the n entity objects; the entity relationships include cluster entity relationships;
[0156] A tuple construction module 17, used to construct an original triple according to n entity objects and entity relationships corresponding to the n entity objects;
[0157] The vector adjustment module 18 is used to adjust the initial entity vectors of the n entity objects based on the vector conversion relationship corresponding to the original triplet, so as to obtain the target entity vectors corresponding to the n entity objects respectively.
[0158] The original triplet includes a first entity object, a second entity object, and an entity relationship between the first entity object and the second entity object; the n entity objects include the first entity object and the second entity object;
[0159] The vector adjustment module 18 includes:
[0160] An initial acquisition unit 18a, configured to acquire an initial entity vector of the first entity object, an initial entity vector of the second entity object, and an initial relationship vector of the entity relationship between the first entity object and the second entity object;
[0161] A vector mapping unit 18b is used to map the initial entity vector of the first entity object to the relationship space where the initial relationship vector is located to obtain a first mapping vector of the first entity object, and map the initial entity vector of the second entity object to the relationship space to obtain a second mapping vector of the second entity object;
[0162] A loss generating unit 18c, configured to generate a first loss function according to the first mapping vector, the second mapping vector, the initial relationship vector, and the vector conversion relationship corresponding to the original triple;
[0163] The vector adjustment unit 18d is used to adjust the initial entity vector of the first entity object and the initial entity vector of the second entity object based on the first loss function to obtain the target entity vector of the first entity object and the target entity vector of the second entity object.
[0164] Among them, the number of original triplets is m, and m is a positive integer;
[0165] The vector adjustment module 18 includes:
[0166] The type division unit 18e is used to obtain k types of relationship types included in the target knowledge graph, and divide the m original triples into k triple clusters based on the k types of relationship types; k is a positive integer; each triple cluster includes at least one original triple;
[0167] The vector adjustment unit 18d is also used to adjust the initial entity vectors of the n entity objects based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type, so as to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained; i is a positive integer less than or equal to k.
[0168] The vector adjustment module 18 includes:
[0169] A negative sample acquisition unit 18f is used to construct a negative sample entity object corresponding to the entity relationship in the original triple;
[0170] A positive distance acquisition unit 18g, used to acquire the positive sample distance corresponding to the original triplet based on the vector conversion relationship corresponding to the original triplet;
[0171] A negative distance acquisition unit 18h, used to acquire a negative sample distance between a negative sample entity object and an entity relationship in the original triplet based on a vector conversion relationship corresponding to the original triplet;
[0172] The loss adjustment unit 18i is used to generate a second loss function according to the positive sample distance and the negative sample distance, and adjust the initial entity vectors of the n entity objects according to the second loss function to obtain target entity vectors corresponding to the n entity objects.
[0173] The entity clustering module 12 includes:
[0174] The center processing unit 12a is used to obtain p initial cluster centers, and based on the target entity vectors of the n entity objects, obtain the initial cluster distances from the n entity objects to the p initial cluster centers respectively;
[0175] An initial clustering unit 12b, configured to divide the n entity objects into initial sets corresponding to the p initial clustering centers based on the initial clustering distances from the n entity objects to the p initial clustering centers respectively;
[0176] The update clustering unit 12c is used to obtain the update clustering centers corresponding to the p initial sets respectively, and divide the n entity objects into the update sets corresponding to the p update clustering centers based on the update clustering distances from the n entity objects to the update clustering centers corresponding to the p initial sets respectively;
[0177] The clustering iteration unit 12d is used for determining the p updated sets as the p initial sets if the p updated sets do not satisfy the node clustering condition, and returning to execute the process of obtaining the updated cluster centers corresponding to the p initial sets respectively;
[0178] The cluster determination unit 12e is configured to determine the p update sets as p entity clusters if the p update sets satisfy the node clustering condition; each entity cluster includes at least one entity object.
[0179] The entity clustering module 12 includes:
[0180] The to-be-processed acquisition unit 12f is used to acquire the to-be-processed entity object from the n entity objects; the to-be-processed entity object refers to the entity object that has not been subjected to node clustering processing;
[0181] The number acquisition unit 12g is used to acquire the number of adjacent entity objects located in the neighborhood of the entity object to be processed; the entity objects located in the neighborhood of the entity object to be processed refer to entity objects whose vector distance with the entity object to be processed is less than or equal to the neighborhood radius; the vector distance refers to the distance between the target entity vector of the corresponding entity object and the target entity vector of the entity object to be processed;
[0182] The node expansion unit 12h is used for, if the number of adjacent nodes is greater than or equal to the minimum number of set nodes, performing node expansion based on the entity object to be processed and the entity objects located in the neighborhood of the entity object to be processed, obtaining the density-reachable entity corresponding to the entity object to be processed, forming an entity cluster with the entity object to be processed and the density-reachable entity, returning to execute the process of obtaining the entity object to be processed from the n entity objects, until the entity object to be processed does not exist in the n entity objects, and p entity clusters are obtained;
[0183] The node processing unit 12i is used to return to the process of obtaining the entity object to be processed from the n entity objects if the number of adjacent nodes is less than the minimum number of set nodes.
[0184] The target entity vectors of n entity objects include target entity vectors of n entity objects under k types of relationships; k is a positive integer;
[0185] The entity clustering module 12 includes:
[0186] A type acquisition unit 12j is used to acquire k types of relationship types included in the target knowledge graph;
[0187] The type clustering unit 12k is used to cluster the n entity objects based on their target entity vectors under the i-th relationship type to obtain entity clusters corresponding to the i-th relationship type, until entity clusters corresponding to k relationship types are obtained; the entity clusters corresponding to the k relationship types constitute p entity clusters; i is a positive integer less than or equal to k.
[0188] The graph generation module 14 includes:
[0189] The relationship determination unit 14a is used to obtain the cluster entity relationship between the cluster entity objects corresponding to the entity cluster under the i-th relationship type from the target knowledge graph;
[0190] A graph generation unit 14b is used to form an abstract graph corresponding to the i-th relationship type by combining the cluster entity objects and cluster entity relationships corresponding to the entity cluster under the i-th relationship type;
[0191] The graph generation unit 14b is also used to obtain abstract graphs corresponding to k types of relationship types when i is k.
[0192] The graph detection module 15 includes:
[0193] A graph summarizing unit 15a is used to obtain entity attributes corresponding to cluster entity objects in the abstract graph, replace the cluster entity objects in the abstract graph with corresponding entity attributes, and obtain an ontology attribute graph;
[0194] The knowledge acquisition unit 15b is used to acquire the knowledge set in the ontology attribute graph and acquire standard knowledge;
[0195] The knowledge detection unit 15c is used to perform consistency check on the knowledge set based on the standard knowledge and determine the target check result of the target knowledge graph.
[0196] Among them, the knowledge set includes the knowledge to be tested; the standard knowledge includes the wrong knowledge;
[0197] The knowledge detection unit 15c includes:
[0198] The anomaly detection subunit 151c is used to compare the knowledge to be detected with the standard knowledge. If there is knowledge to be detected that matches the wrong knowledge in the knowledge set, it is determined that the target inspection result of the target knowledge graph is a graph contradiction result;
[0199] The abnormal output subunit 152c is used to map the knowledge to be detected that conforms to the erroneous knowledge into the target knowledge graph, obtain the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge, determine the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge as abnormal triples, and output the graph abnormality message.
[0200] The knowledge detection unit 15c includes:
[0201] The detection subunit 153c is used to compare the knowledge set with the standard knowledge. If there is undetected knowledge in the knowledge set that is not related to the standard knowledge, the undetected knowledge is sent to the management object so that the management object detects the undetected knowledge.
[0202] The knowledge adding subunit 154c is used to obtain the test results sent by the management object and the supplementary knowledge corresponding to the test results, determine the test results as the target inspection results of the target knowledge graph, and add the supplementary knowledge to the standard knowledge.
[0203] An embodiment of the present application provides a graph inspection device, which can obtain target entity vectors of n entity objects included in a target knowledge graph; n is a positive integer; the target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph; based on the target entity vectors of the n entity objects, the n entity objects are clustered to obtain p entity clusters, and cluster entity objects are respectively obtained from the p entity clusters; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster; the cluster entity relationship between the cluster entity objects corresponding to the p entity clusters is obtained from the target knowledge graph, and an abstract graph is generated based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters; a consistency check is performed on the abstract graph, and based on the inspection result of the abstract image, the target inspection result of the target knowledge graph is determined. Through the above process, clustering processing can be performed based on the target entity vector of the entity object, and the target entity vector can represent the characteristics of the corresponding entity object, and the target entity vector is obtained based on triple training, so that the target entity vector of each entity object can represent the relationship between each entity object in the target knowledge graph, and the entity objects are clustered based on the target entity vector, and similar entity objects can be clustered together, so that when the target knowledge graph is downsampled based on the entity cluster obtained by clustering, that is, when cluster entity objects are extracted from the entity cluster to form an abstract graph, the abstract graph conforms to the distribution of the original graph (that is, the target knowledge graph), that is, the abstract graph can maintain the same consistent distribution as the target knowledge graph, while reducing the scale of the knowledge graph that needs to be checked, thereby improving the inspection efficiency of the target knowledge graph while ensuring the accuracy of the inspection of the target knowledge graph.
[0204] See also Fig.10 , Fig.10 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.10 As shown, the computer device in the embodiment of the present application may include: one or more processors 1001, a memory 1002, and an input-output interface 1003. The processor 1001, the memory 1002, and the input-output interface 1003 are connected via a bus 1004. The memory 1002 is used to store a computer program, which includes program instructions, and the input-output interface 1003 is used to receive and output data, such as for data exchange between a computer device and an electronic device; the processor 1001 is used to execute the program instructions stored in the memory 1002.
[0205] The processor 1001 may perform the following operations:
[0206] Obtain target entity vectors of n entity objects included in the target knowledge graph; n is a positive integer; the target entity vectors of n entity objects are obtained by training the original triples included in the target knowledge graph;
[0207] Based on the target entity vectors of n entity objects, cluster the n entity objects to obtain p entity clusters, and obtain cluster entity objects from the p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster;
[0208] Obtain the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generate an abstract graph based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters;
[0209] Perform consistency check on the abstract graph, and determine the target check result of the target knowledge graph based on the check result of the abstract image.
[0210] In some feasible implementations, the processor 1001 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0211] The memory 1002 may include a read-only memory and a random access memory, and provide instructions and data to the processor 1001 and the input / output interface 1003. A portion of the memory 1002 may also include a non-volatile random access memory. For example, the memory 1002 may also store information about the device type.
[0212] In a specific implementation, the computer device can execute the following operations through its built-in functional modules: Figure 3 or Figure 6 For details on the implementation methods provided in each step, please refer to the Figure 3 or Figure 6 The implementation methods provided in each step will not be repeated here.
[0213] The embodiment of the present application provides a computer device, including: a processor, an input / output interface, and a memory, wherein the processor obtains a computer program in the memory and executes the computer program. Figure 3 Each step of the method shown in is used to perform a graph inspection operation. The embodiment of the present application realizes obtaining the target entity vectors of the n entity objects included in the target knowledge graph; n is a positive integer; the target entity vectors of the n entity objects are obtained by training the original triples included in the target knowledge graph; based on the target entity vectors of the n entity objects, the n entity objects are clustered to obtain p entity clusters, and cluster entity objects are obtained from the p entity clusters respectively; p is a positive integer; the cluster entity object is used to refer to the corresponding entity cluster; the cluster entity relationship between the cluster entity objects corresponding to the p entity clusters is obtained from the target knowledge graph, and an abstract graph is generated based on the cluster entity objects and cluster entity relationships corresponding to the p entity clusters respectively; the abstract graph is checked for consistency, and the target inspection result of the target knowledge graph is determined based on the inspection result of the abstract image. Through the above process, clustering processing can be performed based on the target entity vector of the entity object, and the target entity vector can represent the characteristics of the corresponding entity object, and the target entity vector is obtained based on triple training, so that the target entity vector of each entity object can represent the relationship between each entity object in the target knowledge graph, and the entity objects are clustered based on the target entity vector, and similar entity objects can be clustered together, so that when the target knowledge graph is downsampled based on the entity cluster obtained by clustering, that is, when cluster entity objects are extracted from the entity cluster to form an abstract graph, the abstract graph conforms to the distribution of the original graph (that is, the target knowledge graph), that is, the abstract graph can maintain the same consistent distribution as the target knowledge graph, while reducing the scale of the knowledge graph that needs to be checked, thereby improving the inspection efficiency of the target knowledge graph while ensuring the accuracy of the inspection of the target knowledge graph.
[0214] The present application also provides a computer-readable storage medium storing a computer program suitable for being loaded and executed by the processor. Figure 3 or Figure 6 For details on the spectrum inspection methods provided in each step, please refer to the Figure 3 or Figure 6 The implementation methods provided in each step are not repeated here. In addition, the description of the beneficial effects of adopting the same method is not repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, the computer program can be deployed to execute on one computer device, or on multiple computer devices located in one place, or on multiple computer devices distributed in multiple locations and interconnected by a communication network.
[0215] The computer-readable storage medium may be the internal storage unit of the spectrum inspection device or the computer device provided in any of the aforementioned embodiments, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0216] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes Figure 3 or Figure 6 The method provided in the various optional methods realizes clustering processing based on the target entity vector of the entity object, and the target entity vector can represent the characteristics of the corresponding entity object, and the target entity vector is obtained based on triple training, so that the target entity vector of each entity object can represent the relationship between each entity object in the target knowledge graph, and the entity objects are clustered based on the target entity vector, and similar entity objects can be clustered together, so that when the target knowledge graph is downsampled based on the entity cluster obtained by clustering, that is, when the cluster entity objects are extracted from the entity cluster to form an abstract graph, the abstract graph conforms to the distribution of the original graph (that is, the target knowledge graph), that is, the abstract graph can maintain the same consistent distribution as the target knowledge graph, while reducing the scale of the knowledge graph that needs to be checked, thereby improving the inspection efficiency of the target knowledge graph while ensuring the accuracy of the inspection of the target knowledge graph.
[0217] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.
[0218] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in this description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0219] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart 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 spectrum inspection device to generate a machine, so that the instructions executed by the processor of the computer or other programmable spectrum inspection device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable atlas inspection device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable atlas inspection device, so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0220] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0221] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0222] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A spectrum inspection method, characterized in that: The method comprises: Obtain n entity objects included in the target knowledge graph and entity relationships corresponding to the n entity objects; n is a positive integer; the target knowledge graph is a medical knowledge graph; any entity object refers to an object belonging to a disease, a drug or a symptom; According to the n entity objects and the entity relationships corresponding to the n entity objects, construct original triples; the number of the original triples is m, where m is a positive integer; Obtain k types of relations included in the target knowledge graph, and divide m original triples into k triple clusters based on the k types of relations; k is a positive integer; each triple cluster includes at least one original triple; Based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type, the initial entity vectors of the n entity objects are adjusted to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained; i is a positive integer less than or equal to k; Based on the target entity vectors of the n entity objects, clustering the n entity objects is performed to obtain p entity clusters, and cluster entity objects are respectively obtained from the p entity clusters; p is a positive integer; and the cluster entity objects are used to refer to the corresponding entity clusters; Acquire the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generate an abstract graph based on the cluster entity objects corresponding to the p entity clusters and the cluster entity relationships; the entity relationships include the cluster entity relationships; A consistency check is performed on the abstract graph, and based on the check result of the abstract graph, a target check result of the target knowledge graph is determined.
2. The method according to claim 1, characterized in that The original triplet includes a first entity object, a second entity object, and an entity relationship between the first entity object and the second entity object; the n entity objects include the first entity object and the second entity object; The initial entity vectors of the n entity objects are adjusted based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained, including: Acquire an initial entity vector of the first entity object, an initial entity vector of the second entity object, and an initial relationship vector of the entity relationship between the first entity object and the second entity object; Mapping the initial entity vector of the first entity object to the relationship space where the initial relationship vector of the i-th relationship type is located to obtain a first mapping vector i of the first entity object, and mapping the initial entity vector of the second entity object to the relationship space corresponding to the i-th relationship type to obtain a second mapping vector i of the second entity object; Generate a first loss function i according to the vector conversion relationship corresponding to the first mapping vector i, the second mapping vector i, the initial relationship vector, and the original triple; Based on the first loss function i, the initial entity vector of the first entity object and the initial entity vector of the second entity object are adjusted to obtain the target entity vector of the first entity object under the i-th relationship type and the target entity vector of the second entity object, until the target entity vectors of each entity object in the k relationship types are obtained.
3. The method according to claim 1, characterized in that The initial entity vectors of the n entity objects are adjusted based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained, including: In the i-th relationship type, construct a negative sample entity object corresponding to the entity relationship in the original triple; Based on the vector conversion relationship corresponding to the original triplet, obtaining the positive sample distance corresponding to the original triplet; Based on the vector conversion relationship corresponding to the original triplet, obtaining the negative sample distance between the negative sample entity object and the entity relationship in the original triplet; A second loss function is generated according to the positive sample distance and the negative sample distance, and the initial entity vectors of the n entity objects are adjusted according to the second loss function to obtain target entity vectors corresponding to the n entity objects under the i-th relationship type, until the target entity vectors of each entity object in the k relationship types are obtained.
4. The method according to claim 1, characterized in that The clustering process is performed on the n entity objects based on the target entity vectors of the n entity objects to obtain p entity clusters, including: Obtain p initial cluster centers, and based on the target entity vectors of the n entity objects, obtain initial cluster distances from the n entity objects to the p initial cluster centers respectively; Based on the initial clustering distances from the n entity objects to the p initial clustering centers respectively, the n entity objects are divided into initial sets corresponding to the p initial clustering centers; Obtaining update cluster centers corresponding to the p initial sets respectively, and dividing the n entity objects into update sets corresponding to the p update cluster centers based on update cluster distances from the n entity objects to the update cluster centers corresponding to the p initial sets respectively; If the p update sets do not satisfy the node clustering condition, the p update sets are determined as the p initial sets, and the process of obtaining the update cluster centers respectively corresponding to the p initial sets is returned to be executed; If the p update sets satisfy the node clustering condition, the p update sets are determined as p entity clusters; each entity cluster includes at least one entity object.
5. The method according to claim 1, characterized in that The clustering process is performed on the n entity objects based on the target entity vectors of the n entity objects to obtain p entity clusters, including: Obtaining an entity object to be processed from the n entity objects; the entity object to be processed refers to an entity object that has not been subjected to node clustering processing; Acquire the number of neighbors of the entity objects located in the neighborhood of the entity object to be processed; the entity objects located in the neighborhood of the entity object to be processed refer to entity objects whose vector distance with the entity object to be processed is less than or equal to the neighborhood radius; the vector distance refers to the distance between the target entity vector of the corresponding entity object and the target entity vector of the entity object to be processed; If the number of neighbors is greater than or equal to the minimum number of nodes in the set, node expansion is performed based on the entity object to be processed and the entity objects located in the neighborhood of the entity object to be processed to obtain a density-reachable entity corresponding to the entity object to be processed, the entity object to be processed and the density-reachable entity are combined into an entity cluster, and the process of obtaining the entity object to be processed from the n entity objects is returned to execute until the entity object to be processed does not exist in the n entity objects, and p entity clusters are obtained; If the number of adjacent nodes is less than the minimum number of set nodes, the process returns to execute the process of obtaining the entity object to be processed from the n entity objects.
6. The method according to claim 1, characterized in that The target entity vectors of the n entity objects include target entity vectors of the n entity objects under k types of relationships; k is a positive integer; The clustering process is performed on the n entity objects based on the target entity vectors of the n entity objects to obtain p entity clusters, including: Obtain the k types of relationships included in the target knowledge graph; Based on the target entity vectors of the n entity objects under the i-th relationship type, the n entity objects are clustered to obtain the entity cluster corresponding to the i-th relationship type, until the entity clusters corresponding to the k relationship types are obtained; the entity clusters corresponding to the k relationship types constitute p entity clusters; i is a positive integer less than or equal to k.
7. The method according to claim 6, characterized in that The step of acquiring the cluster entity relationships between the cluster entity objects corresponding to the p entity clusters from the target knowledge graph, and generating an abstract graph based on the cluster entity objects corresponding to the p entity clusters and the cluster entity relationships, includes: From the target knowledge graph, obtain the cluster entity relationship between the cluster entity objects corresponding to the entity cluster under the i-th relationship type; The cluster entity objects and cluster entity relationships corresponding to the entity cluster under the i-th relationship type are combined to form an abstract graph corresponding to the i-th relationship type; When i is k, the abstract graphs corresponding to the k types of relationships are obtained.
8. The method according to claim 1, characterized in that The performing consistency check on the abstract graph and determining a target check result of the target knowledge graph based on the check result of the abstract graph includes: Obtaining entity attributes corresponding to the cluster entity objects in the abstract graph, replacing the cluster entity objects in the abstract graph with corresponding entity attributes, and obtaining an ontology attribute graph; Acquire a knowledge set in the ontology attribute graph, acquire standard knowledge, perform a consistency check on the knowledge set based on the standard knowledge, and determine a target check result of the target knowledge graph.
9. The method according to claim 8, characterized in that The knowledge set includes knowledge to be tested; the standard knowledge includes erroneous knowledge; The performing consistency check on the knowledge set based on the standard knowledge to determine the target check result of the target knowledge graph includes: Compare the knowledge to be detected with the standard knowledge, and if there is knowledge to be detected that matches the erroneous knowledge in the knowledge set, determine that the target inspection result of the target knowledge graph is a graph-contradictory result; Map the knowledge to be detected that conforms to the erroneous knowledge into the target knowledge graph, obtain the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge, determine the original triples corresponding to the knowledge to be detected that conforms to the erroneous knowledge as abnormal triples, and output a graph abnormality message.
10. The method according to claim 8, characterized in that The performing consistency check on the knowledge set based on the standard knowledge to determine the target check result of the target knowledge graph includes: Comparing the knowledge set with the standard knowledge, if there is undetected knowledge in the knowledge set that is not related to the standard knowledge, sending the undetected knowledge to a management object so that the management object detects the undetected knowledge; Obtain the test result sent by the management object and the supplementary knowledge corresponding to the test result, determine the test result as the target inspection result of the target knowledge graph, and add the supplementary knowledge to the standard knowledge.
11. A spectrum inspection device, characterized in that: The device comprises: A data acquisition module, used to acquire n entity objects included in the target knowledge graph and entity relationships corresponding to the n entity objects; n is a positive integer; the target knowledge graph is a medical knowledge graph; any entity object refers to an object belonging to a disease, a drug or a symptom; A tuple construction module, used to construct an original triple according to the n entity objects and the entity relations corresponding to the n entity objects; the number of the original triples is m, where m is a positive integer; A vector adjustment module, used to obtain k types of relationship included in the target knowledge graph, and divide the m original triples into k triple clusters based on the k types of relationship; k is a positive integer; each triple cluster includes at least one original triple; The vector adjustment module is further used to adjust the initial entity vectors of the n entity objects based on the vector conversion relationship of at least one original triple in the triple cluster corresponding to the i-th relationship type, so as to obtain the target entity vectors corresponding to the n entity objects in the i-th relationship type, until the target entity vectors of each entity object in the k-th relationship type are obtained; i is a positive integer less than or equal to k; An entity clustering module, configured to perform clustering processing on the n entity objects based on the target entity vectors of the n entity objects to obtain p entity clusters; An object selection module, used to obtain cluster entity objects from the p entity clusters respectively; p is a positive integer; the cluster entity objects are used to refer to the corresponding entity clusters; A graph generation module, configured to obtain, from the target knowledge graph, cluster entity relationships between cluster entity objects corresponding to the p entity clusters, and generate an abstract graph based on the cluster entity objects corresponding to the p entity clusters and the cluster entity relationships; the entity relationships include the cluster entity relationships; The graph detection module is used to perform a consistency check on the abstract graph and determine a target check result of the target knowledge graph based on the check result of the abstract graph.
12. A computer device, characterized in that: Includes processor, memory, input and output interfaces; The processor is connected to the memory and the input / output interface respectively, wherein the input / output interface is used to receive and output data, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 10.
14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Knowledge graph construction method and device, server and computer readable storage medium
CN112445919A
Knowledge graph representation learning method and device, electronic equipment and storage medium
CN112784059A