Knowledge graph reasoning completion method and device, equipment, storage medium and product
By constructing an initial knowledge graph and performing rule mining and vector initialization, and optimizing entity and relation vectors, the problem of incomplete user information knowledge graph completion in existing technologies is solved, and higher quality and deeper knowledge graph embedding and reasoning are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-12
AI Technical Summary
Existing methods for constructing user information knowledge graphs rely on explicit associations and static rules, lacking efficient and automated reasoning mechanisms, resulting in insufficient comprehensiveness and depth of information completion.
By acquiring raw user data, converting it into triples to construct an initial knowledge graph, mining logical rules based on rule mining algorithms to perform path iterative combination and semantic association, and initializing and weighting entities and relations into vectors, the knowledge graph is optimized using combinatorial representation learning, generating optimized entity vectors and relation vectors, and finally completing the knowledge graph.
It improves the quality and reasoning performance of knowledge graph embedding, enhances the comprehensiveness and depth of knowledge graph completion, and enables better utilization of global information to achieve personalized services.
Smart Images

Figure CN122198115A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge graph technology, and in particular to a method, apparatus, device, storage medium, and product for knowledge graph reasoning and completion. Background Technology
[0002] In today's highly digitalized environment, many platforms manage numerous user accounts and information. However, a common phenomenon during user registration or profile updates is the omission of many non-mandatory fields, resulting in incomplete user profiles. This not only hinders a deeper understanding of users but also limits the ability to provide personalized services. To address this issue of incomplete user profile information, existing technologies can leverage knowledge graphs to integrate user information from different sources. Through the reasoning capabilities of knowledge graphs, unknown attributes can be inferred from known data, automatically filling in missing user information. This intelligent completion mechanism not only enriches user profiles but also improves the accuracy and depth of data analysis, enabling more precise personalized experiences and services. However, existing user information knowledge graph construction methods largely rely on explicit associations and static rules, lacking efficient and automated reasoning mechanisms to handle ambiguous, missing, or implicit user information, thus affecting the comprehensiveness and depth of information completion. Summary of the Invention
[0003] The purpose of this invention is to provide a knowledge graph reasoning completion method, apparatus, device, storage medium, and product that can better utilize global information in the knowledge graph, improve the quality of knowledge graph embedding and reasoning performance, thereby improving the comprehensiveness and depth of knowledge graph completion.
[0004] To achieve the above objectives, embodiments of the present invention provide a knowledge graph reasoning completion method, including: Obtain raw user data, convert the raw user data into triples, and construct an initial knowledge graph; Logical rules are extracted from the initial knowledge graph based on the rule mining algorithm, and new semantic associations are generated by iterative combination of paths in the initial knowledge graph according to the logical rules. The entities and relations in the initial knowledge graph are initialized and weighted as vectors, and the targets of triples, paths and relation pairs in the initial knowledge graph are optimized based on combinatorial representation learning to obtain optimized entity vectors and relation vectors; The initial knowledge graph is completed based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
[0005] As an improvement to the above scheme, the rule-based mining algorithm mines logical rules from the initial knowledge graph, and performs path iterative combination and generates new semantic associations on the initial knowledge graph according to the logical rules, including: Based on the rule mining algorithm, Horn logical rules are mined from the initial knowledge graph, and the form of the Horn logical rules is converted into a chain rule form; wherein, the Horn logical rules include a first rule set of length 1 and a second rule set of length 2; the first rule set is used to associate two relations in the rule body and the rule header, and the second rule set is used to combine paths; The improved PTransE algorithm is used to extract paths from the initial knowledge graph. The paths in the initial knowledge graph are guided to iteratively combine according to the second rule set and the preset path combination iteration rules to obtain all paths between all entities in the initial knowledge graph. New semantic associations between relations in the initial knowledge graph are generated based on the first rule set.
[0006] As an improvement to the above scheme, the path combination iteration rule is as follows: For a path of arbitrary length, traverse the relationships along the path in order, and select two adjacent relationships each time to form a path segment; The path segments are synthesized according to the second rule set; Iterate through the above process until the paths can no longer be merged.
[0007] As an improvement to the above scheme, the step of initializing and weighting the entities and relations in the initial knowledge graph, and optimizing the objectives of triples, paths, and relation pairs in the initial knowledge graph based on combinatorial representation learning, to obtain optimized entity vectors and relation vectors, includes: Map the entities and relations in the initial knowledge graph to a vector space; The weight of each relation in the path is determined based on the similarity of the relations in the path, and a path vector is constructed based on the relation weighting; Based on the triples, path vectors, and relation pairs in the initial knowledge graph, energy functions for triples, paths, and relation pairs are constructed respectively. A loss function is established based on the energy function, and the loss function is minimized to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, resulting in optimized entity vectors and relation vectors.
[0008] As an improvement to the above scheme, the step of determining the weight of each relation in the path based on the relation similarity in the path, and constructing a path vector based on relation weighting, includes: Calculate the edit distance between each relation in the path and the target relation; The similarity between each relation and the target relation is calculated based on the edit distance; The weight of each relation in the path is calculated based on the similarity. The path vector is obtained by weighted summation of all relations in the path.
[0009] As an improvement to the above scheme, the step of establishing a loss function based on the energy function, minimizing the loss function to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, and obtaining optimized entity vectors and relation vectors, includes: Based on the energy function, a loss function is established that includes triplet loss, path loss, and relation pair loss, and rule confidence is introduced as a penalty coefficient. The pairwise ranking loss is calculated based on the negative sampling strategy, and the loss function is minimized using the gradient descent method to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, thereby obtaining the optimized entity vector and relation vector.
[0010] This invention also provides a knowledge graph reasoning completion device, comprising: The data transformation module is used to acquire raw user data, convert the raw user data into triplet form, and construct an initial knowledge graph. The rule mining module is used to mine logical rules from the initial knowledge graph based on the rule mining algorithm, and to perform path iterative combination and generate new semantic associations on the initial knowledge graph according to the logical rules. The vector learning module is used to initialize and weight the entities and relations in the initial knowledge graph, and optimize the targets of triples, paths and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors. The graph completion module is used to complete the initial knowledge graph based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
[0011] This invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the knowledge graph reasoning and completion method described in any of the preceding embodiments.
[0012] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the knowledge graph reasoning and completion method described above.
[0013] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the knowledge graph reasoning and completion method described above.
[0014] Compared to existing technologies, the beneficial effects of the knowledge graph reasoning completion method, apparatus, device, storage medium, and product provided by this invention are as follows: First, original user data is acquired and converted into triplet form to construct an initial knowledge graph. Logical rules are then mined from the initial knowledge graph using a rule-based mining algorithm. Based on these rules, the initial knowledge graph undergoes iterative path combination and new semantic associations are generated. Entities and relations in the initial knowledge graph are initialized and weighted as vectors. Then, based on combinatorial representation learning, the targets of triplets, paths, and relation pairs in the initial knowledge graph are optimized to obtain optimized entity vectors and relation vectors. Finally, the initial knowledge graph is completed using the optimized entity vectors and relation vectors to obtain the target knowledge graph. This invention aims to solve the problem of missing user information in platforms with numerous users. By integrating knowledge graphs with a rule-guided path combinatorial representation learning method, a knowledge graph information completion system is constructed. This system can better utilize global information in the knowledge graph, improve the quality of knowledge graph embedding and reasoning performance, thereby enhancing the comprehensiveness and depth of knowledge graph completion. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating a preferred embodiment of a knowledge graph reasoning and completion method provided by the present invention; Figure 2 This is a schematic diagram of the algorithm model in a knowledge graph reasoning completion method provided by the present invention; Figure 3 This is a schematic diagram of RS1 generating semantic associations in a knowledge graph reasoning completion method provided by the present invention; Figure 4 This is a schematic diagram of the path combination iteration rules in a knowledge graph reasoning completion method provided by the present invention; Figure 5 This is a schematic diagram of a preferred embodiment of a knowledge graph reasoning and completion device provided by the present invention; Figure 6 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. Detailed Implementation
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] Please see Figure 1 , Figure 1 This is a flowchart illustrating a preferred embodiment of a knowledge graph reasoning and completion method provided by the present invention. The knowledge graph reasoning and completion method includes: S1, Obtain raw user data, convert the raw user data into triplet form, and construct an initial knowledge graph; S2, based on the rule mining algorithm, logical rules are mined from the initial knowledge graph, and the initial knowledge graph is iteratively combined with paths and new semantic associations are generated according to the logical rules; S3, initialize and weight the entities and relations in the initial knowledge graph, and optimize the targets of triples, paths and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors; S4. The initial knowledge graph is completed based on the optimized entity vector and relation vector to obtain the target knowledge graph.
[0018] Specifically, this embodiment of the invention first collects structured data within the enterprise, mainly including user basic information tables and organizational structure tables, and supplements it with tables from the IHR system, internal social network, project management system, and industry skill database to obtain raw user data. This data is then cleaned, deduplicated, and formatted to form a unified data source set. Neo4j graph database technology is used to convert the processed raw user data into structured triples, and a detailed initial knowledge graph is constructed. In constructing the initial knowledge graph, entity types (e.g., user, department, project), relationship types (e.g., belong, participate, friend), and entity attributes (e.g., user name, department ID, project name) need to be defined. Then, logical rules are mined from the initial knowledge graph using a rule mining algorithm. Based on these logical rules, the initial knowledge graph is iteratively combined with paths and new semantic associations are generated. Next, the entities and relationships in the initial knowledge graph are initialized and weighted as vectors, and the objectives of triples, paths, and relationship pairs in the initial knowledge graph are optimized based on combinatorial representation learning, resulting in optimized entity vectors and relationship vectors. Finally, the initial knowledge graph is completed based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
[0019] It should be noted that, after completing the initial knowledge graph to obtain the target knowledge graph, this embodiment of the invention can also respond to user feedback on the target knowledge graph and optimize and iterate the model based on the user feedback to improve the model's accuracy and robustness. For frequently occurring problem types in the feedback, rule mining parameters or optimized path combination strategies are adjusted. For example, a user verification interface is designed and implemented on the system platform for users to view and confirm the completed information result set. The verification interface needs to intuitively and clearly display the specific content of the completed information and the basis for completion (such as the path and rule information used), so that users can quickly understand and perform verification operations. A feedback mechanism is integrated into the user verification interface, allowing users to provide feedback on the completed information result set (such as confirming correctness, correcting errors, or submitting suggestions). The feedback operation results will be recorded in the feedback log for administrators or subsequent system processing. Simultaneously, the feedback mechanism also needs to support batch processing and asynchronous processing to improve processing efficiency and user experience. The vector representation is continuously adjusted based on user feedback, ensuring that the model can both fit known facts and conform to logical rules. Ultimately, this rule-optimized model achieves higher accuracy in predicting new knowledge, and the prediction results can be interpreted according to the rules.
[0020] This invention integrates knowledge graphs with a rule-guided path-based combined representation learning method to construct a knowledge graph information completion system. By integrating internal and external enterprise data to build a detailed initial knowledge graph, the missing content in the initial knowledge graph is completed through model algorithm reasoning. Based on user feedback on the completed information, a feedback loop is formed to continuously optimize the model accuracy. This allows for better utilization of global information in the knowledge graph, improving the quality of knowledge graph embedding and reasoning performance, thereby enhancing the comprehensiveness and depth of knowledge graph completion.
[0021] In a preferred embodiment, step S2 involves mining logical rules from the initial knowledge graph using a rule mining algorithm, and then iteratively combining paths and generating new semantic associations based on these logical rules. S21, Based on the rule mining algorithm, Horn logical rules are mined from the initial knowledge graph, and the form of the Horn logical rules is converted into a chain rule form; wherein, the Horn logical rules include a first rule set with a length of 1 and a second rule set with a length of 2; the first rule set is used to associate two relations in the rule body and the rule header, and the second rule set is used to combine paths; S22, Based on the improved PTransE algorithm, extract the paths in the initial knowledge graph, and perform guided iterative combination of the paths in the initial knowledge graph according to the second rule set and the preset path combination iteration rules to obtain all paths between all entities in the initial knowledge graph; S23, Generate new semantic associations between relations in the initial knowledge graph based on the first rule set.
[0022] Specifically, this invention proposes a novel rule-guided compositional representation learning method, called Rule-guided path-based representation learning algorithm (RGPBA), with the following overall architecture: Figure 2 As shown, Figure 2 This is a schematic diagram of the algorithm model in the knowledge graph reasoning completion method provided by the present invention. The embodiments of the present invention are based on rule mining algorithms, such as the RuLES rule mining algorithm, to mine Horn logic rules from the initial knowledge graph, and the confidence of the rule is recorded as μ. The higher the confidence, the higher the probability of the rule being held. The maximum length of the rule is limited to 2 to improve the efficiency of mining effective rules. Therefore, Horn logic rules can be divided into two types according to their length: (1) a first rule set (rule set1, RS1) with a length of 1, which associates the two relations in the rule body and the rule header. (2) a second rule set (rule set2, RS2) with a length of 2, which can be used to combine paths. Table 1 below provides some examples of the first rule set RS1 and the second rule set RS2 and their corresponding confidence.
[0023] Table 1 Examples of some rules
[0024] Since non-chained rules cannot be directly used for path composition, Horn logic rules need to be converted into chained rule form for use in the path composition process. During the conversion, rules can be encoded according to the rule conversion patterns in Table 2 to form a chained rule list.
[0025] Table 2. List of chained rule transformations for the second rule set RS2
[0026] The improved PTransE algorithm extracts paths from the initial knowledge graph, and guides iterative combinations of these paths according to the second rule set RS2 and preset path combination iteration rules to obtain all paths between all entities in the initial knowledge graph. Then, new semantic associations between relations in the initial knowledge graph are generated according to the first rule set RS1, such as... Figure 3 As shown, Figure 3 This is a schematic diagram illustrating the generation of semantic associations using RS1 in a knowledge graph reasoning completion method provided by this invention. In the case of the first rule set RS1, when the rule... At the time of establishment, the relationship Its directly derived relationship They may have higher semantic similarity. For the form of The rules need to be encoded as To facilitate representation learning, during training, the embeddings of pairs of relations that coexist in the first rule set RS1 are constrained to be closer than the embedding distance between two relations that do not match any rules. Based on this, entities and relations in the symbolic space are converted into a vector space using a vector initialization method to train the knowledge graph embeddings. This initialization helps preserve the semantic information of entities and relations during learning, thereby improving the quality of the embeddings.
[0027] This invention addresses the shortcomings of existing knowledge graph completion methods, such as the inability to embed complex semantics through logical rules and the lack of interpretability in black-box models. It proposes a rule-guided path-based combined representation learning method that combines paths with logical rules to provide the model with more semantic information. Using Horn logical rules, paths and relationships are combined at the semantic layer to improve the accuracy of learning knowledge graph path embedding and enhance the interpretability of representation learning.
[0028] In another preferred embodiment, the path combination iteration rule is: For a path of arbitrary length, traverse the relationships along the path in order, and select two adjacent relationships each time to form a path segment; The path segments are synthesized according to the second rule set; Iterate through the above process until the paths can no longer be merged.
[0029] Specifically, this invention provides a path combination iteration rule, such as... Figure 4 As shown, Figure 4 This is a schematic diagram of the path combination iteration rule in a knowledge graph reasoning completion method provided by this invention. This rule can handle paths of arbitrary length, sequentially traversing the relations along the path, selecting two adjacent relations each time to form a small path segment, and then combining them using the RS2 rule set. By continuously iterating this process until no two relations in the path can be merged by the RS2 rule, all possible paths between all entities in the initial knowledge graph can be found.
[0030] This invention, through implementing this method, can more effectively utilize encoding rules to combine and optimize paths. This method allows for the discovery of more precise and meaningful relationships in knowledge graphs, thus providing a stronger foundation for reasoning about relationships between entities. For entities or relationships in a user's knowledge graph with incomplete information, a rule-guided path combination representation learning method is used to complete the information, including inferring skills, potential experiences, interests, etc., forming a personalized information completion strategy.
[0031] In another preferred embodiment, step S3 involves initializing and weighting the entities and relations in the initial knowledge graph, and optimizing the targets of triples, paths, and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors, including: S31, map the entities and relations in the initial knowledge graph to a vector space; S32, determine the weight of each relation in the path based on the relation similarity in the path, and construct a path vector based on relation weighting; S33, based on the triples, path vectors and relation pairs in the initial knowledge graph, construct energy functions for the triples, paths and relation pairs respectively; S34. Establish a loss function based on the energy function, minimize the loss function to optimize the targets of triples, paths and relation pairs in the initial knowledge graph, and obtain the optimized entity vector and relation vector.
[0032] Specifically, this embodiment of the invention uses a vector initialization method to map entities and relations in the symbolic space to the vector space. When vectorizing the paths between entities in the initial knowledge graph, traditional PTransE simply adds the relation vectors contained in the path to construct the path vector representation. However, after studying the relevance of certain paths and relations, this embodiment of the invention finds that some relations are more important to the path, and different relations should have different weights to express their influence on entity-relation pairs. Based on this, this embodiment of the invention determines the weight of each relation in the path according to the relation similarity, and constructs the path vector based on relation weighting. Then, based on the triples, path vectors, and relation pairs in the initial knowledge graph, energy functions are constructed for the triples, paths, and relation pairs respectively, to simulate the relevance with direct triples, the relevance of path pairs using rule RS2 in PTransE, and the relevance of relation pairs using rule RS1, as shown in the following equation: ; ; ; in, Indicates when triples The initial score was low. Indicates the evaluation path With Relationship The energy function of similarity between them. It indicates an evaluation relationship. With another relationship The energy function of similarity between them, if It is a relationship Relationships derived from rule RS1 should be given a lower score.
[0033] Finally, in the joint training module, combinatorial representation learning is implemented. A loss function is established based on the energy function, and minimizing the loss function optimizes the objectives of triples, paths, and relation pairs in the initial knowledge graph, resulting in optimized entity vectors and relation vectors. In this process, the objective function is optimized by learning the embedding representations of entities and relations, enabling it to better capture semantic information in the knowledge graph. This representation learning method helps improve the model's predictive ability and generalization performance.
[0034] The rule-guided path-based combinatorial representation learning provided in this invention extracts paths and mines Horn logic rules from a knowledge graph, then applies these rules to generate new semantic associations. Next, entities and relations are converted into vector space representations using vector initialization and weighting methods. Combinatorial representation learning optimizes targets specific to triples, paths, and association pairs, better utilizing global information in the knowledge graph. This improves the quality of knowledge graph embedding and inference performance, thereby enhancing the comprehensiveness and depth of knowledge graph completion.
[0035] In another preferred embodiment, step S32, determining the weight of each relation in the path based on the relation similarity in the path, and constructing a path vector based on relation weighting, includes: S321, calculates the edit distance between each relation in the path and the target relation; S322, Calculate the similarity between each relation and the target relation based on the edit distance; S323, Calculate the weight of each relation in the path based on the similarity; S324, perform a weighted summation of all relations in the path to obtain the path vector.
[0036] Specifically, this embodiment of the invention defines a This is used to represent the similarity between relationships in the path and the target relationship. This represents the edit distance between two relations. The calculation method is shown in the following formula: ; in, and These represent two relations, and the edit distance is... Indicates will Convert to Minimum edit distance required and These represent the lengths of the two relations, respectively. This represents the edit distance for converting one string to another, which is the minimum number of operations required, including inserting, deleting, or replacing a character.
[0037] Next, the similarity between each relation and the target relation is calculated, as shown in the following formula: ; in, Indicates the relationships within a path. Indicates a target relationship.
[0038] Secondly, the weight of each relation in the path is calculated based on the similarity, as shown in the following formula: ; in, Indicates the first in the path The weight of each relation, This represents the sum of similarities between all relations and the target relation.
[0039] Finally, a weighted sum is performed on all relations in the path to obtain the path vector, as shown in the following formula: ; in, p Represents the path vector. , … Each relation represents a separate relation. r 1 、r 2… r n The weight.
[0040] In the process of constructing path vector representations based on relational weighting, the energy function is defined as follows: ; It's important to note that the method of constructing path vectors based on relation weights is only applicable to specific scenarios, namely, where the relationship between the head and tail entities needs to be included in the path. In this case, the weight of the corresponding relation may be higher when calculating the weights, thus... Use the above formula to calculate.
[0041] This invention, based on an optimized relation-weighted method, helps to uncover more details of relationships between entities compared to the traditional PTransE algorithm. When determining relation weights, a more accurate representation can be achieved by analyzing the similarity between relations and their position and importance within the path. This method helps to better understand the complex relationships between entities, thereby improving the accuracy of predicting new relations in knowledge graphs.
[0042] In another preferred embodiment, step S34 involves establishing a loss function based on the energy function, minimizing the loss function to optimize the targets of triples, paths, and relation pairs in the initial knowledge graph, and obtaining optimized entity vectors and relation vectors, including: S341, Based on the energy function, establish a loss function including triplet loss, path loss and relation pair loss, and introduce rule confidence as a penalty coefficient; S342, calculate the pairwise ranking loss based on the negative sampling strategy, and minimize the loss function using the gradient descent method to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, thereby obtaining the optimized entity vector and relation vector.
[0043] Specifically, this embodiment of the invention introduces a pairwise ranking loss function to formalize the model training optimization objective, and the calculation method is shown in the following formula: ; Based on this, an optimization objective is proposed, consisting of three parts, corresponding to the three parts of the energy function mentioned earlier: triples, path pairs, and relation pairs. In the overall loss function formula, the parameters... and These represent the weights of the loss for path pairs and relation pairs, respectively, with the aim of achieving a better balance during the learning process. Defined according to rule RS1 from r The set of all derived relations. for Any relationship within it. Indicates a pair of connected entities All paths, yes One of the paths in the middle. , and These are three marginal loss functions of the energy function, which respectively measure the impact of representation learning on direct triples. Path pair and relationship The validity of is defined as follows: ; ; ; Among them, the function is defined. To obtain 0 to The maximum value between; , , These are three positive hyperparameters, representing each margin of the loss function in the formula; the weights of the triples are fixed at 1. and These are two hyperparameters, representing the influence of weighted paths and relations on embedding constraints, respectively. This represents the confidence level of rule RS1, which is the confidence level of a rule of length 1. The confidence levels of all rules are considered as penalty coefficients in the optimization process. This represents the set containing all positive triples observed in the knowledge graph. This represents the set of negative triples. This invention employs gradient descent to train model parameters, aiming to optimize the triples, paths, and relation pairs in the initial knowledge graph by minimizing the loss function.
[0044] The embodiments of the present invention define The function calculates the score of the triplet and sorts all candidate triplets according to their energy.
[0045] ; The candidate entity or relation with the highest score is selected as the prediction result to fill in the missing user information in the initial knowledge graph, thereby obtaining the target knowledge graph.
[0046] Accordingly, the present invention also provides a knowledge graph reasoning completion device, which can implement all the processes of the knowledge graph reasoning completion method in the above embodiments.
[0047] Please see Figure 5 , Figure 5 This is a schematic diagram of a preferred embodiment of a knowledge graph reasoning and completion device provided by the present invention. The knowledge graph reasoning and completion device includes: The data conversion module 501 is used to acquire raw user data, convert the raw user data into triplet form, and construct an initial knowledge graph. The rule mining module 502 is used to mine logical rules from the initial knowledge graph based on the rule mining algorithm, and to perform path iterative combination and generate new semantic associations on the initial knowledge graph according to the logical rules. The vector learning module 503 is used to initialize and weight the entities and relations in the initial knowledge graph, and optimize the targets of triples, paths and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors. The graph completion module 504 is used to complete the initial knowledge graph based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
[0048] Preferably, the rule mining module 502 is specifically used for: Based on the rule mining algorithm, Horn logical rules are mined from the initial knowledge graph, and the form of the Horn logical rules is converted into a chain rule form; wherein, the Horn logical rules include a first rule set of length 1 and a second rule set of length 2; the first rule set is used to associate two relations in the rule body and the rule header, and the second rule set is used to combine paths; The improved PTransE algorithm is used to extract paths from the initial knowledge graph. The paths in the initial knowledge graph are guided to iteratively combine according to the second rule set and the preset path combination iteration rules to obtain all paths between all entities in the initial knowledge graph. New semantic associations between relations in the initial knowledge graph are generated based on the first rule set.
[0049] Preferably, the path combination iteration rule is as follows: For a path of arbitrary length, traverse the relationships along the path in order, and select two adjacent relationships each time to form a path segment; The path segments are synthesized according to the second rule set; Iterate through the above process until the paths can no longer be merged.
[0050] Preferably, the vector learning module 503 is specifically used for: Map the entities and relations in the initial knowledge graph to a vector space; The weight of each relation in the path is determined based on the similarity of the relations in the path, and a path vector is constructed based on the relation weighting; Based on the triples, path vectors, and relation pairs in the initial knowledge graph, energy functions for triples, paths, and relation pairs are constructed respectively. A loss function is established based on the energy function, and the loss function is minimized to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, resulting in optimized entity vectors and relation vectors.
[0051] Preferably, the step of determining the weight of each relation in the path based on the relation similarity in the path, and constructing a path vector based on relation weighting, includes: Calculate the edit distance between each relation in the path and the target relation; The similarity between each relation and the target relation is calculated based on the edit distance; The weight of each relation in the path is calculated based on the similarity. The path vector is obtained by weighted summation of all relations in the path.
[0052] Preferably, the step of establishing a loss function based on the energy function, minimizing the loss function to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, and obtaining optimized entity vectors and relation vectors, includes: Based on the energy function, a loss function is established that includes triplet loss, path loss, and relation pair loss, and rule confidence is introduced as a penalty coefficient. The pairwise ranking loss is calculated based on the negative sampling strategy, and the loss function is minimized using the gradient descent method to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, thereby obtaining the optimized entity vector and relation vector.
[0053] In specific implementation, the working principle, control process and technical effects of the knowledge graph reasoning and completion device provided in the embodiments of the present invention are the same as those of the knowledge graph reasoning and completion method in the above embodiments, and will not be repeated here.
[0054] Please see Figure 6 , Figure 6 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 601, a memory 602, and a computer program stored in the memory 602 and configured to be executed by the processor 601. When the processor 601 executes the computer program, it implements the knowledge graph reasoning and completion method described in any of the above embodiments.
[0055] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 602 and executed by the processor 601 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0056] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor 601 may be any conventional processor. The processor 601 is the control center of the terminal device, connecting various parts of the terminal device through various interfaces and lines.
[0057] The memory 602 mainly includes a program storage area and a data storage area. The program storage area can store the operating system, applications required for at least one function, etc., while the data storage area can store related data, etc. Furthermore, the memory 602 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard drive, a smart media card (SMC), a secure digital card (SD), and a flash card, or it can be other volatile solid-state storage devices.
[0058] It should be noted that the aforementioned terminal devices may include, but are not limited to, processors and memory, as will be understood by those skilled in the art. Figure 6 The structural diagram is merely an example of the terminal device described above and does not constitute a limitation on the terminal device described above. It may include more or fewer components than shown in the diagram, or combine certain components, or use different components.
[0059] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the knowledge graph reasoning and completion method described in any of the above embodiments.
[0060] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the knowledge graph reasoning and completion method described in any of the above embodiments.
[0061] This invention provides a knowledge graph reasoning completion method, apparatus, device, storage medium, and product. It acquires raw user data, converts the data into triples, and constructs an initial knowledge graph. Logical rules are mined from the initial knowledge graph using a rule-based mining algorithm. Based on these rules, the initial knowledge graph undergoes iterative path combination and generates new semantic associations. Entities and relations in the initial knowledge graph are initialized and weighted as vectors. Based on combinatorial representation learning, the targets of triples, paths, and relation pairs in the initial knowledge graph are optimized to obtain optimized entity vectors and relation vectors. The initial knowledge graph is then completed using the optimized entity vectors and relation vectors to obtain a target knowledge graph. This invention aims to address the problem of missing user information in platforms with numerous users. By integrating knowledge graphs with a rule-guided path combinatorial representation learning method, a knowledge graph information completion system is constructed. This system can better utilize global information in the knowledge graph, improve the quality of knowledge graph embedding and reasoning performance, thereby enhancing the comprehensiveness and depth of knowledge graph completion.
[0062] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0063] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A knowledge graph reasoning completion method, characterized in that, include: Obtain raw user data, convert the raw user data into triples, and construct an initial knowledge graph; Logical rules are extracted from the initial knowledge graph based on the rule mining algorithm, and new semantic associations are generated by iterative combination of paths in the initial knowledge graph according to the logical rules. The entities and relations in the initial knowledge graph are initialized and weighted as vectors, and the targets of triples, paths and relation pairs in the initial knowledge graph are optimized based on combinatorial representation learning to obtain optimized entity vectors and relation vectors; The initial knowledge graph is completed based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
2. The knowledge graph reasoning completion method as described in claim 1, characterized in that, The rule-based mining algorithm extracts logical rules from the initial knowledge graph, and performs path iterative combination and generates new semantic associations based on the logical rules, including: Based on the rule mining algorithm, Horn logical rules are mined from the initial knowledge graph, and the form of the Horn logical rules is converted into a chain rule form; wherein, the Horn logical rules include a first rule set of length 1 and a second rule set of length 2; the first rule set is used to associate two relations in the rule body and the rule header, and the second rule set is used to combine paths; The improved PTransE algorithm is used to extract paths from the initial knowledge graph. The paths in the initial knowledge graph are guided to iteratively combine according to the second rule set and the preset path combination iteration rules to obtain all paths between all entities in the initial knowledge graph. New semantic associations between relations in the initial knowledge graph are generated based on the first rule set.
3. The knowledge graph reasoning completion method as described in claim 2, characterized in that, The path combination iteration rule is as follows: For a path of arbitrary length, traverse the relationships along the path in order, and select two adjacent relationships each time to form a path segment; The path segments are synthesized according to the second rule set; Iterate through the above process until the paths can no longer be merged.
4. The knowledge graph reasoning completion method as described in claim 3, characterized in that, The process involves initializing and weighting the entities and relations in the initial knowledge graph, and then optimizing the targets of triples, paths, and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors, including: Map the entities and relations in the initial knowledge graph to a vector space; The weight of each relation in the path is determined based on the similarity of the relations in the path, and a path vector is constructed based on the relation weighting; Based on the triples, path vectors, and relation pairs in the initial knowledge graph, energy functions for triples, paths, and relation pairs are constructed respectively. A loss function is established based on the energy function, and the loss function is minimized to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, resulting in optimized entity vectors and relation vectors.
5. The knowledge graph reasoning completion method as described in claim 4, characterized in that, The step of determining the weight of each relation in the path based on the relation similarity in the path, and constructing a path vector based on relation weighting, includes: Calculate the edit distance between each relation in the path and the target relation; The similarity between each relation and the target relation is calculated based on the edit distance; The weight of each relation in the path is calculated based on the similarity. The path vector is obtained by weighted summation of all relations in the path.
6. The knowledge graph reasoning completion method as described in claim 5, characterized in that, The step of establishing a loss function based on the energy function, minimizing the loss function to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, and obtaining optimized entity vectors and relation vectors includes: Based on the energy function, a loss function is established that includes triplet loss, path loss, and relation pair loss, and rule confidence is introduced as a penalty coefficient. The pairwise ranking loss is calculated based on the negative sampling strategy, and the loss function is minimized using the gradient descent method to optimize the objectives of triples, paths, and relation pairs in the initial knowledge graph, thereby obtaining the optimized entity vector and relation vector.
7. A knowledge graph reasoning completion device, characterized in that, include: The data transformation module is used to acquire raw user data, convert the raw user data into triplet form, and construct an initial knowledge graph. The rule mining module is used to mine logical rules from the initial knowledge graph based on the rule mining algorithm, and to perform path iterative combination and generate new semantic associations on the initial knowledge graph according to the logical rules. The vector learning module is used to initialize and weight the entities and relations in the initial knowledge graph, and optimize the targets of triples, paths and relation pairs in the initial knowledge graph based on combinatorial representation learning to obtain optimized entity vectors and relation vectors. The graph completion module is used to complete the initial knowledge graph based on the optimized entity vectors and relation vectors to obtain the target knowledge graph.
8. A terminal device, characterized in that, The method includes a processor and a memory, wherein the memory stores a computer program and the computer program is configured to be executed by the processor, wherein the processor, when executing the computer program, implements the knowledge graph reasoning completion method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the knowledge graph reasoning and completion method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the knowledge graph reasoning completion method as described in any one of claims 1 to 6.