A knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph
By using the heterogeneous graph attention network model in industrial machinery fault diagnosis, the problem of missing relationships in the knowledge graph is solved, efficient fault knowledge discovery and reasoning is achieved, and the accuracy and efficiency of fault diagnosis are improved.
Patent Information
- Application Number
- CN202111265289.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2041-10-28
AI Technical Summary
The existing knowledge graphs have serious problems with the lack of inter-entities in industrial machinery fault diagnosis, and insufficient computing efficiency and data sparsity, making it difficult to achieve efficient fault knowledge discovery and reasoning.
Using a knowledge reasoning method based on heterogeneous graph attention network, the knowledge structure and graph structure information of the knowledge graph triplet are retained, and the graph neural network is used for end-to-end learning to realize fault knowledge entity classification and link prediction.
Improve the accuracy of fault knowledge entity classification and link prediction, assisting engineers to quickly build industrial fault diagnosis knowledge graphs, and recommend fault causes and solutions.
Smart Images

Figure CN113961718B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of mechanical fault diagnosis, and relates to the technical field of knowledge reasoning based on a knowledge graph, in particular to a knowledge reasoning method based on an industrial mechanical fault diagnosis knowledge graph. Background Art
[0002] A knowledge graph aims to describe concepts, entities, events in the objective world and the relationships among them. Essentially, it is a semantic network that precipitates objective experience in a huge network. The knowledge graph expresses the information on the Internet in a form closer to the human cognitive world, providing an ability to better organize, manage, and understand the vast amount of information on the Internet. The core content of the knowledge graph is similar to that of a knowledge base, except that there are slightly differences in the presentation form. When it comes to structural information, the knowledge graph can be regarded as a graph; when it comes to formal semantics, it can be used as a knowledge base for explaining and inferring facts. The emergence of the knowledge graph has changed the traditional knowledge acquisition mode, transforming the "top-down" approach of knowledge engineering into a "bottom-up" approach of mining data and extracting knowledge. After long-term theoretical innovation and practical exploration, the knowledge graph already has systematic construction and reasoning methods.
[0003] The knowledge graph extracts, organizes, and manages knowledge from a large number of data resources. However, most of the relationships between knowledge graphs are incomplete, and the relationship between entities is seriously missing. Therefore, the knowledge reasoning technology emerges as the times require. This technology can deduce new relationships between entities from a given knowledge graph, further complete knowledge discovery, and thus complete in-depth analysis and reasoning of data. The core of realizing knowledge reasoning is knowledge representation. Although the knowledge representation form of knowledge graph triples has been widely recognized by people, it faces many problems in terms of computational efficiency, data sparsity, etc. In recent years, learning technologies represented by deep learning have made important progress, which can represent the semantic information of entities as dense low-dimensional real-valued vectors, and then efficiently calculate the complex semantic associations between entities, relationships and them in the low-dimensional space, which is of great significance for the construction, reasoning, fusion and application of knowledge bases.
[0004] Based on this background, engineering personnel need to explore a knowledge interconnection method that not only conforms to the development and changes of network information resources but also meets the user's needs from a new perspective according to the knowledge organization principle in the new era's big data environment, and reveals the overall relevance of human cognition at a deeper level. Therefore, the industrial community and the academic community have begun to actively introduce knowledge graph technology into the field of fault diagnosis. With the help of knowledge graph technology, engineering personnel can easily locate and solve various faults that occur during the operation of industrial equipment, and can simulate an expert system to realize automatic analysis and diagnosis of faults. Therefore, it is particularly important to establish a real-time agile, flexible and scalable, intelligent and adaptive dynamic fault diagnosis knowledge graph. Summary of the Invention
[0005] The object of the present invention is to overcome the defects of the prior art and provide a knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph. This method constructs an industrial machinery fault diagnosis knowledge graph and conducts new graph neural network-based knowledge reasoning for the industrial machinery fault diagnosis knowledge graph. Based on the heterogeneous graph attention network model, this method innovatively retains the knowledge structure of the knowledge graph triples and the graph structure information of the knowledge graph as a graph data structure, and can learn the entity embedding representation in the industrial machinery fault diagnosis knowledge graph in an end-to-end learning manner, so as to complete two downstream tasks of fault knowledge entity classification and fault knowledge link prediction.
[0006] To solve the above technical problems, the present invention adopts the following technical solutions.
[0007] A knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph of the present invention includes the following steps:
[0008] Step 1, data cleaning stage: collect and clean the fault condition data of a certain industrial machinery; create structured fault knowledge triples;
[0009] Step 2, data processing stage: create word embedding representations of fault entities and fault relationships and a heterogeneous industrial machinery fault diagnosis knowledge graph according to the structured fault knowledge triples;
[0010] Step 3, graph display stage: visually display the constructed industrial machinery fault diagnosis knowledge graph through the Neo4j graph database based on Python and the Py2neo library;
[0011] Step 4, model construction and training stage: construct a knowledge graph heterogeneous graph attention network model; train the model to obtain the embedding representation of entities in the industrial machinery fault diagnosis knowledge graph;
[0012] Step 5, task verification stage: complete the fault knowledge entity classification task and the fault knowledge link prediction task to realize the knowledge reasoning of the industrial machinery fault diagnosis knowledge graph.
[0013] Further, the data cleaning stage of step 1 includes:
[0014] Step 1.1, cleaning the fault condition data: extract the fault entities and fault knowledge triple data in the fault condition data with regular expressions, and remove redundant punctuation marks and auxiliary description information;
[0015] Step 1.2. Create structured fault knowledge triples: Screen fault knowledge triples according to the corresponding relationships between fault entities. The specific form is: (head entity, relationship, tail entity), briefly denoted as: (h, r, t).
[0016] 3. According to a knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph described in claim 1, it is characterized in that in the data processing stage of the said step 2, it specifically includes:
[0017] Step 2.1. Create word embedding representations of fault entities and fault relationships: Arrange the cleaned fault condition data into a list with each Chinese character and sort it in ascending order according to the Unicode encoding method. Encode each fault entity and fault relationship according to the Chinese character list and the number of Chinese characters. The encoded vector is used as its word embedding representation;
[0018] Step 2.2. Create a heterogeneous industrial machinery fault diagnosis knowledge graph: Store the heterogeneous industrial machinery fault diagnosis knowledge graph based on the graph data structure in the graph neural network framework DGL.
[0019] Further, in the graph display stage of the said step 3, it specifically includes:
[0020] Step 3.1. Construct an industrial machinery fault diagnosis knowledge graph: Based on Python and the Py2neo library, construct the fault knowledge triples into an industrial machinery fault diagnosis knowledge graph;
[0021] Step 3.2. Visualization of the knowledge graph: Perform visual display through the Neo4j graph database, and be able to implement graph search algorithms for adding, deleting, and searching various industrial fault data through Python scripts.
[0022] Further, in the model construction and training stage of step 4, a knowledge graph heterogeneous graph attention network KGHAN model is proposed based on the heterogeneous graph attention network HAN, which specifically includes:
[0023] Step 4.1. Construct a knowledge graph heterogeneous graph attention network model: Based on the heterogeneous graph attention network HAN, a knowledge graph heterogeneous graph attention network KGHAN model is proposed; on the basis of the heterogeneous graph attention network model, it retains the knowledge structure of the knowledge graph triples and the graph structure information owned by the knowledge graph as a graph data structure, and can learn the entity embedding representation in the industrial machinery fault diagnosis knowledge graph in an end-to-end learning manner; the KGHAN model adopts the following design:
[0024] (1) Knowledge information fusion layer: In order to retain the original knowledge triple structure of the knowledge graph, fuse the embedding vector representations of the knowledge graph translation model TransD;
[0025] The TransD model learns the embedded vector representations of each entity and relationship in the knowledge graph by optimizing the TransE translation model. It uses two vectors to represent each entity and relationship. The first vector represents the meaning of the entity or relationship, and the other vector, called the projection vector, is used to construct the mapping matrix. The mapping matrices of the head entity and the tail entity are defined as:
[0026]
[0027]
[0028] Among them, is the mapping matrix of the head and tail entities, r i (0) is the initialized relationship embedded vector, are the initialized head and tail entity embedded vectors, m is the dimension of the relationship embedded vector, n is the dimension of the head and tail entity embedded vectors, is the identity matrix, and m×n is the shape of the identity matrix;
[0029] After that, the embedded vectors of the entities are mapped into the corresponding relationship embedded vector space through the mapping matrix. The formulas for the embedded vectors of the head entity and the tail entity mapped into the relationship space are defined as:
[0030]
[0031]
[0032] Among them, are the updated head and tail entity embedded vectors;
[0033] To evaluate the correlation between the embedded vectors of the head entity and the tail entity, the vector distance error is defined as s i ; The reputation score formula f of the updated triple ri is defined as follows:
[0034]
[0035] Among them, is the square operation of a vector two-norm;
[0036] To optimize the training process, in the knowledge graph embedding layer, the correct triple is randomly replaced with the head and tail entities to achieve negative sample sampling. The wrong triple is defined as The vector distance error is s i ′; The training loss function L adopts the Margin loss function, and its formula is defined as:
[0037]
[0038] Among them, γ is the margin between the correct triple score and the incorrect triple score, and max(x, y) is the operation of taking the maximum value between x and y;
[0039] Finally, the embedded vectors of the trained entities and relationships are added to the word embedding representation of the nodes as input; the fused word embedding representation of the nodes is defined as:
[0040]
[0041] Among them, is the word embedding representation after fusing knowledge information, is the word embedding representation described in step 2.1, is the embedding representation of the i-th node, that is, the head entity embedding vector and the tail entity embedding vector of the set, || is the vector concatenation operation;
[0042] (2) Graph structure information fusion layer: In order to retain the graph structure information of the knowledge graph as a graph data structure, the degrees of the nodes in the graph are fused;
[0043] In the KGHAN model, the degree vector of each entity is used as an additional signal for the embedded representations of entities and relationships, that is: entity centrality encoding is added, and two real-valued embedding vectors are assigned to each entity according to the in-degree and out-degree of the entity; since the entity centrality encoding is applied to each entity, it is only necessary to add it to the word embedding representation of the entity as input; the fused embedded representation of the entity is defined as:
[0044]
[0045] Among them, x i is the embedded representation of the i-th entity after fusing the graph structure information, is the embedded representation after fusing knowledge information, || is the vector concatenation operation, is the in-degree vector of this entity, is the out-degree vector of this entity;
[0046] (3) Heterogeneous graph attention network layer: This layer simultaneously includes node-level attention and semantic-level attention. Node-level attention mainly learns the weights between an entity and its neighboring entities, and semantic-level attention is used to learn the weights based on different meta-paths; thanks to this hierarchical attention, the importance of neighbor entities and meta-paths can be considered simultaneously;
[0047] a) Node-level attention:
[0048] A knowledge graph is a typical heterogeneous graph, which can be represented as G=(V, E), consisting of an entity set V and a relationship set E; the knowledge graph is also associated with an entity type mapping function φ: V→A and a relationship type mapping function E→B; A and B represent sets of predefined entity types and relationship types, where ||A||+||B||≥2; in a heterogeneous graph, two entities of different types can be associated through different semantic paths, and this semantic path is called a meta-path, which can be defined as where A1, A2, …, A l+1 are entities on a meta-path, and R1, R2, …, R l are relationships on a meta-path;
[0049] Here, node-level attention is introduced to aggregate the meta-path neighbor information of each entity, thereby learning the importance of neighbor entities based on the meta-path for each entity in the knowledge graph, and aggregating the representations of these neighbors to form the embedding representation of the entity; for each type of entity, a specific type of transformation matrix is designed to project the embedding representations of different types of entities into the same embedding space; the projection formula is defined as:
[0050]
[0051] where x′ i is the projected entity embedding representation, is the transformation matrix of the type to which the i-th entity belongs, and x i is the embedding representation of the entity after fusing knowledge information and graph structure information;
[0052] After that, the self-attention mechanism is used to learn the weights between various entities; given an entity pair (i, j) connected by a meta-path Φ, then the weight coefficient can be used to represent the importance of j to i, and its formula is defined as:
[0053]
[0054] where attn node is a deep neural network for calculating node-level attention, x i ′, x′ j are the projected entity embedding representations, and Φ is the meta-path from entity j to entity i;
[0055] Thus, in the entity pair (i, j) based on the meta-path, the attention coefficient of entity j to entity i is defined by the formula:
[0056]
[0057] Among them, σ is the activation function, and the LeakyReLU non-linear function is adopted. is the set of neighbor entities of the i-th entity, and exp(x) represents the mathematical operation e x , || is the vector concatenation operation. is the transpose of the mapping vector.
[0058] Then, the embedding representation of entity i based on the meta-path can be aggregated by the projection of the embedding representations of its neighbor entities and the corresponding attention coefficients, and its formula is defined as:
[0059]
[0060] Among them, is the embedding representation learned by entity i corresponding to the meta-path Φ, and σ is the non-linear function.
[0061] Applying multi-head attention to node-level attention makes the training process more stable; and connecting the learned embeddings into an embedding representation of specific semantics; its formula is defined as:
[0062]
[0063] Therefore, given a set of meta-paths {Φ0, Φ1, …, Φ P-1} of a knowledge graph, P groups of specific entity semantic embeddings can be obtained through node-level attention, denoted as
[0064] b) Semantic-level attention
[0065] Introduce a new semantic-level attention to automatically learn the importance of different meta-paths and fuse them into specific tasks; taking the P groups of specific entity semantic embeddings learned from node-level attention as input, the weights of each meta-path can be learned, and its formula is defined as:
[0066]
[0067] Among them, is the weight of the meta-path, and attn sem is the deep neural network for calculating semantic-level attention.
[0068] To understand the importance of each meta-path, first transform the embedding of specific semantics through a non-linear function; then, use the inner product of a semantic-level attention vector q and the non-linear transformation of the meta-path specific semantic node embedding to measure the importance of the embedding of specific meta-path specific semantic entities; after that, average and optimize the importance of all specific semantic node embeddings; the importance of each meta-path is defined as:
[0069]
[0070] Among them, is the importance of the meta-path Φ i , Λ is the set of all meta-paths, q is the semantic-level attention vector, W is the weight matrix, and b is the bias;
[0071] After obtaining the importance of each meta-path, it is normalized by the softmax function; the weight of the meta-path Φ i is expressed as and its formula is defined as:
[0072]
[0073] Taking the learned weights as coefficients and fusing these semantics-specific embeddings to obtain the final embedding Z, its formula is defined as:
[0074]
[0075] Step 4.2, Train the knowledge graph heterogeneous graph attention network model: Train the model to obtain the word embedding representation of the entities in the industrial machinery knowledge graph;
[0076] For semi-supervised entity classification, the cross-entropy function that minimizes the predicted class label distribution of the nodes with class labels and the true class labels is used as the loss function, and its formula is defined as:
[0077]
[0078] Among them, C is the parameter of the classifier, y L is the set of indices of the labeled nodes, Y l and Z l are the labels and embeddings of the labeled nodes; for link prediction, the training loss function L uses the Margin loss function, and its formula is defined as:
[0079]
[0080] Step 4.2, Train the knowledge graph heterogeneous graph attention network model: Train the model to obtain the embedding representation of the entities in the industrial machinery fault diagnosis knowledge graph.
[0081] Furthermore, in the task verification stage of step 5, it specifically includes:
[0082] Step 5.1, Fault knowledge entity classification task: Reduce the embedding representation of the entity to two dimensions by the dimensionality reduction algorithm TSNE, and classify the fault entities based on the distribution of the word embedding representation of the entity on the two-dimensional plane;
[0083] Step 5.2, Fault knowledge link prediction task: Verify the accuracy of fault knowledge link prediction by using the embedding representation of entities with Hits@10 score.
[0084] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0085] 1. Based on the heterogeneous graph attention network model, the present invention innovatively retains the knowledge structure of the knowledge graph triples and the graph structure information possessed by the knowledge graph as a graph data structure, and can learn the entity embedding representation in the industrial machinery fault diagnosis knowledge graph in an end-to-end learning manner. The present invention uses the knowledge graph heterogeneous graph attention network model (KGHAN) to train the fault knowledge data, which can greatly improve the accuracy of fault knowledge entity classification and fault knowledge link prediction.
[0086] 2. The present invention can deduce the relationships between new entities from the given knowledge graph, further complete knowledge discovery, and thus complete in-depth analysis and reasoning of data. The embedding representation forms of entities and relationships obtained by the present invention through the knowledge graph heterogeneous graph attention network model play an important role in the calculation, completion, reasoning, etc. of the knowledge graph.
[0087] 3. The fault knowledge entity classification task of the present invention can realize the semi-automatic construction of the knowledge graph, and can assist engineers to construct the industrial fault diagnosis knowledge graph faster and better; the fault knowledge link prediction task of the present invention can assist engineers to diagnose industrial faults and recommend possible causes of faults and solutions to faults to engineers. Description of the Drawings
[0088] Figure 1 It is a flowchart of the method according to an embodiment of the present invention.
[0089] Figure 2 It is a structural diagram of the knowledge graph heterogeneous graph attention network model according to an embodiment of the present invention.
[0090] Figure 3 is a display diagram of fault knowledge entity classification according to an embodiment of the present invention. Among them, Figure 3a It is a display diagram of fault knowledge entity classification of the dataset FDI-NCM, Figure 3b It is a display diagram of fault knowledge entity classification of the dataset FDI-EXC. Detailed Embodiment
[0091] A knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph according to the present invention performs knowledge reasoning by using a heterogeneous graph attention network of the knowledge graph on the basis of establishing the industrial machinery fault diagnosis knowledge graph, so as to solve the fault knowledge entity classification task and the fault knowledge link prediction task of the industrial machinery fault diagnosis knowledge graph. The present invention uses a heterogeneous graph attention network model of the knowledge graph to train the fault condition data of a certain industrial machinery for knowledge reasoning. The present invention takes into account both the knowledge structure and the graph structure of the knowledge graph, and can greatly improve the accuracy of fault knowledge entity classification and fault knowledge link prediction. The method of the present invention includes: collecting and cleaning the fault condition data of a certain industrial machinery; creating structured fault knowledge triples; creating word embedding representations of fault entities and fault relationships and a heterogeneous industrial machinery fault diagnosis knowledge graph according to the structured fault knowledge triples; visually displaying the constructed industrial machinery fault diagnosis knowledge graph through a Neo4j graph database; constructing a heterogeneous graph attention network model of the knowledge graph; training the model to obtain the embedding representations of entities in the industrial machinery fault diagnosis knowledge graph; and completing the fault knowledge entity classification task and the fault knowledge link prediction task, so as to realize the knowledge reasoning of the industrial machinery fault diagnosis knowledge graph.
[0092] The present invention will be further described in detail below with reference to the accompanying drawings.
[0093] Figure 1 The flowchart of the method of an embodiment of the present invention is shown in Figure 1 As shown, the method of this embodiment includes the following steps:
[0094] Step 1 is the data cleaning stage, which includes: collecting and cleaning the fault condition data of a certain industrial machinery; creating structured fault knowledge triples.
[0095] Step 2 is the data processing stage, which includes: creating word embedding representations of fault entities and fault relationships and a heterogeneous industrial machinery fault diagnosis knowledge graph according to the structured fault knowledge triples.
[0096] Step 3 is the graph display stage, which includes: visually displaying the constructed industrial machinery fault diagnosis knowledge graph through a Neo4j graph database.
[0097] Step 4 is the model construction and training stage, which includes: constructing a heterogeneous graph attention network model of the knowledge graph; training the model to obtain the embedding representations of entities in the industrial machinery fault diagnosis knowledge graph.
[0098] Step 5 is the task verification stage, which includes: completing the fault knowledge entity classification task and the fault knowledge link prediction task, so as to realize the knowledge reasoning of the industrial machinery fault diagnosis knowledge graph.
[0099] In the data cleaning phase of step 1, it includes:
[0100] Step 1.1, cleaning the data of fault conditions: Extracting the fault entities and the fault knowledge triple data in the fault condition data with regular expressions, and removing the redundant punctuation marks and auxiliary description information.
[0101] Step 1.2, creating a structured fault knowledge triple: Screening the fault knowledge triple according to the corresponding relationship between fault entities, and the specific form is: (head entity, relationship, tail entity), briefly recorded as: (h, r, t).
[0102] In the data processing phase of step 2, it includes:
[0103] Step 2.1, creating the word embedding representation of fault entities and fault relationships: Sorting the cleaned fault condition data in ascending order according to the single Chinese characters to form a list and encoding it in Unicode encoding format. Encoding each fault entity and fault relationship according to the Chinese character list and the number of Chinese characters, and the encoding vector is used as its word embedding representation.
[0104] Step 2.2, creating a heterogeneous industrial machinery fault diagnosis knowledge graph: Storing the heterogeneous industrial machinery fault diagnosis knowledge graph based on the graph data structure in the graph neural network framework DGL.
[0105] In the graph display phase of step 3, it includes:
[0106] Step 3.1, constructing an industrial machinery fault diagnosis knowledge graph: Constructing an industrial machinery fault diagnosis knowledge graph based on the fault knowledge triple with Python and the Py2neo library.
[0107] Step 3.2, visualizing the knowledge graph: Visualizing and displaying through the Neo4j graph database, and being able to implement graph search algorithms for adding, deleting, and searching various industrial fault data through Python scripts.
[0108] In the model construction and training phase of step 4, a knowledge graph heterogeneous graph attention network KGHAN model is proposed based on the heterogeneous graph attention network HAN, which specifically includes:
[0109] Step 4.1, constructing a knowledge graph heterogeneous graph attention network model: A knowledge graph heterogeneous graph attention network (KGHAN) model is proposed based on the heterogeneous graph attention network (HAN). On the basis of the heterogeneous graph attention network model, it innovatively retains the knowledge structure of the knowledge graph triple and the graph structure information owned by the knowledge graph as a graph data structure, and can learn the entity embedding representation in the industrial machinery fault diagnosis knowledge graph in an end-to-end learning manner.
[0110] Figure 2This is the structural diagram of the knowledge graph heterogeneous graph attention network model for an embodiment of the present invention. Among them, the KGHAN model adopts the following design, including a knowledge information fusion layer, a graph structure information fusion layer, and a heterogeneous graph attention network layer, specifically:
[0111] (1) Knowledge information fusion layer: The structural diagram of this layer is as shown in the Figure 2 knowledge information fusion layer module. In order to retain the original knowledge triple structure of the knowledge graph, the embedding vector representation of the knowledge graph translation model TransD is fused. The word embedding representations of the entities and relationships described in step 2.1 are based on their one-hot word encoding vector representations. However, when using one-hot word encoding vectors to represent a knowledge triple, the vector dimension will be too large to capture similarity. Therefore, the present invention fuses the embedding vectors of the knowledge graph translation model TransD to improve this problem.
[0112] The TransD model learns the embedding vector representations of each entity and relationship in the knowledge graph by optimizing the TransE translation model. It uses two vectors to represent each entity and relationship. The first vector represents the meaning of the entity or relationship, and the other vector (called the projection vector) will be used to construct the mapping matrix. The mapping matrices of the head entity and the tail entity are defined as:
[0113]
[0114]
[0115] Among them, is the mapping matrix of the head and tail entities, r i (0) is the initialized relationship embedding vector, is the initialized head and tail entity embedding vectors, m is the dimension of the relationship embedding vector, n is the dimension of the head and tail entity embedding vectors, is the identity matrix, and m×n is the shape of the identity matrix.
[0116] After that, the embedding vectors of the entities are mapped into the corresponding relationship embedding vector space through the mapping matrix. The embedding vector formulas of the head entity and the tail entity mapped into the relationship space are defined as:
[0117]
[0118]
[0119] Among them, are the updated head and tail entity embedding vectors.
[0120] In order to evaluate the correlation between the embedding vectors of the head entity and the tail entity, the vector distance error is defined as si The updated triple The reputation scoring formula f ri is defined as follows:
[0121]
[0122] where is the square operation of a vector two-norm.
[0123] To optimize the training process, in the knowledge information fusion layer, the correct triples are randomly replaced with head and tail entities to achieve negative sample sampling, and the wrong triples are defined as The vector distance error is s i ′. The training loss function L adopts the Margin loss function, and its formula is defined as:
[0124]
[0125] where γ is the margin between the scores of the correct triples and the wrong triples, and max(x, y) is the operation of taking the maximum value of x or y.
[0126] Finally, the present invention adds the embedded vectors of the trained entities and relationships to the word embedding representation of the nodes as input. The fused word embedding representation of the nodes is defined as:
[0127]
[0128] where is the word embedding representation after fusing knowledge information, is the word embedding representation described in step 2.1, is the i-th node embedding representation (a set of the head entity embedding vector and the tail entity embedding vector ), and || is the vector concatenation operation.
[0129] (2) Graph structure information fusion layer: The structure diagram of this layer is as shown in the graph structure information fusion layer module of Figure 2 To retain the graph structure information of the knowledge graph as a graph data structure and fuse the degrees of the nodes in the graph. The attention correlation between the entities described in step 2.1 is calculated according to their semantic correlation. However, node centrality (measuring the importance of a node in the graph) is usually an important signal for understanding the graph, and this information is ignored in the current attention calculation.
[0130] The present invention uses the degree vector of each entity in the KGHAN model as an additional signal for the embedding representation of entities and relationships. Specifically, the present invention adds entity centrality encoding, and assigns two real-valued embedding vectors to each entity according to the in-degree and out-degree of the entity. Since the entity centrality encoding is applied to each entity, the present invention only needs to add it to the word embedding representation of the entity as an input. The embedding representation of the fused entity is defined as:
[0131]
[0132] where x i is the embedding representation of the i-th entity after fusing the structural information of the graph, is the embedding representation after fusing knowledge information, || is the vector concatenation operation, is the in-degree vector of the entity, is the out-degree vector of the entity.
[0133] (3) Heterogeneous graph attention network layer: The structure diagram of this layer is as shown in the heterogeneous graph attention network layer module of Figure 2 . This layer simultaneously includes node-level attention and semantic-level attention. Node-level attention mainly learns the weights between an entity and its neighboring entities, and semantic-level attention is used to learn the weights based on different meta-paths. Thanks to this hierarchical attention, the importance of neighbor entities and meta-paths can be considered simultaneously.
[0134] a) Node-level attention
[0135] The knowledge graph is a typical heterogeneous graph, which can be represented as G=(V, E), consisting of an entity set V and a relationship set E. The knowledge graph is also associated with an entity type mapping function φ: V→A and a relationship type mapping function E→B. A and B represent the sets of predefined entity types and relationship types, where ||A||+||B||≥2. In a heterogeneous graph, two entities of different types can be associated through different semantic paths, and this semantic path is called a meta-path, which can be defined as where A1, A2,..., A l+1 are the entities on a meta-path, and R1, R2,..., R l are the relationships on a meta-path.
[0136] The present invention introduces node-level attention to aggregate the meta-path neighbor information of each entity, thereby learning the importance of neighbor entities based on the meta-path for each entity in the knowledge graph, and aggregating the representations of these neighbors to form the embedding representation of the entity. Due to the heterogeneous characteristics of the nodes in the knowledge graph, different types of entities have different embedding spaces. Therefore, specific types of transformation matrices are designed for each type of entity to project the embedding representations of different types of entities into the same embedding space. The projection formula is defined as:
[0137]
[0138] where x′ i is the projected entity embedding representation, is the transformation matrix of the type to which the i-th entity belongs, and x i is the embedding representation of the entity after fusing the knowledge information and the structural information of the graph.
[0139] After that, the self-attention mechanism is used to learn the weights between various entities. Given an entity pair (i, j) connected by the meta-path Φ, then the weight coefficient can be used to represent the importance of j to i, and its formula is defined as:
[0140]
[0141] where attn node is the deep neural network for calculating node-level attention, x′ i , x′ j are the projected entity embedding representations, and Φ is the meta-path from entity j to entity i.
[0142] Thus, in the entity pair (i, j) based on the meta-path, the attention coefficient of entity j to entity i is defined by the formula:
[0143]
[0144] where σ is the activation function, and the present invention adopts the LeakyReLU non-linear function, is the set of neighbor entities of the i-th entity, exp(x) represents the mathematical operation e x , || is the vector concatenation operation, is the transpose of the mapping vector.
[0145] Then, the embedding representation of entity i based on the meta-path can be aggregated from the projection of the embedding representations of its neighbor entities and the corresponding attention coefficients, and its formula is defined as:
[0146]
[0147] Among them, is the embedding representation learned by entity i corresponding to the meta-path Φ, and σ is a non-linear function.
[0148] Since the heterogeneous graph has a scale-free property, the variance of the graph data is very large. To solve this problem, the present invention applies multi-head attention to node-level attention, making the training process more stable. The meaning of multi-head attention is to call K independent node-level attention operations (average optimization can be performed) for each entity respectively, and connect the learned embeddings into an embedding representation of specific semantics. Its formula is defined as:
[0149]
[0150] Therefore, given a set of meta-paths {Φ0, Φ1, …, Φ P-1} of a knowledge graph, P groups of specific entity semantic embeddings can be obtained through node-level attention, denoted as
[0151] b) Semantic-level attention
[0152] To learn more comprehensive node embeddings, it is necessary to fuse the specific semantics contained in each meta-path. The present invention introduces a new semantic-level attention, automatically learning the importance of different meta-paths and fusing them into specific tasks. Taking the P groups of specific entity semantic embeddings learned from node-level attention as input, the weights of each meta-path can be learned, and its formula is defined as:
[0153]
[0154] Among them, is the weight of the meta-path, and attn sem is a deep neural network for calculating semantic-level attention.
[0155] To understand the importance of each meta-path, first transform the embedding of specific semantics through a non-linear function. Then, use the inner product of a semantic-level attention vector q and the non-linear transformation of the meta-path specific semantic node embedding to measure the importance of the embedding of the specific semantic entity of the specific meta-path. Further, average and optimize the importance of all specific semantic node embeddings. The importance of each meta-path is defined as:
[0156]
[0157] Among them, is the importance of the meta-path Φ i , Λ is the set of all meta-paths, q is the semantic-level attention vector, W is the weight matrix, and b is the bias.
[0158] After obtaining the importance of each meta-path, normalize it using the softmax function. The weight of meta-path Φ i is denoted as and its formula is defined as:
[0159]
[0160] Take the learned weights as coefficients and fuse these semantics-specific embeddings to obtain the final embedding Z, whose formula is defined as:
[0161]
[0162] Step 4.2, Train the knowledge graph heterogeneous graph attention network model: Train the model to obtain the word embedding representations of the entities in the industrial machinery knowledge graph.
[0163] For semi-supervised entity classification, use the cross-entropy function that minimizes the predicted class label distribution and the true class label of the nodes with class labels as the loss function, and its formula is defined as:
[0164]
[0165] where C is the parameter of the classifier, y L is the index set of labeled nodes, Y l and Z l are the labels and embeddings of the labeled nodes.
[0166] For link prediction, the training loss function L uses the Margin loss function, and its formula is defined as:
[0167]
[0168] In the task verification stage of step 5, it includes:
[0169] Step 5.1, Fault knowledge entity classification task: Reduce the embedding representation of the entity to two dimensions using the dimensionality reduction algorithm TSNE, and classify the fault entities based on the distribution of the word embedding representation of the entity on the two-dimensional plane.
[0170] Step 5.2, Fault knowledge link prediction task: Verify the accuracy of the fault knowledge link prediction with the Hits@10 score of the entity embedding representation.
[0171] As described above, the present invention proposes a knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph, which can be used to implement the knowledge reasoning of the industrial machinery fault diagnosis knowledge graph, and can greatly improve the accuracy of fault knowledge entity classification and fault knowledge link prediction.
[0172] Based on the heterogeneous graph attention network model, the present invention innovatively retains the knowledge structure of the knowledge graph triples and the graph structure information possessed by the knowledge graph as a graph data structure, and can learn the entity embedding representation in the industrial machinery fault diagnosis knowledge graph in an end-to-end learning manner. The present invention uses the knowledge graph heterogeneous graph attention network model (KGHAN) to train the fault knowledge data, which can greatly improve the accuracy of fault knowledge entity classification and fault knowledge link prediction.
[0173] The present invention can derive new relationships between entities from a given knowledge graph, further complete knowledge discovery, and thus complete in-depth analysis and reasoning of data. The embedding representation forms of entities and relationships obtained by the present invention through the knowledge graph heterogeneous graph attention network model play an important role in the calculation, completion, reasoning, etc. of the knowledge graph.
[0174] The fault knowledge entity classification task of the present invention can realize the semi-automatic construction of the knowledge graph, and can assist engineers to construct the industrial fault diagnosis knowledge graph faster and better; the fault knowledge link prediction task of the present invention can assist engineers to diagnose industrial faults and recommend possible causes of faults and solutions to engineers.
[0175] The present invention has been verified on the fault condition data of a domestic certain type of CNC machine tool and a domestic certain type of excavator. The present invention processes the fault condition data of a domestic certain type of CNC machine tool and forms a trainable data set named FDI-NCM; processes the fault condition data of a domestic certain type of excavator and forms a trainable data set named FDI-EXC. The present invention uses a one-layer knowledge graph heterogeneous graph attention network.
[0176] The verification results of the fault knowledge entity classification task of the present invention are shown in Table 1:
[0177] Table 1 Accuracy indicators for the fault knowledge entity classification task
[0178]
[0179] The verification result graph of the fault knowledge entity classification task of the present invention is as Figure 3a and Figure 3b shown. Combining Table 1 and the result graph above, it can be seen that the knowledge graph heterogeneous graph attention network model can well predict the fault knowledge entity categories, and can greatly improve the fault knowledge entity classification compared with other models. At the same time, the fault knowledge entity classification task of the present invention can realize the semi-automatic construction of the knowledge graph, and can assist engineers to construct the industrial fault diagnosis knowledge graph faster and better.
[0180] The verification results of the fault knowledge link prediction task of the present invention are shown in Table 2:
[0181] Table 2 Hits@n Metrics for Fault Knowledge Link Prediction Task
[0182]
[0183] As can be seen from Table 2 above, the heterogeneous graph attention network model of the knowledge graph can well predict the fault knowledge link path. At the same time, the fault knowledge link prediction task of the present invention can assist engineers in diagnosing industrial faults and recommend possible causes of faults and solutions to faults to engineers.
Claims
1. A knowledge reasoning method based on an industrial machinery fault diagnosis knowledge graph, characterized in that, Including the following steps: Step 1, data cleaning stage: Collect and clean the fault condition data of a certain industrial machine; Create a structured fault knowledge triple; Step 2, data processing stage: Create word embedding representations of fault entities and fault relationships and a heterogeneous industrial machine fault diagnosis knowledge graph according to the structured fault knowledge triples; Step 3, knowledge graph display stage: Visualize the constructed industrial machine fault diagnosis knowledge graph through the Neo4j graph database based on Python and the Py2neo library; Step 4, model construction and training stage: Construct a knowledge graph heterogeneous graph attention network model; Train the model to obtain the embedding representations of entities in the industrial machine fault diagnosis knowledge graph; Step 5, task verification stage: Complete the fault knowledge entity classification task and the fault knowledge link prediction task to achieve knowledge reasoning of the industrial machine fault diagnosis knowledge graph; The data cleaning stage of the said Step 1 includes: Step 1.1, clean the fault condition data: Extract the fault entities and fault knowledge triple data in the fault condition data with regular expressions, and remove redundant punctuation marks and auxiliary description information; Step 1.2, create a structured fault knowledge triple: Screen the fault knowledge triples according to the corresponding relationships between fault entities. The specific form is: (head entity, relationship, tail entity), briefly recorded as: (h, r, t); The data processing stage of the said Step 2 specifically includes: Step 2.1, create word embedding representations of fault entities and fault relationships: Form a list of each single Chinese character from the cleaned fault condition data and sort it in ascending order in Unicode encoding. Encode each fault entity and fault relationship according to the Chinese character list and the number of Chinese characters. The encoded vector is used as its word embedding representation; Step 2.2, create a heterogeneous industrial machine fault diagnosis knowledge graph: Store the heterogeneous industrial machine fault diagnosis knowledge graph based on the graph data structure in the graph neural network framework DGL; The knowledge graph display stage of the said Step 3 specifically includes: Step 3.1, construct an industrial machine fault diagnosis knowledge graph: Construct an industrial machine fault diagnosis knowledge graph based on the fault knowledge triples with Python and the Py2neo library; Step 3.2, knowledge graph visualization: Visualize and display through the Neo4j graph database, and can implement graph search algorithms for adding, deleting, and searching various industrial fault data through Python scripts; In the model construction and training stage of Step 4, the construction of the knowledge graph heterogeneous graph attention network model; Training the model to obtain the embedding representations of entities in the industrial machine fault diagnosis knowledge graph specifically includes: Step 4.1, construct a knowledge graph heterogeneous graph attention network model: Propose a knowledge graph heterogeneous graph attention network KGHAN model based on the heterogeneous graph attention network HAN; On the basis of the heterogeneous graph attention network model, it retains the knowledge structure of the knowledge graph triples and the graph structure information owned by the knowledge graph as a graph data structure, and can learn the entity embedding representations in the industrial machine fault diagnosis knowledge graph in an end-to-end learning manner; The KGHAN model adopts the following design: (1) Knowledge Information Fusion Layer: To preserve the original knowledge triple structure of the knowledge graph, the embedding vector representation of the TransD model of the knowledge graph is fused; The TransD model learns the embedding vector representation of each entity and relationship in the knowledge graph by optimizing the TransE translation model. It uses two vectors to represent each entity and relationship. The first vector represents the meaning of the entity or relationship, and the other vector, called the projection vector, is used to construct the mapping matrix; the mapping matrices of the head entity and the tail entity are defined as: Among them, is the mapping matrix of the head and tail entities, is the initialized relation embedding vector, is the initialized head and tail entity embedding vectors, m is the dimension of the relation embedding vector, and n is the dimension of the head and tail entity embedding vectors. is the identity matrix, and m×n is the shape of the identity matrix; After that, the embedding vector of the entity is mapped into the corresponding relationship embedding vector space through the mapping matrix. The formulas for the embedding vectors of the head entity and the tail entity mapped into the relationship space are defined as: Among them, are the updated head and tail entity embedding vectors; To evaluate the correlation between the embedding vectors of the head entity and the tail entity, the vector distance error is defined as s i ; the updated triple of the reputation scoring formula f ri is defined as follows: Among them, is the square operation of a vector two-norm; To optimize the training process, in the knowledge graph embedding layer, random replacement of the head and tail entities of correct triples is performed to achieve negative sample sampling. Incorrect triples are defined as The vector distance error is s' i ; The training loss function L uses the Margin loss function, and its formula is defined as: Among them, γ is the margin between the scores of the correct triples and the incorrect triples, and max(x, y) is the operation of taking the maximum value of x or y; Finally, the trained embedding vectors of the entities and relationships are added to the word embedding representation of the nodes as input; the fused word embedding representation of the nodes is defined as: Among them, is the word embedding representation after fusing knowledge information, is the word embedding representation described in Step 2.1, is the embedding representation of the i-th node, that is, the head entity embedding vector and the tail entity embedding vector is a set of, || is the vector concatenation operation; (2) Graph Structure Information Fusion Layer: To preserve the graph structure information of the knowledge graph as a graph data structure, the degrees of the nodes in the graph are fused; In the KGHAN model, the degree vector of each entity is used as an additional signal for the embedding representation of the entity and the relationship, that is: entity centrality encoding is added, and two real-valued embedding vectors are assigned to each entity according to the in-degree and out-degree of the entity; since the entity centrality encoding is applied to each entity, it only needs to be added to the word embedding representation of the entity as input; the fused embedding representation of the entity is defined as: Among them, x i is the embedded representation of the i-th entity after fusing the structural information of the graph, and x i (2) is the embedded representation after fusing the knowledge information. || is the vector concatenation operation, is the in-degree vector of the entity, is the out-degree vector of the entity; (3) Heterogeneous Graph Attention Network Layer: This layer includes both node-level attention and semantic-level attention. Node-level attention mainly learns the weights between an entity and its neighboring entities, and semantic-level attention is used to learn the weights based on different meta-paths; thanks to this hierarchical attention, the importance of neighbor entities and meta-paths can be considered simultaneously; a) Node-level attention: A knowledge graph is a typical heterogeneous graph, which can be represented as G = (V, E), consisting of an entity set V and a relationship set E; the knowledge graph is also associated with an entity type mapping function φ: V → A and a relationship type mapping function : E → B; A and B represent sets of predefined entity types and relationship types, where ||A|| + ||B|| ≥ 2; in a heterogeneous graph, two entities of different types can be associated through different semantic paths, and this semantic path is called a meta-path, which can be defined as Φ: where A1, A2, …, A l+1 are entities on a meta-path, and R1, R2, …, R l are relationships on a meta-path; Node-level attention is introduced here to aggregate the meta-path neighbor information of each entity, thereby learning the importance of neighbor entities based on meta-paths for each entity in the knowledge graph, and aggregating the representations of these neighbors to form the embedding representation of the entity; for each type of entity, a specific type of transformation matrix is designed to project the embedding representations of different types of entities into the same embedding space; the projection formula is defined as: Among them, x' i is the projected entity embedding representation, is the transformation matrix of the type to which the i-th entity belongs, and x i is the embedding representation of the entity after integrating knowledge information and graph structure information; After that, the self-attention mechanism is used to learn the weights between various entities; given an entity pair (i, j) connected by a meta-path Φ, then the weight coefficient can be used to represent the importance of j to i, and its formula is defined as: Among them, attn node is a deep neural network for calculating node-level attention, and x′ i , x′ j are the projected entity embedding representations, and Φ is the meta-path from entity j to entity i; Thus, in the entity pair (i, j) based on the meta-path, the attention coefficient of entity j to entity i is defined by the formula as follows: where σ is the activation function, and the LeakyReLU non-linear function is adopted. is the set of neighbor entities of the i-th entity, and exp(x) represents the mathematical operation e x , || is the vector concatenation operation, is the transpose of the mapping vector; Then, the embedding representation of entity i based on the meta-path can be aggregated by the projection of the embedding representations of its neighbor entities and the corresponding attention coefficients, and its formula is defined as: Among them, is the embedding representation learned by entity i corresponding to the meta-path Φ, and σ is a non-linear function; Multi-head attention is applied to node-level attention to make the training process more stable; and the learned embeddings are connected into an embedding representation with specific semantics; its formula is defined as: Therefore, given a set of meta-paths of a knowledge graph \(\{\Phi_0, \Phi_1, \ldots, \Phi\) P-1 \}, P groups of specific entity semantic embeddings can be obtained through node-level attention, denoted as b) Semantic-level attention A new semantic-level attention is introduced to automatically learn the importance of different meta-paths and fuse them into a specific task; taking the P groups of specific entity semantic embeddings learned from node-level attention as input, the weights of each meta-path can be learned, and its formula is defined as: Among them, is the weight of the meta-path, and attn sem is a deep neural network for calculating semantic-level attention; To understand the importance of each meta-path, first, the embeddings of specific semantics are transformed through a non-linear function; then, the importance of the embeddings of specific semantic entities of a specific meta-path is measured by taking the inner product of a semantic-level attention vector q and the non-linear transformation of the meta-path specific semantic node embeddings; afterwards, the importance of all specific semantic node embeddings is averaged and optimized; the importance of each meta-path is defined as: Among them, is the importance of the meta-path Φ i , Λ is the set of all meta-paths, q is the semantic-level attention vector, W is the weight matrix, and b is the bias; After obtaining the importance of each meta-path, normalize it using the softmax function; the weight of meta-path Φ i is denoted as and its formula is defined as: The learned weights are used as coefficients, and these semantics-specific embeddings are fused to obtain the final embedding Z, whose formula is defined as: Step 4.
2. Train the knowledge graph heterogeneous graph attention network model: Train the model to obtain the word embedding representations of the entities in the industrial machinery knowledge graph; For semi-supervised entity classification, the cross-entropy function that minimizes the predicted class label distribution of the nodes with class labels and the true class labels is used as the loss function, and its formula is defined as: where C is the parameter of the classifier, y L is the set of indices of labeled nodes, Y l and Z l are the labels and embeddings of the labeled nodes; For link prediction, the training loss function L uses the Margin loss function, and its formula is defined as: Step 4.
2. Train the knowledge graph heterogeneous graph attention network model: Train the model to obtain the embedding representations of the entities in the industrial machinery fault diagnosis knowledge graph; The task verification stage of step 5 specifically includes: Step 5.
1. Fault knowledge entity classification task: The embedding representations of the entities are reduced to two dimensions by the dimensionality reduction algorithm TSNE, and the classification of the fault entities is realized by the distribution of the word embedding representations of the entities on the two-dimensional plane; Step 5.
2. Fault knowledge link prediction task: The embedding representations of the entities are used to verify the accuracy of the fault knowledge link prediction with the Hits@10 score.
Citation Information
Patent Citations
Hydroelectric generating set fault diagnosis method and system based on knowledge graph of fusion characteristics
CN110033101A
Entity alignment method based on heterogeneous graph attention network
CN112800770A
Mechanical fault diagnosis method based on knowledge graph and graph neural network
CN113283027A