Graph embedding method and system based on semantic attributes of knowledge graph nodes
By obtaining entity semantic information and sentence feature matrices, a graph embedding model is designed to predict the relationships between entities in the knowledge graph, which solves the problem of failure to fully utilize entity information in the existing technology and achieves accurate completion and application of the knowledge graph.
Patent Information
- Application Number
- CN202210080718.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-24
- Publication Date
- 2024-08-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing graph embedding models have uncertainties in predicting entities and relationships in knowledge graphs and fail to make full use of entity information, making it difficult for head vectors and relationship vectors to accurately predict the relationships between entities, affecting the completion effect of knowledge graphs.
By obtaining the semantic information of the entity, the word embedding method is used to obtain the semantic feature vector of the node attribute information, combined with the sentence feature extraction method to form a semantic feature matrix, and the model is designed to predict the edges to complete the knowledge graph. Specific steps include the convolution operator to extract the relationship between words, maximum pooling, residual calculation, projection operation, and finally the calculation of the edge probability between entities.
Make full use of node attribute information to effectively predict relationships between entities, improving the completion accuracy and application effect of knowledge graphs.
Smart Images

Figure CN114491070B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph embedding technology, and in particular to a graph embedding method and system based on semantic attributes of knowledge graph nodes. Background Art
[0002] Knowledge graphs have emerged in recent years and have been widely used in information search, e-commerce and other fields because they can quickly describe the relationships between different entities in life. Knowledge graphs need to go through a process from scratch, and a complete graph cannot be obtained at the beginning. New knowledge needs to be acquired continuously and it needs to be completed when it is used. When completing the knowledge graph, since the graph is composed of nodes and edges, in order to better solve the problem that graph data is difficult to efficiently input into machine learning algorithms, the graph data needs to be embedded in the graph first.
[0003] Graph embedding converts the attribute graph into a vector or vector set, and embeds the graph nodes into a low-dimensional continuous space for representation. A good graph embedding can effectively represent the graph structure, fully represent the node information, help predict the edges between nodes, and then help complete the knowledge graph, so as to better apply the knowledge graph to practical fields.
[0004] Knowledge graphs are usually represented by triplets (head, relation, tail), and current graph embedding models use the sum of the head vector and the relation vector to predict the tail vector, which embeds entities and relations into the point vector space. However, there may be uncertainty between entities and relations. It is difficult for the head vector and the relation vector to accurately predict the relationship between the head and the tail, and there is also a defect that the entity information is not fully utilized. Summary of the invention
[0005] In response to the above-mentioned defects, the purpose of the present invention is to propose a graph embedding method and system based on the semantic attributes of knowledge graph nodes, which can predict the relationship between two entities by directly obtaining the semantic information of the entities, and make full use of the attribute information of the nodes to effectively help complete the knowledge graph.
[0006] To achieve this object, the present invention adopts the following technical solutions:
[0007] The graph embedding method based on the semantic attributes of knowledge graph nodes includes the following steps:
[0008] A. Collect user information and product information from the shopping mall, format the acquired text information, store it, and archive it for backup;
[0009] B. Taking user information and product information as nodes, the word embedding method is used to obtain the semantic feature vector of node attribute information;
[0010] C. Use sentence feature extraction method to sort the above semantic feature vectors to form a sentence semantic feature matrix;
[0011] D. Design and build models based on semantic feature vectors and semantic feature matrices;
[0012] E. Predict edges based on the model and complete the knowledge graph.
[0013] Preferably, the model design and construction in step D includes the following contents:
[0014] d1. Use six convolution operators of different sizes to extract the relationship between words in sentences, obtain six corresponding feature matrices, and connect the six feature matrices; then perform the maximum pooling operation to obtain the first feature vector;
[0015] d2. Calculate the residual of the first eigenvector to obtain a second eigenvector, add the first eigenvector to the second eigenvector to obtain a third eigenvector;
[0016] d3. Perform coarse-grained projection and fine-grained projection on the third eigenvector to obtain a fourth eigenvector;
[0017] d4. Apply three convolution operators of the same size to perform residual calculation on the fourth eigenvector again to obtain the fifth eigenvector;
[0018] d5. Perform random dropout and hyperplane projection on the fifth eigenvector.
[0019] Preferably, the step d1 includes operations on user information, specifically including the following contents:
[0020] Definition M head is the semantic feature matrix of user information, M tail is the semantic feature matrix of product information, M head The size after convolution calculation is (Q, 768), where Q∈{2, 3, 4, 5, 6, 7}, and six feature matrices are obtained as follows:
[0021] C q =Cov q (M head ),q∈{2,3,4,5,6,7};
[0022] Among them, q means extracting the relationship between q words;
[0023] After concatenating these six feature matrices and performing the maximum pooling operation, the first eigenvector is obtained:
[0024] O cov=MaxPool([C2;C3;...;C7]);
[0025] Similarly, for M tail Convolution calculation, matrix concatenation and maximum pooling are performed in sequence to obtain the corresponding feature vector.
[0026] Preferably, in the step d2, the first eigenvector is subjected to residual calculation to obtain a second eigenvector, and the first eigenvector is added to the second eigenvector to obtain a third eigenvector:
[0027] O COV :=O COV +LN(w cov *O cov +b cov ),
[0028] Where LN is the layer normalization operation, w cov and b cov is the weight parameter.
[0029] Preferably, the steps d3 and d4 specifically include the following contents:
[0030] The third eigenvector is coarse-grained projected and fine-grained projected as follows:
[0031] O low =w l ' ow *(w low *O low +b low )+b l ' ow ;
[0032] Among them, w low and b low is the weight parameter and bias of the coarse-grained projection, w' low and b' low are the weight parameters and biases of fine-grained projection;
[0033] At the same time, after residual calculation, it is as follows:
[0034]
[0035] Among them, σ is the sigmoid function, Cov is the convolution operator, and LN is the normalization operation.
[0036] Preferably, the step d5 specifically includes the following contents:
[0037] O low Projected into the hyperplane space, as follows:
[0038] Oe =w hp *O low +b hp ;
[0039] Among them, w hp and b hp represents the weight parameters and bias in the hyperplane space.
[0040] Preferably, predicting edges and completing the knowledge graph in step E includes the following:
[0041] e1. Store the above entities in set O kg In, O kg = {O e |e∈E};
[0042] e2. Calculate the probability P that there is an edge between entity head and entity tail ht :P ht =w lc *([σ(O h );σ(O t )])+b lc , where the entity head corresponds to user information and the entity tail corresponds to product information; lc and b lc is the weight parameter and bias of edge prediction, σ is the sigmoid activation function, O h and O t It is the feature vector of entity head and entity tail projected onto the same hyperplane.
[0043] A graph embedding system based on the semantic attributes of knowledge graph nodes, including a data acquisition module, a preprocessing module, a feature extraction module, an embedding generation module and a connection module;
[0044] The data collection module is used to collect user information and product information of the shopping mall, format the acquired text information, store it, and archive it for backup;
[0045] The preprocessing module is used to obtain the semantic feature vectors of the node attribute information, and compose the semantic feature vectors into a semantic feature matrix of the sentence;
[0046] The feature extraction module is used to perform convolution calculation, connect feature matrix and maximum pooling;
[0047] The embedding generation module is used to perform coarse-grained projection and fine-grained projection;
[0048] The connection module is used to calculate the probability of an edge between two entities to predict the edge.
[0049] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the graph embedding method based on semantic attributes of knowledge graph nodes as described above are implemented.
[0050] A non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the graph embedding method based on semantic attributes of knowledge graph nodes as described above.
[0051] The above technical solution has the following beneficial effects:
[0052] This embodiment makes full use of the attribute information of the nodes and can predict whether the two entities are related by extracting the entity attribute information, that is, predicting the relation by obtaining the semantic information of the head and tail of the knowledge graph, thereby achieving the effect of predicting edges and completing the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a schematic diagram of the overall process of an embodiment of the present invention;
[0054] Figure 2 It is a flow chart of model design and construction in step D of an embodiment of the present invention. DETAILED DESCRIPTION
[0055] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0056] In the description of the present invention, it is necessary to understand that the terms "longitudinal", "transverse", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, features defined as "first" or "second" may explicitly or implicitly include one or more of the features, and are used to distinguish and describe features, without distinction of order or importance.
[0057] In the description of the present invention, unless otherwise specified, "plurality" means two or more.
[0058] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0059] Combine the following Figure 1 to Figure 2 Describe the graph embedding method and system based on the semantic attributes of knowledge graph nodes according to an embodiment of the present invention:
[0060] The graph embedding method based on the semantic attributes of knowledge graph nodes includes the following steps:
[0061] A. Collect user information and product information from the shopping mall, format the acquired text information, store it, and archive it for backup;
[0062] B. Taking user information and product information as nodes, the word embedding method is used to obtain the semantic feature vector of node attribute information;
[0063] C. Use sentence feature extraction method to sort the above semantic feature vectors to form a sentence semantic feature matrix;
[0064] D. Design and build models based on semantic feature vectors and semantic feature matrices;
[0065] E. Predict edges based on the model and complete the knowledge graph.
[0066] Specifically, this embodiment makes full use of the attribute information of the nodes and can predict whether two entities are related by extracting the entity attribute information, that is, predicting the relation by obtaining the semantic information of the head and tail of the knowledge graph, thereby achieving the effect of predicting edges and completing the knowledge graph.
[0067] Specifically, in this embodiment, by writing a crawler program or using an existing data collection tool, the following two types of data are collected in batches: user information of the shopping mall, including: user gender, purchase history, favorites, etc.; product information of the shopping mall, including: product name, price, type, product description, etc. The collected user information and product information are all text information, and the above acquired text information is formatted and stored in txt text, and the above data is archived and backed up.
[0068] The user information and product information obtained above are used as the head and tail of the knowledge graph respectively. Since the semantic features of the entity are helpful for link prediction in the subsequent steps, it is necessary to obtain the semantic feature vector of each word in the information, and combine the semantic feature vectors of these words into a semantic feature matrix of a sentence. In this embodiment, the semantic feature vector of each word in the information is obtained by BERT embedding, and one-hot, word2vec and other word embedding methods can also be used, as shown in the following formula:
[0069] M head =BERT(s head )
[0070] M tail =BERT(s tail )
[0071] Among them, s head 、s tail are user information and product information respectively, M head and M tail are the semantic feature matrices of user information and product information respectively. Since the feature vector length of each word is 768 and the dimension of BERT is 512, a 512*768 semantic feature matrix will be generated, that is, M head and M tail It is a 512*768 semantic feature matrix.
[0072] Preferably, the model design and construction in step D includes the following contents:
[0073] d1. Use six convolution operators of different sizes to extract the relationship between words in sentences, obtain six corresponding feature matrices, and connect the six feature matrices; then perform the maximum pooling operation to obtain the first feature vector;
[0074] d2. Calculate the residual of the first eigenvector to obtain a second eigenvector, add the first eigenvector to the second eigenvector to obtain a third eigenvector;
[0075] d3. Perform coarse-grained projection and fine-grained projection on the third eigenvector to obtain a fourth eigenvector;
[0076] d4. Apply three convolution operators of the same size to perform residual calculation on the fourth eigenvector again to obtain the fifth eigenvector;
[0077] d5. Perform random dropout and hyperplane projection on the fifth eigenvector.
[0078] Specifically, the maximum pooling operation is to select the maximum value in the matrix. The maximum pooling operation is used to prevent the feature matrix after connection from overfitting. At the same time, in order to prevent the gradient from disappearing, the vector must be obtained through residual calculation and then added to the original vector. Since the length of the vector generated above is too large, in order to reduce the complexity of subsequent calculations, the vector needs to be coarse-grained and fine-grained projected. At the same time, in order to prevent the gradient from disappearing, the residual calculation is further performed. Finally, in order to avoid overfitting, a dropout operation is required, that is, the vector obtained by the residual calculation needs to be projected into the hyperplane space. In this embodiment, a dense CNN module is used for residual calculation, which can keep the dimension of the vector unchanged by splicing an element at each end of the vector and then using a convolution operator to extract features.
[0079] Preferably, the step d1 includes operations on user information, specifically including the following contents:
[0080] Definition M head is the semantic feature matrix of user information, M tail is the semantic feature matrix of product information, M head The size after convolution calculation is (Q, 768), where Q∈{2, 3, 4, 5, 6, 7}, and six feature matrices are obtained as follows:
[0081] C q =Cov q (M head ),q∈{2,3,4,5,6,7};
[0082] Among them, q means extracting the relationship between q words;
[0083] After concatenating these six feature matrices and performing the maximum pooling operation, the first eigenvector is obtained:
[0084] O cov =MaxPool([C2;C3;...;C7]);
[0085] Similarly, for M tail Convolution calculation, matrix concatenation and maximum pooling are performed in sequence to obtain the corresponding feature vector.
[0086] Preferably, in the step d2, the first eigenvector is subjected to residual calculation to obtain a second eigenvector, and the first eigenvector is added to the second eigenvector to obtain a third eigenvector:
[0087] O COV :=O COV +LN(w cov *O cov +b cov ),
[0088] Where LN is the layer normalization operation, w cov and b cov is the weight parameter.
[0089] Preferably, the steps d3 and d4 specifically include the following contents:
[0090] The third eigenvector is coarse-grained projected and fine-grained projected as follows:
[0091] O low =w l ' ow *(w low *O low +b low )+b l ' ow ;
[0092] Among them, w low and b low is the weight parameter and bias of the coarse-grained projection, w' low and b' low are the weight parameters and biases of fine-grained projection;
[0093] At the same time, in order to prevent the gradient from disappearing, residual calculation is also required, as shown below:
[0094]
[0095] Among them, σ is the sigmoid function, Cov is the convolution operator, and LN is the normalization operation.
[0096] Preferably, the step d5 specifically includes the following contents:
[0097] O low Projected into the hyperplane space, as follows:
[0098] O e =w hp *O low +b hp ;
[0099] Among them, w hp and b hp represents the weight parameters and bias in the hyperplane space.
[0100] Preferably, predicting edges and completing the knowledge graph in step E includes the following:
[0101] e1. Store the above entities in set O kg In, O kg = {O e |e∈E};
[0102] e2. Calculate the probability P that there is an edge between entity head and entity tail ht :P ht =w lc *([σ(O h );σ(O t )])+b lc , where the entity head corresponds to user information and the entity tail corresponds to product information; lc and b lc is the weight parameter and bias of edge prediction, σ is the sigmoid activation function, O h and O t It is the feature vector of entity head and entity tail projected onto the same hyperplane.
[0103] This embodiment also discloses a graph embedding system based on semantic attributes of knowledge graph nodes, including a data acquisition module, a preprocessing module, a feature extraction module, an embedding generation module and a connection module;
[0104] The data collection module is used to collect user information and product information of the shopping mall, format the acquired text information, store it, and archive it for backup;
[0105] The preprocessing module is used to obtain the semantic feature vectors of the node attribute information, and compose the semantic feature vectors into a semantic feature matrix of the sentence;
[0106] The feature extraction module is used to perform convolution calculation, connect feature matrix and maximum pooling;
[0107] The embedding generation module is used to perform coarse-grained projection and fine-grained projection;
[0108] The connection module is used to calculate the probability of an edge between two entities to predict the edge.
[0109] This embodiment also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the graph embedding method based on semantic attributes of knowledge graph nodes as described above are implemented.
[0110] This embodiment also discloses a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the graph embedding method based on semantic attributes of knowledge graph nodes as described above are implemented.
[0111] The graph embedding method based on semantic attributes of knowledge graph nodes and other structures and operations of the system according to the embodiment of the present invention are well known to ordinary technicians in the field and will not be described in detail here.
[0112] Each module in the graph embedding system based on the semantic attributes of knowledge graph nodes can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in the memory of an electronic device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0113] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and 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 may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many 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).
[0114] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0115] The above description of the specific embodiments of the present invention is only for illustrating the technical route and features of the present invention, and its purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly, but the present invention is not limited to the above specific implementation methods. Any changes or modifications made within the scope of the claims of the present invention should be included in the protection scope of the present invention.
Claims
1. A graph embedding method based on the semantic attributes of knowledge graph nodes, characterized by: The steps include: A. Collect user information and product information from the shopping mall, format the acquired text information, store it, and archive it for backup; B. Taking user information and product information as nodes, the word embedding method is used to obtain the semantic feature vector of node attribute information; C. Use sentence feature extraction method to sort the above semantic feature vectors to form a sentence semantic feature matrix; D. Design and build models based on semantic feature vectors and semantic feature matrices, including: d1. Use six convolution operators of different sizes to extract the relationship between words in sentences, and obtain six feature matrices accordingly. Then connect the six feature matrices; then perform the maximum pooling operation to obtain the first feature vector, which is: Definition M head is the semantic feature matrix of user information, M tail is the semantic feature matrix of product information, M head The size after convolution calculation is (Q, 768), where Q∈{2, 3, 4, 5, 6, 7}, and six feature matrices are obtained as follows: C q =Cov q (M head ), q∈{2,3,4,5,6,7}; Among them, q means extracting the relationship between q words; After concatenating these six feature matrices and performing the maximum pooling operation, the first eigenvector is obtained: About cov =MaxPool([C2;C3;...;C7]); Similarly, for M tail Perform convolution calculation, matrix concatenation and maximum pooling in sequence to obtain the corresponding feature vector; d2. Calculate the residual of the first eigenvector to obtain a second eigenvector, add the first eigenvector to the second eigenvector to obtain a third eigenvector, specifically: O COV :=O COV +LN(w cov *O cov +b cov ), Where LN is the layer normalization operation, w cov and b cov is the weight parameter; d3. Perform coarse-grained projection and fine-grained projection on the third eigenvector to obtain a fourth eigenvector; d4. Apply three convolution operators of the same size to perform residual calculation on the fourth eigenvector again to obtain the fifth eigenvector; The steps d3 and d4 specifically include the following contents: The third eigenvector is coarse-grained projected and fine-grained projected as follows: O low =w′ low *(w low *O low +b low )+b′ low ; Among them, w low and b low is the weight parameter and bias of the coarse-grained projection, w′ low and b′ low are the weight parameters and biases of fine-grained projection; At the same time, after residual calculation, it is as follows: Among them, σ is the sigmoid function, Cov is the convolution operator, and LN is the normalization operation; d5. Perform random inactivation and hyperplane projection on the fifth eigenvector, specifically: O low Projected into the hyperplane space, as follows: O e =w hp *O low +b hp ; Among them, w hp and b hp Represents weight parameters and biases in the hyperplane space; E. Predict edges based on the model and complete the knowledge graph, including: e1. Store the above entities in set O kg In, O kg = {O e |e∈E}; e2. Calculate the probability P that there is an edge between entity head and entity tail ht :P ht =w lc *([σ(O h );σ(O t )])+b lc , where the entity head corresponds to user information and the entity tail corresponds to product information; lc and b lc is the weight parameter and bias of edge prediction, σ is the sigmoid activation function, O h and O t It is the feature vector of entity head and entity tail projected onto the same hyperplane.
2. A graph embedding system based on semantic attributes of knowledge graph nodes, using the graph embedding method based on semantic attributes of knowledge graph nodes according to claim 1, characterized in that: It includes a data acquisition module, a preprocessing module, a feature extraction module, an embedding generation module and a connection module; The data collection module is used to collect user information and product information of the shopping mall, format the acquired text information, store it, and archive it for backup; The preprocessing module is used to obtain the semantic feature vectors of the node attribute information and compose the semantic feature vectors into a semantic feature matrix of the sentence; The feature extraction module is used to perform convolution calculation, connect feature matrix and maximum pooling; The embedding generation module is used to perform coarse-grained projection and fine-grained projection; The connection module is used to calculate the probability of an edge between two entities to predict the edge.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, it implements the steps of the graph embedding method based on the semantic attributes of knowledge graph nodes as described in claim 1.
4. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the graph embedding method based on semantic attributes of knowledge graph nodes as described in claim 1 are implemented.
