Link prediction method and device based on subgraph feature fusion and computer equipment
By fusing subgraph features in the knowledge graph and utilizing multi-head self-attention and cross-attention mechanisms for semantic feature extraction and fusion, the problem of insufficient link prediction performance caused by the incompleteness of the knowledge graph is solved, and more efficient link prediction is achieved.
Patent Information
- Application Number
- CN202310684342.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-09
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-06-09
AI Technical Summary
Existing technologies struggle to effectively address the incompleteness of knowledge graphs, resulting in insufficient link prediction performance.
We employ a subgraph feature fusion approach to obtain the context subgraph of the knowledge graph and use multi-head self-attention and cross-attention mechanisms to extract and fuse semantic features, thereby enabling link prediction of the knowledge graph.
It improves the accuracy and efficiency of knowledge graph link prediction, especially performing well in large-scale industrial knowledge graphs.
Smart Images

Figure CN116662486B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of knowledge graph technology, and in particular to a link prediction method, apparatus, and computer equipment based on subgraph feature fusion. Background Art
[0002] Knowledge graphs typically encode various unstructured data in the form of (head entity, relationship, tail entity) triplets. The rapid development of knowledge graphs in recent years has led to continuous advancements in downstream knowledge graph tasks such as information mining and information retrieval, becoming an essential component in solving real-world problems such as question-answering and recommendation systems. However, the diversity and complexity of knowledge inevitably lead to incompleteness in knowledge graphs.
[0003] The link prediction task aims to predict potential triples in knowledge graphs, addressing the gap between knowledge diversity and graph incompleteness. Early link prediction methods primarily learned embedding vectors for each entity and relationship in the knowledge graph and then used simple scoring functions to calculate the plausibility of new entities. The goal was to learn a compact encoding structure and semantic information for each entity and relationship embedding, enabling accurate judgments using simple scoring functions. However, fully encoding the rich information in knowledge graphs into shallow embeddings is a significant challenge. Summary of the Invention
[0004] Based on this, it is necessary to provide a link prediction method, device and computer equipment based on subgraph feature fusion that can improve prediction performance in response to the above technical problems.
[0005] A link prediction method based on subgraph feature fusion, the method comprising:
[0006] Obtain the knowledge graph and query sentence for link prediction;
[0007] Selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph to obtain a context subgraph related to the query sentence;
[0008] Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph;
[0009] Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0010] Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features;
[0011] The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0012] In one embodiment, selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph includes:
[0013] When the source entity in the query is unknown, a breadth-limited search or a two-hop proximity search is used to search the knowledge graph;
[0014] When the target entity in the query is unknown, a reinforcement learning network is used to search the knowledge graph.
[0015] In one embodiment, the reinforcement learning network adopts the MSURL model, and the actor-critic reinforcement learning algorithm is used to train the MSURL model.
[0016] In one embodiment, after the context subgraph is input into the embedding layer, the context subgraph is first classified according to the subject and relationship, and then word lookup embedding, word type embedding and word segment embedding are performed respectively, and the obtained embedding data are merged to form a static vector table related to the context subgraph.
[0017] In one embodiment, the dual-tower layer based on the multi-head self-attention mechanism includes two identical self-attention mechanism units, which respectively perform feature extraction on the static vector table and the query question, and correspondingly obtain the query semantic features and the context subgraph semantic features.
[0018] In one embodiment, the embedding layer, the dual-tower layer based on the multi-head self-attention mechanism, the feature fusion layer based on the cross-attention mechanism, and the prediction layer are integrated into a knowledge graph link prediction network;
[0019] The knowledge graph to be linked is predicted and the query sentence are input into the knowledge graph link prediction network to obtain the probability distribution of each entity in the context subgraph related to the query sentence in the knowledge graph to achieve link prediction for the knowledge graph.
[0020] A link prediction device based on subgraph feature fusion, the device comprising:
[0021] The data acquisition module is used to obtain the knowledge graph and query sentences for link prediction;
[0022] A subgraph obtaining module, configured to select a corresponding search strategy according to the representation of the query sentence to search the knowledge graph and obtain a context subgraph related to the query sentence;
[0023] a static vector table obtaining module, configured to input the context subgraph into an embedding layer, learn all entity and relationship information in the context subgraph using a word embedding method in the embedding layer, and output a static vector table related to the context subgraph;
[0024] A semantic feature extraction module is used to input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0025] A semantic feature fusion module is used to input the query semantic feature and the context subgraph semantic feature into a feature fusion layer based on a cross attention mechanism to obtain a semantic fusion feature;
[0026] The link prediction module is used to input the semantic fusion features and the context subgraph semantic features into the prediction layer, and to perform probability distribution of each entity in the context subgraph to achieve link prediction for the knowledge graph.
[0027] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0028] Obtain the knowledge graph and query sentence for link prediction;
[0029] Selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph to obtain a context subgraph related to the query sentence;
[0030] Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph;
[0031] Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0032] Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features;
[0033] The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0034] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0035] Obtain the knowledge graph and query sentence for link prediction;
[0036] Selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph to obtain a context subgraph related to the query sentence;
[0037] Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph;
[0038] Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0039] Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features;
[0040] The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0041] The above-mentioned link prediction method, device, and computer device based on subgraph feature fusion search the knowledge graph for link prediction by selecting a corresponding search strategy based on the representation of the query, obtaining a context subgraph related to the query. The context subgraph is input into the embedding layer, which uses word embedding to learn all entity and relationship information in the subgraph to obtain a static vector table. Then, a dual-tower layer based on a multi-head self-attention mechanism and a feature fusion layer based on a cross-attention mechanism are used to extract semantic features from the static vector table and the query, respectively, and then the semantic features are fused. Finally, the prediction layer predicts the fused features to achieve connection prediction in the knowledge graph. This method can improve the performance of entity link prediction and is suitable for link prediction in knowledge graphs in industrial fields with large amounts of entity data. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 1 is a flow chart of a link prediction method based on subgraph feature fusion in one embodiment;
[0043] Figure 2 Schematic diagram of a multi-head self-attention mechanism framework in one embodiment;
[0044] Figure 3 A schematic diagram of the structure of a knowledge graph link prediction network in one embodiment;
[0045] Figure 4 1 is a structural block diagram of a link prediction device based on subgraph feature fusion in one embodiment;
[0046] Figure 5 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0048] In one embodiment, Figure 1 As shown, a link prediction method based on subgraph feature fusion is provided, which includes the following steps:
[0049] Step S100: Obtain the knowledge graph and query sentence for link prediction;
[0050] Step S110: Select a corresponding search strategy based on the representation of the query to search the knowledge graph and obtain a context subgraph related to the query;
[0051] Step S120: input the context subgraph into the embedding layer, use the word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and output a static vector table related to the context subgraph;
[0052] Step S130: Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism to extract query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0053] Step S140: inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross-attention mechanism to obtain semantic fusion features;
[0054] In step S150, the semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0055] In this method, we first search for subgraphs related to the query statement in the known knowledge graph, which can speed up the prediction of the entire entity link. After the subgraph is embedded, a dual-tower structure based on multi-head self-attention is used to simultaneously encode the subgraph and the query statement, so that the model focuses on the semantic information of the nodes and edges. Then, the cross-attention mechanism is used to fuse the hidden layer features of the subgraph and the query statement, so that the model pays more attention to the relevant information in the nodes and relationships in the subgraph and the query statement, which facilitates the subsequent prediction of entity links in the subgraph. This method can effectively improve the accuracy and efficiency of link prediction.
[0056] In step S100, the knowledge graph to be used for link prediction is a knowledge graph in the industrial field, including a set of entities α and a set of relationships β. The knowledge graph can be defined as a set of multiple triples, represented as f = (h, r, t), where h, t∈α, r∈β. h and t represent the head entity and the tail entity, respectively, or can also be represented as the source entity and the target entity, and r represents the relationship between entities. The link prediction task aims to use the current knowledge graph information to infer the set of triples that do not appear in f. Given a query statement, the statement is abstracted as q = (h, r, ?) or q = (?, r, t), where ? represents the target entity or source entity in the query sentence.
[0057] In this example, the large-scale industrial knowledge graph for link prediction was created using an ontology reconstruction method. During the creation process, data sets provided by various parties, including the Certification and Supervision Department of the State Administration for Market Regulation and various certification bodies, were used. This data set includes certification data provided by multiple companies.
[0058] Specifically, the steps for creating a large-scale knowledge graph in the industrial domain include: Step 1: Build a general industrial domain ontology library. The data in this ontology library can reflect the general knowledge ontology of the industrial domain. This library is typically generated using Protege software in the OWL format. The ontology library is typically universal and can be used across multiple industry segments. Step 2: Based on a multi-pattern matching mechanism and guided by specific industrial data, the ontology in the general industrial domain ontology library is reconstructed according to the rule base to create a specific industrial domain ontology library. This specific industrial domain ontology library consists of ontologies composed of attributes, relationships, and entities. Step 3: Generate corresponding instances based on the data schema and build the corresponding knowledge graph. This involves establishing a mapping relationship between the ontology and the data schema, and generating corresponding instances based on the data schema to build the initial specific industrial domain knowledge graph. Step 4: Using the initial specific industrial domain knowledge graph, analyze and summarize the specific industrial domain data, expand the rule base, and obtain a newly added and expanded rule base. This step uses SPARQL as a query language to query existing data. Query types include information summarization and data verification. Step 5: Use the newly added extension rules to modify the industrial domain ontology library. In this step, the newly added extension rule library is used to modify the industrial domain general ontology library, and then returns to step 1, thus forming a closed loop of ontology reconstruction.
[0059] For example, the entities in the knowledge graph for the industrial sector include six categories: enterprise, laboratory, inspector, certification body, certificate, and product. The relationships between them include eight types: entrust, delegate, own, inspect, test, certify, submit for review, and include. A query statement might be: "What products are covered by certificate GB9WEX303N029J3K03?"
[0060] In step S110, since only entity links related to the query are predicted in the knowledge graph, that is, the unknown head entity, tail entity, or relationship is found based on the known elements in the query, the answer to the query is only related to a portion of the subgraph in the entire knowledge graph. If the knowledge graph is large, the size of the subgraph is negligible. Therefore, after obtaining the context subgraph related to the query in the knowledge graph, link prediction based on the context subgraph can use fewer resources to calculate the final inference.
[0061] In this embodiment, the search strategy selected based on the query representation to search the knowledge graph includes: when the source entity in the query is unknown, a breadth-limited search or a two-hop proximity search is used to search the knowledge graph; when the target entity in the query is unknown, a reinforcement learning network is used to search the knowledge graph.
[0062] Specifically, when the query is represented as q = (?, r, t), meaning the source entity is unknown, a breadth-first search or a two-hop proximity search can be used. For breadth-first search, first-order sampling is performed along the edges starting from the source entity until a context threshold is reached. For a two-hop proximity search, the sampling set consists of the immediate one-hop neighborhood of the source entity and the edge entities in the two-hop neighborhood.
[0063] Specifically, when the query statement is expressed as q = (h, r, ?), that is, when the target entity is unknown, a reinforcement learning network can be used to search the knowledge graph.
[0064] Furthermore, the reinforcement learning network can adopt the MSURL (Multi-hop Search Using Reinforcement Learning) model and train it using an actor-critic reinforcement learning algorithm. The MSURL model formulates the learning problem as a Markov decision process with a state representation that encodes the dynamics of the search process and a reward structure that minimizes the number of documents that must be processed while still finding a multi-hop path. This method is implemented using an actor-critic reinforcement learning algorithm.
[0065] The above subgraph acquisition method can be used to learn how to navigate the graph to find a predicted path given a query, even in environments where random walking is impractical in an unknown starting node and where there are numerous possible paths from that starting node. Furthermore, when the target entity is unknown, various methods can be used to acquire contextual subgraphs containing known entities. This makes it possible to extract subgraphs relevant to the query within large-scale industrial domain knowledge graphs.
[0066] In step S120, the acquired context subgraph is embedded, and the entity and relationship data in the subgraph are mapped to a lower dimension for subsequent semantic feature extraction. Because entities and relationships in the subgraph represent different semantic information, the entity and relationship data are classified before embedding. Each data in the context subgraph is classified into entity and relationship categories, and then embedded separately.
[0067] Furthermore, when embedding entity and relationship data, multiple types of embeddings are used simultaneously, including word lookup embedding, word type embedding, and word segment embedding. Because entities and relationships represent different semantic information, type embedding is used to facilitate differentiation by the subsequent semantic feature extraction model. Segment embedding indicates whether an entity token corresponds to the tail entity in the path starting from the source entity. This helps the subsequent semantic feature extraction model distinguish tail tokens, which are more likely to correspond to the final answer than other tokens.
[0068] After performing multiple types of embedding on each entity data and relationship data, the different embedded data are superimposed and merged to obtain a static vector table related to the context subgraph.
[0069] Then, in step S130, the static vector table and the query sentence are input into the dual-tower layer based on the multi-head self-attention mechanism, and the query semantic features and the context subgraph semantic features of the static vector table and the query sentence are extracted respectively. The dual-tower layer based on the multi-head self-attention mechanism includes two identical self-attention mechanism units, which perform feature extraction on the static vector table and the query sentence respectively, and obtain the query semantic features and the context subgraph semantic features accordingly.
[0070] In this embodiment, the multi-head self-attention mechanism framework is as follows Figure 2 As shown in Figure 1, it is used as a component in the dual-tower layer based on the multi-head self-attention mechanism. The purpose of using the multi-head attention mechanism is to improve the performance of the attention layer through different levels. On the one hand, it expands the model's ability to pay attention to different unknowns, and on the other hand, it provides multiple representation subspaces for the attention layer, and after training, the embedding is projected into different representation subspaces. Assuming that the subgraph contains m nodes and n edges, the hidden layer L of the subgraph embedding can be expressed as The embedding layer passes through the multi-head self-attention layer formula as follows:
[0071]
[0072]
[0073]
[0074] In formulas (1) to (3), Q k,l , V k,l , O k,l , K k,l They represent the mapping matrix and the final parameters are learned during the training process. n represents the number of attention heads, d k represents the embedding layer dimension, and ⊙ represents concatenation. The query embedding and subgraph adopt the same dual-tower structure, which improves the parallel speed of the model while focusing on its own key points.
[0075] In step S140 , in order to further filter the relevant parts of the context subgraph and the query statement, a cross-attention mechanism is used to fuse the extracted query semantic features and context subgraph semantic features.
[0076] Specifically, the query vector Q comes from the query hidden state, while the key K and value V come from the subgraph hidden state. The output hidden state represents the result of encoding and fusing the subgraph information features relevant to the current query. This is then concatenated with the original contextualized representation of the subgraph, ultimately outputting a feature vector used to predict the plausibility score. represents the query vector of layer L, Expressed as the embedded representation of the subgraph, the cross-attention mechanism process is as follows:
[0077]
[0078]
[0079] In formula (4) and formula (5), Q k,l , V k,l , O k,l , K k,l Represents the mapping matrix, which is learned during the training process to obtain the final parameters. n represents the number of attention heads, d k represents the embedding layer dimension, and ⊙ represents concatenation.
[0080] In step S150 , the final prediction layer predicts the distribution probabilities of all entities in the subgraph according to the fusion features and the query statement to achieve the prediction of entity links.
[0081] In this embodiment, the above-mentioned embedding layer, the dual-tower layer based on the multi-head self-attention mechanism, the feature fusion layer based on the cross-attention mechanism, and the prediction layer are integrated to obtain a knowledge graph link prediction network, such as Figure 3 The knowledge graph to be linked is predicted and the query are input into the knowledge graph link prediction network to obtain the probability distribution of each entity in the context subgraph related to the query in the knowledge graph, so as to achieve link prediction for the knowledge graph.
[0082] When training the entire knowledge graph link prediction network, it can be regarded as training for a classification task, and the loss function used is cross entropy loss.
[0083] In this paper, in order to verify the effectiveness of this method in link prediction of knowledge graphs in the industrial field, a simulation verification of this method is also carried out.
[0084] First, an industry domain knowledge graph is created. The industry domain general ontology library, constructed by various experts, is expanded through intensive discussions among experts to form a general knowledge ontology that reflects the industry domain. This ontology is typically generated using Protege software in the OWL format. The ontology library is typically universal and can be used across multiple industry sub-sectors. Next, based on a multi-pattern matching mechanism and guided by specific industry data, the ontology within the general ontology library is reconstructed according to a rule base to create a specific industry domain ontology library. This specific industry domain ontology library consists of ontologies composed of attributes, relationships, and entities. Based on the data schema, corresponding instances are generated to build the corresponding knowledge graph. A mapping relationship is established between the ontology and the data schema, and corresponding instances are generated based on the data schema to build the initial specific industry domain knowledge graph. This initial specific industry domain knowledge graph is then used to analyze and summarize the specific industry domain data, expanding the rule base to create a newly added and expanded rule base. This part uses SPARQL as a query language to query existing data. Query types include information summarization and data verification. Try to modify the domain ontology library using the newly added extension rules. In this step, the new extension rule library is used to modify the general ontology library in the industrial field, and then return to step 1, thereby forming a closed loop of ontology reconstruction.
[0085] The resulting industrial domain knowledge graph dataset includes certified data from 2 million companies, encompassing over 150 fields and over 50 million records. The domain-specific ontology, generated by experts, contains 282 classes and 305 attributes, mapping all attributes in the raw data to those in the ontology. User information includes user-specified information, such as identifying important entities or other potentially relevant attribute design information.
[0086] We conducted multiple comparative experiments on a self-built industrial dataset (IKGD: Industrial Knowledge Graph Dataset) to demonstrate the effectiveness of the model. We compared it with multiple baseline models, obtained better performance, and analyzed the experimental results.
[0087] Data Preparation: The IKGD dataset is divided into three parts: IKGD-dev, IKGD-train, and IKGD-test, representing the validation set, training set, and test set, respectively. Because the dataset contains both sample datasets with corresponding entities and sample datasets without corresponding entities, we sampled and filtered the samples without corresponding entities. The number of samples in each set after screening is shown in Table 1.
[0088] Table 1 Statistics of the number of samples in the dataset
[0089]
[0090] Evaluation metrics: For each test triple (h, r, t), remove its head entity (?, r, t) or tail entity (h, r, ?) to make it consistent with the link prediction state, and then use the model to make predictions. The evaluation metrics after filtering are used, that is, the ranking of the target entity is not affected by the source entity. In this experimental simulation, the evaluation metrics used are as follows:
[0091]
[0092] In formula (6), MRR (Mean Reciprocal Rank) represents the inverse of the average ranking, where S represents the triple set, rank i Hits@n represents the ranking of the link prediction for each triplet i. Hits@n represents the average proportion of triples ranked less than n in the link prediction. Currently, n takes the values 1, 3, and 10, respectively, represented as Hits@1, Hits@3, and Hits@10.
[0093] Comparative experiment: In this simulation experiment, the following baselines are used for comparison:
[0094] DRUM: The DRUM model is a scalable and differentiable method for mining first-order logic rules from knowledge graphs. It is motivated by establishing a connection between the learned confidence score of each rule and a low-rank tensor approximation. A bidirectional RNN is used to share useful information in the task of learning rules across different relations.
[0095] HRWGE: The model proposes a random walk-based graph embedding algorithm specifically designed for node classification. The algorithm's random walk sampling strategy focuses on nodes that play the most critical role in the overall connectivity of the graph. It is comparable to Node2Vec, the most popular random walk method for generating general graph embeddings.
[34] Compared with the traditional CNN method, the prediction ability of the classification task is significantly improved.
[0096] RGCN: To avoid the bias caused by manual measurement, RGCN uses graph neural networks (GNNs) to automatically extract important features from local information for link prediction.
[0097] HAKE: To facilitate modeling semantic hierarchies, which are common in real-world applications, HAKE maps entities into a polar coordinate system. Radial coordinates are designed to model entities at different levels of the hierarchy; entities with smaller radii are expected to be at higher levels. Angular coordinates are designed to distinguish entities at the same level in the hierarchy; these entities are expected to have roughly the same radius but different angles.
[0098] Relphormer: The model introduces Triple2Seq, which dynamically samples contextualized subgraph sequences as input to alleviate heterogeneity issues. A novel structure-enhanced self-attention mechanism is proposed in the framework to encode relational information and preserve semantic information between entities and relations. This model can be applied to a variety of knowledge graph-based tasks, including knowledge graph generation, question answering, and recommendation.
[0099] LowFER: This model proposes a factorized bilinear pooling model to better fuse entities and relations, resulting in an efficient and unconstrained model.
[0100] Table 2 Comparative experimental results
[0101]
[0102]
[0103] As shown in Table 2, comparative experiments on link prediction tasks using a self-built industrial dataset demonstrate that the current LPBS model outperforms existing baseline methods across all metrics. The LPBS model achieves a mean-recovery (MMR) of 36.2%, nearly 0.5 points higher than the Relphormer model. It achieves a 31.3% hits@1 score, 0.3 points higher than the relatively well-performing Relphormer model. All other metrics achieve state-of-the-art performance. Experimental results show that the traditional path-based approach, DRUM, performs worse than deep learning-based approaches in link prediction tasks due to its inability to capture deep semantic connections between nodes and relationships. However, graph embedding methods based on random walk strategies achieve superior results. Graph convolutional network-based approaches automatically extract features from graph networks, enabling them to capture the connections between individual nodes compared to embedding-based approaches. The RGCN model achieves a MRR of 35.2%, second only to the Relphormer model.
[0104] Ablation experiments: To test the necessity of various components of the LPBS model in this paper, this simulation experiment modified the model using deletion and substitution methods. M-Embedding represents the use of static embedding instead of the three-layer input embedding method proposed in this paper. M-LSTM represents the model that uses LSTM instead of the multi-head attention mechanism in the dual-tower structure. M-BiLSTM represents the model that uses Bi-LSMT instead of the multi-head attention mechanism in the dual-tower structure. M-Cross represents the model that removes the original alternating attention mechanism and directly concatenates the hidden layers. M-org represents the original model proposed in this paper. The experimental results are shown in Table 3.
[0105] Table 3 Ablation experiment results
[0106]
[0107]
[0108] The above ablation experiments demonstrate the necessity of each component of the LPBS model. Removing the embedding layer significantly reduces the expressiveness of the model's hidden layers, with the MRR metric dropping by nearly 8 points. Replacing the multi-head attention mechanism with an LSTM and a bidirectional LSTM, respectively, results in slight decreases in all metrics. However, due to the superior expressiveness of the bidirectional LSTM, the M-BiLSTM performs slightly better than the M-LSTM. Removing the alternating attention mechanism also underperforms the original model on link prediction tasks. Intuitively, the direct concatenation of the node and relationship hidden layers for prediction prevents the model from capturing the connections between components, thus failing to make accurate predictions.
[0109] The aforementioned link prediction method based on subgraph feature fusion employs a reinforcement learning model, MSURL, to design a strategy for obtaining a context set for the predicted link path and performing input encoding. A dual-tower model based on a multi-head attention mechanism then acquires embedding features of the query and subgraph. The quantitative features are then fused using a cross-attention mechanism to obtain the predicted distribution for each node. The MSURL model, as part of the text framework, is interchangeable and serves as a baseline, allowing for flexible exploration and development of different link prediction models. Testing on a self-built industrial dataset demonstrated achievement of MMR (Massive Markov Ranking) metrics of 0.362, Hits@1 (Hits@1) of 0.313, Hits@3 (Hits@3) of 0.426, and Hits@10 (Hits@10) of 0.592. Ablation experiments also demonstrated the model's effectiveness. The proposed framework can be applied to link prediction tasks on large-scale knowledge graphs in fields such as industry and can be extended to open-ended knowledge question answering (KQA) based on large-scale corpora, demonstrating its scalability.
[0110] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0111] In one embodiment, Figure 4 As shown, a link prediction device based on subgraph feature fusion is provided, comprising: a data acquisition module 200, a subgraph acquisition module 210, a static vector table acquisition module 220, a semantic feature extraction module 230, a semantic feature fusion module 240 and a link prediction module 250, wherein:
[0112] The data acquisition module 200 is used to obtain the knowledge graph and query sentence to be used for link prediction;
[0113] A subgraph obtaining module 210 is configured to select a corresponding search strategy according to the representation of the query sentence to search the knowledge graph and obtain a context subgraph related to the query sentence;
[0114] A static vector table obtaining module 220 is configured to input the context subgraph into an embedding layer, use a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and output a static vector table related to the context subgraph;
[0115] A semantic feature extraction module 230 is configured to input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0116] A semantic feature fusion module 240 is configured to input the query semantic feature and the context subgraph semantic feature into a feature fusion layer based on a cross attention mechanism to obtain a semantic fusion feature;
[0117] The link prediction module 250 is used to input the semantic fusion features and the context subgraph semantic features into the prediction layer, and to perform probability distribution of each entity in the context subgraph to achieve link prediction for the knowledge graph.
[0118] For the specific limitations of the link prediction device based on subgraph feature fusion, please refer to the limitations of the link prediction method based on subgraph feature fusion above, which will not be repeated here. The various modules in the above-mentioned link prediction device based on subgraph feature fusion can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0119] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a link prediction method based on subgraph feature fusion is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0120] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0121] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0122] Obtain the knowledge graph and query sentence for link prediction;
[0123] Selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph to obtain a context subgraph related to the query sentence;
[0124] Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph;
[0125] Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0126] Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features;
[0127] The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0128] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0129] Obtain the knowledge graph and query sentence for link prediction;
[0130] Selecting a corresponding search strategy according to the representation of the query sentence to search the knowledge graph to obtain a context subgraph related to the query sentence;
[0131] Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph;
[0132] Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively;
[0133] Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features;
[0134] The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is performed to achieve link prediction of the knowledge graph.
[0135] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0136] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0137] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A link prediction method based on subgraph feature fusion, characterized in that: The method comprises: Obtain the knowledge graph and query sentence for link prediction; Selecting a corresponding search strategy according to the representation of the query to search the knowledge graph to obtain a context subgraph related to the query, wherein selecting a corresponding search strategy according to the representation of the query to search the knowledge graph includes: when a source entity in the query is unknown, using a breadth-limited search or a two-hop proximity search to search the knowledge graph; when a target entity in the query is unknown, using a reinforcement learning network to search the knowledge graph; Inputting the context subgraph into an embedding layer, using a word embedding method in the embedding layer to learn all entity and relationship information in the context subgraph, and outputting a static vector table related to the context subgraph; Input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract the query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively; Inputting the query semantic features and the context subgraph semantic features into a feature fusion layer based on a cross attention mechanism to obtain semantic fusion features; The semantic fusion features and the context subgraph semantic features are input into the prediction layer, and the probability distribution of each entity in the context subgraph is predicted to achieve link prediction of the knowledge graph.
2. The link prediction method according to claim 1, wherein: The reinforcement learning network adopts the MSURL model, and the actor-critic reinforcement learning algorithm is used to train the MSURL model.
3. The link prediction method according to claim 1, wherein: After the context subgraph is input into the embedding layer, the context subgraph is first classified according to the subject and relationship, and then word lookup embedding, word type embedding and word segment embedding are performed respectively. The obtained embedding data are merged into a static vector table related to the context subgraph.
4. The link prediction method according to claim 1, wherein: The dual-tower layer based on the multi-head self-attention mechanism includes two identical self-attention mechanism units, which respectively extract features from the static vector table and the query sentence, and correspondingly obtain the query semantic features and the context subgraph semantic features.
5. The link prediction method according to any one of claims 1 to 4, characterized in that: The embedding layer, the dual-tower layer based on the multi-head self-attention mechanism, the feature fusion layer based on the cross-attention mechanism, and the prediction layer are integrated into a knowledge graph link prediction network; The knowledge graph to be linked is predicted and the query sentence are input into the knowledge graph link prediction network to obtain the probability distribution of each entity in the context subgraph related to the query sentence in the knowledge graph to achieve link prediction for the knowledge graph.
6. A link prediction device based on subgraph feature fusion, characterized in that: The device comprises: The data acquisition module is used to obtain the knowledge graph and query sentences for link prediction; a subgraph obtaining module, configured to select a corresponding search strategy based on the representation of the query sentence to search the knowledge graph, and obtain a context subgraph related to the query sentence, wherein selecting a corresponding search strategy based on the representation of the query sentence to search the knowledge graph includes: when the source entity in the query sentence is unknown, using a breadth-limited search or a two-hop proximity search to search the knowledge graph; when the target entity in the query sentence is unknown, using a reinforcement learning network to search the knowledge graph; a static vector table obtaining module, configured to input the context subgraph into an embedding layer, learn all entity and relationship information in the context subgraph using a word embedding method in the embedding layer, and output a static vector table related to the context subgraph; A semantic feature extraction module is used to input the static vector table and the query sentence into a dual-tower layer based on a multi-head self-attention mechanism, and extract query semantic features and context subgraph semantic features of the static vector table and the query sentence respectively; A semantic feature fusion module is used to input the query semantic feature and the context subgraph semantic feature into a feature fusion layer based on a cross attention mechanism to obtain a semantic fusion feature; The link prediction module is used to input the semantic fusion features and the context subgraph semantic features into the prediction layer, and predict the probability distribution of each entity in the context subgraph to achieve link prediction for the knowledge graph.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to claim 5 are implemented.
Citation Information
Patent Citations
Event reasoning method and device
CN114357197A
Knowledge graph question and answer method and system based on Sparql statement generation
CN115827844A