Electromechanical equipment knowledge graph link prediction method fused with large language model

By combining a chain-based fine-tuning large language model with a graph attention network, the problem of missing entities and relationships in the electromechanical equipment knowledge graph is solved, improving the context awareness and prediction performance of the knowledge graph and achieving high-quality fault analysis and prediction.

CN120806101APending Publication Date: 2025-10-17CHINA JILIANG UNIV

Patent Information

Application Number
CN202511299734.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-12
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

The knowledge graph of electromechanical equipment suffers from the problem of missing entities and relationships. Traditional graph structure learning is difficult to mine complex semantic features, and there is insufficient research on the combination of large language models in the electromechanical equipment scenario, resulting in poor link prediction performance of knowledge graph.

Method used

A chain-based fine-tuned large language model is used to construct a knowledge graph of electromechanical equipment. A graph attention network is combined to perform feature fusion and neighborhood information aggregation. Information is transmitted iteratively through a multi-layer network. The large language model is used to encode text information and a decoder is combined to perform link prediction.

Benefits of technology

It enhances the context awareness and adaptability of the electromechanical equipment knowledge graph, improves the accuracy of root cause analysis and prediction of faults, and strengthens the representational capabilities of the knowledge graph.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120806101A_ABST
    Figure CN120806101A_ABST
Patent Text Reader

Abstract

An electromechanical equipment knowledge graph link prediction method fused with a large language model belongs to the field of electromechanical equipment and knowledge graphs, and comprises the following steps: step 1, constructing an electromechanical equipment knowledge graph by combining a fine tuning large language model and a prompt project; step 2, designing an encoder with a multilayer graph attention network for the constructed EKG, and realizing embedded representation updating of the knowledge graph; and a third step, combining a decoder to decode the knowledge graph embedding obtained by coding, and executing a link prediction task. According to the method, effective extraction of the triple information of the high-quality electromechanical equipment is realized, and a data basis is provided for fault root cause analysis and fault prediction of the electromechanical equipment; the representation capability of the graph is enhanced, the context sensing capability of the knowledge graph is enhanced, and the adaptability and prediction performance of the model in the field of electromechanical equipment are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of mechanical and electrical equipment and knowledge graph, and particularly relates to a mechanical and electrical equipment knowledge graph link prediction method fusing a large language model. BACKGROUND

[0002] With the continuous development of cognitive intelligent manufacturing, knowledge plays a key role in realizing higher-level intelligence. Knowledge graph was proposed by Google in 2012, which builds a knowledge base with rich semantic associations through structured representation of triples (entity, relationship, entity). At present, this technology has been widely applied to intelligent question answering, fault diagnosis, fault prediction and other tasks in the field of mechanical and electrical equipment, and provides technical support for realizing knowledge-driven intelligent upgrading of cognitive intelligent manufacturing.

[0003] However, the mechanical and electrical equipment knowledge graph still has the problem of incompleteness, and the lack of key entities and relationships will limit its effectiveness in downstream task applications. Therefore, in order to further improve the knowledge graph and promote the intelligent upgrading of mechanical and electrical equipment, many researchers have begun to combine link prediction methods to complete the knowledge graph, for example, Liu et al. constructed a 3D printing knowledge graph and used an improved graph convolutional network for link prediction to complete the knowledge graph, and further applied the graph to downstream tasks of fault analysis; Xia et al. constructed a maintenance-oriented knowledge graph and proposed a relationship graph convolutional neural network based on attention mechanism for link prediction to find potential links between entities, thereby improving the decision accuracy of predictive maintenance. However, due to the complex semantic relationships and overly professional entity and relationship vocabulary in the field of mechanical and electrical equipment, it is difficult to mine more complex semantic features relying only on graph structure learning.

[0004] In recent years, the development of large language models has provided a new direction for mechanical and electrical equipment knowledge graph link prediction. Large language models have strong semantic understanding and generation capabilities, which can effectively analyze complex semantic relationships in device data and generate high-quality knowledge representations. Such models have acquired rich knowledge through massive training data and have shown excellent context reasoning and zero-shot learning capabilities, which can adapt to industrial scenarios. For example, Chen proposed a text-based link prediction method, which generates description text related to entities by fine-tuning T5 and applies it to knowledge graph completion tasks. Yang et al. used Qwen-7B with low parameter quantity to perform semantic enhancement on knowledge graph data, used prompt engineering to perform semantic compression and semantic expansion according to the length of the text, and then performed the link prediction task. However, most of the current link prediction researches are mainly focused on general knowledge graphs, and the research on link prediction in specific fields, especially in the field of mechanical and electrical equipment, is still insufficient, and the research on fusing large language models is even more scarce.

[0005] Therefore, the challenges of knowledge graph link prediction in the field of electromechanical equipment at present include: (1) traditional graph embedding methods have insufficient utilization of text information, and it is difficult to mine more complex semantic features in the knowledge graph. (2) There is a lack of research on combining large language models in the current electromechanical equipment knowledge graph link prediction method, and there are difficulties in effectively utilizing large language models to enhance the knowledge graph. SUMMARY

[0006] In order to overcome the shortcomings of the prior art, the present application provides an electromechanical equipment knowledge graph link prediction method fusing a large language model. The method first proposes a triple extraction method of chain fine-tuning a large language model, realizes the construction of an electromechanical equipment knowledge graph, secondly, uses a large language model to encode text information, and constructs a heterogeneous knowledge graph composed of an electromechanical equipment knowledge graph and text information, then combines a graph attention network to respectively perform feature fusion between the graph and the text and neighborhood information aggregation in the graph, and iteratively transmits information through a multi-layer network to strengthen the context perception ability, and finally realizes the link prediction of the electromechanical equipment knowledge graph in combination with a decoder.

[0007] The present application provides the following technical solutions: An electromechanical equipment knowledge graph link prediction method fusing a large language model, the method comprising the following steps: First, combine fine-tuning a large language model with a prompt engineering to construct an electromechanical equipment knowledge graph (EKG, Electromechanical Equipment Knowledge Graph); the process is as follows: Step (1.1) data acquisition and processing; Step (1.2) fine-tuning of a large language model; Step (1.3) entity and relationship extraction based on the fine-tuned large language model, automatically extracting triples from a large amount of unstructured text data; Step (1.4) for structured data with clear entity and relationship, after analysis and screening, the corresponding triples are obtained, which are directly used for the construction of the EKG; Step (1.5) according to the triple information extracted from the unstructured data and the structured data, an electromechanical equipment knowledge graph is constructed , wherein and represent the entity set and the relationship set respectively, and the data is stored in a graph database; Second, for the constructed EKG, design an encoder with a multi-layer graph attention network to realize the embedding representation update of the knowledge graph, the process is as follows: Step (2.1) construction of a text encoder based on a large language model; Step (2.2) Construction of the Heterogeneous Knowledge Graph (HKG) of the electromechanical device; Step (2.3) Construction of the HKG text information aggregation module; Step (2.4) Construction of the HKG pruning module; Step (2.5) Construction of the EKG feature aggregation module, which aggregates the neighborhood information of the new entity and relationship embedding representation calculated in step (2.4) using a triple-level attention mechanism; Third step, combined with the decoder, the knowledge graph embedding obtained by encoding is decoded, and the link prediction task is performed.

[0008] Further, the process of step (1.1) is as follows: Step (1.1.1) Collecting unstructured text data related to electromechanical devices and storing the collected data for processing; Utilizing the crawler technology to obtain the encyclopedia data related to electromechanical devices from the Internet; Among them, the crawler technology (Web Crawling), also known as web spider or web robot, is an automatic program that automatically captures information from the Internet; Step (1.1.2) Collecting structured data in the electromechanical device Internet of Things system and storing it in a relational database; Step (1.1.3) For unstructured text data, long text data is truncated to adapt to the input length limit of the large language model: ; Among them, represents the maximum input length that the large language model can accept, represents the collected unstructured text data, represents the text data obtained after truncation.

[0009] Further, the process of step (1.2) is as follows: Step (1.2.1) Construction of the entity extraction fine-tuning dataset. In this dataset, the entities and entity types in the original text of the electromechanical device are labeled, where the entity types include subsystems, components, fault categories, fault phenomena, fault causes, maintenance types, maintenance projects, and maintenance countermeasures; Step (1.2.2) Construction of the relationship extraction fine-tuning dataset. In this dataset, based on the entities labeled in step (1.2.1), the complete triples in the original text are further labeled, but the entity types are not labeled again; Step (1.2.3) Large language model prompt word design; The prompt words of step (1.2.3) contain entity extraction prompt words and relation extraction prompt words, and are designed as follows: Entity extraction prompt words : You are an expert in the field of mechanical and electrical equipment-related entity recognition. You need to refer to the following entity types [subsystem, component, fault category, fault phenomenon, fault reason, maintenance type, maintenance project, repair countermeasure], and extract relevant industrial entities from <text_input>. The output format is <output_format>. When no entity is found, output "No entity found"; Each line of the output must be in JSON format; Relation extraction prompt words : You are an expert in the field of mechanical and electrical equipment-related relation extraction. You need to extract the relationship between entities from <text_input>, and the output format is <output_format>. When there is no relationship, output "No triple found"; Each line of the output must be in JSON format; Wherein, <text_input> is the input original text, i.e. ; <output_format> is the set input format. For entity extraction, the model is required to output entities and entity types; For relation extraction, the <output_format> requires the model to directly output complete triples; Step (1.2.4) uses a fine-tuning dataset to fine-tune a large language model based on LoRA (Low-Rank Adaptation) fine-tuning technology and combined with prompt words, and constructs an entity extraction and relation extraction large language model respectively; LoRA in step (1.2.4) is a parameter-effective large language model fine-tuning method. Through LoRA technology, the reasoning ability of a large language model in a specific domain task can be enhanced in a low-resource situation, thereby enhancing its adaptability in the field of mechanical and electrical equipment.

[0010] Step (1.2.5) trains an entity extraction large language model based on LoRA fine-tuning using an entity extraction fine-tuning dataset. By decomposing the pre-training weight matrix of the large language model into two low-rank matrices, the parameter size of the training is reduced, and the reasoning ability of the model in a specific domain is improved: ; Wherein, represents the weight matrix of the fine-tuned entity extraction large language model, and represent the dimensions of the weight matrix; represents the original pre-training weight matrix of the large language model; Represents the weight matrix that needs to be updated; , represents two low-rank matrices, is the rank of the matrix; Step (1.2.6) is again based on LoRA fine-tuning, using the relation extraction fine-tuning dataset to train the relation extraction large language model: ; in, Represents the weight matrix of the fine-tuned relation extraction large language model; Represents the weight matrix that needs to be updated; , Express Two low-rank matrices obtained by low-rank decomposition; Step (1.2.7) Step (1.2.5) and Step (1.2.6) respectively use two fine-tuning training sets to fine-tune the large language model and obtain the entity extraction large language model Large language model with relation extraction , and used for subsequent triple extraction of unstructured text; Among them, the initial pre-training weights of the large language model are , after fine-tuning, and Learn different weight matrices adapted to their respective specific tasks and , and applied to reasoning for specific tasks.

[0011] Furthermore, the process of step (1.3) is as follows; Step (1.3.1) first performs entity extraction. For a given input text, compare it with the predefined Combine and then input the model , get the entity extraction results: ; in, Indicates the Input text, for Output Entity results for the text; Step (1.3.2) performs relation extraction based on the results of entity extraction. , entity extraction results Combine and input model , get the final output triple result: ; in, representing the triples obtained by reasoning on the text.

[0012] The process of step (2.1) is as follows: Step (2.1.1) inputs the unstructured text processed in step (1.1.3) into a large language model, extracts the hidden state output of the last layer of the model: ; wherein, is the encoder of the large language model, is the hidden state output of the last layer of the large language model internally about the text ; Step (2.1.2) processes the last layer hidden state of the large language model using the following processing flow as the output of the text encoder: 1) For the model of the encoder architecture, select the [CLS] token output of the last layer as the text embedding representation, this step is represented by the formula , wherein the [CLS] token is the first sequence of the hidden state output, which is usually used as the overall representation of the sequence; 2) For the large language model of the decoder architecture, select the last non-padding token embedding in the output sequence of the last layer as the text embedding representation, this step is represented by the formula ; 3) For the large language model of the encoder-decoder architecture, calculate the average value of all embedding representations of the last layer hidden state as the final text embedding representation, this step is represented by the formula , wherein represents the mean value calculation of all embedding representations of ; Step (2.1.3), input the output result of the text encoder into the full connection layer and the activation function layer for feature dimension conversion: ; wherein, is a linear conversion function, is an activation function, is the embedding representation of the output th text; wherein, and represent the text representation space and the knowledge graph representation space respectively, and the full connection layer and the activation function are common techniques in deep learning.

[0013] The process of step (2.2) is as follows: Step (2.2.1) represents all entities and relations in EKG as nodes in HKG, at this time the node set in HKG is ; all are also represented as nodes in HKG, and the text information node set is represented by ; Step (2.2.2) the edges in HKG are defined as follows: in the initial HKG, each text information node in is connected with all nodes in , and for each node in , the subgraph matrix of is represented by .

[0014] The subgraph of contains itself and all text information nodes connected with .

[0015] The process of the step (2.3) is as follows: Step (2.3.1) obtains the initial embedding representation of EKG based on TransE, wherein the embedding of entities and relations are represented by and respectively, and the feature dimension of is ; TransE is a commonly used knowledge graph embedding method.

[0016] Step (2.3.2) fuses the embedding representation of entities and relations with text features using a graph attention network, in this step, the present application uses to jointly represent or : ; ; wherein, is a parameterized linear conversion matrix, is a shared attention mechanism, represents the th node (or ) in the node set , is a commonly used nonlinear activation function, the function is used to calculate the relative attention value, represents the node and the th node, Attention weights between clauses; Step (2.3.3) To obtain more stable results, the present application adds a multi-head attention mechanism to calculate the attention weights between nodes, denoted as: ; Wherein, represents the number of attention heads, is calculated by the first attention head ; The process of the step (2.4) is: Step (2.4.1) defines the hyperparameter , which is used to measure the amount of text information that needs to be retained.

[0017] Step (2.4.2) combines calculated in step (2.3.3) according to nodes, that is, uses to represent the attention weight matrix between node and each text information node.

[0018] Step (2.4.3) combines and to prune the HKG; Preferably, the process of the step (2.4.3) is: Step (2.4.3.1) updates the embedding representation of each node in : ; ; Wherein, The function represents the index that returns the maximum attention value, is the clause text defined in step (1.3.1), is the index operation, represents the associated attention mask. By performing a pooling operation on the unimportant text nodes, a new entity relationship embedding representation is obtained: ; Wherein, represents the element-wise multiplication operation, is the embedding representation fused with the text information, but at this time only aggregates text embeddings with the highest relevance; Step (2.4.3.2) updates the The normalization is performed, and an activation function is input to obtain the output result of the HKG pruning module, which can be represented as At this time represents the embedding representation of the updated entity or the embedding representation of the relationship ; is a commonly used activation function, is a normalization method; Step (2.4.3.3) updates the subgraph structure of for each node in : ; wherein represents the adjacency matrix of the row index and the column index, and represents that the link between the texts with low relevance is removed according to the index, is the subgraph adjacency matrix output of .

[0019] The process of the step (2.5) is as follows: Step (2.5.1) combines the entity and relationship embeddings in the triplets to obtain the embedding representation of the triplets: ; wherein is a parameterized linear transformation matrix, , , is the head entity, relationship, and tail entity embedding fused with the text information, represents the vector combination operation, is the embedding representation of the triplets (i.e. ) combined by the three; Step (2.5.2) calculates the attention value of the triplets by using the weight matrix and the nonlinear activation function : ; wherein is the weight matrix, is the absolute attention value of the calculated triplets; Step (2.5.3) calculates the relative attention value using the function: ; wherein represents the embedding of the triplets ( , , ).​ representing entities all neighbor nodes of representing a set of relations between them and their neighbor nodes ; Step (2.5.4) In order to obtain more stable results, the application adds a multi-head attention mechanism to calculate the relative attention value between triples, and the entity embedding can be updated as: ; wherein, represents the number of attention heads; Step (2.5.5) Normalizing and inputting it into an activation function to obtain the output of the encoder model, i.e. ; Step (2.5.6) The relation embedding representation calculated in step (2.4.3.2) is taken as the output of the encoder model, i.e. .

[0020] The third step is as follows: Step (3.1) The application uses ConvKB as the decoder module, and the goal of link prediction is to calculate the score of a triple by a scoring function, and the higher the score, the more likely the triple is true. ConvKB is a commonly used knowledge graph link prediction decoder model; Step (3.2) The scoring function of ConvKB is defined as ; wherein, and represent the head entity and the tail entity of the triple, respectively, and their embedding representations are calculated by step (2.5.5), the embedding representation of is obtained by step (2.5.6), represents convolution operation, represents the layer convolution kernel, is the number of convolution kernels, represents a weight matrix used to calculate the predicted score of the triple, and are shared hyperparameters independent of Step (3.3) The loss function is defined as follows: ; ; wherein, is the knowledge graph data, The negative sampling operation is performed to obtain, for the set hyperparameters, represents the square operation of the L2 norm of the parameters, and negative sampling is a commonly used technique for obtaining negative samples.

[0021] The present application has the following advantages: 1. For unstructured data of mechanical and electrical equipment, a fine-tuning dataset is constructed to fine-tune a large language model, thereby realizing effective extraction of high-quality mechanical and electrical equipment triple information, and providing a data basis for fault root cause analysis and fault prediction of mechanical and electrical equipment; 2. Combined with large language model text encoding, a heterogeneous knowledge graph is constructed, and text information features and graph embedding are aggregated through a graph attention network to further learn complex context information in the original text, thereby enhancing the representation ability of the graph; 3. In the process of heterogeneous graph aggregation, a graph pruning method is introduced to remove the interference of redundant text information; in the neighborhood information aggregation, a triple-level attention mechanism is used instead of a single entity attention mechanism to enhance the context awareness ability of the knowledge graph, thereby improving the adaptability and prediction performance of the model in the field of mechanical and electrical equipment. BRIEF DESCRIPTION OF DRAWINGS

[0022] Figure 1 is a mechanical and electrical equipment knowledge graph link prediction method architecture diagram fused with a large language model. DETAILED DESCRIPTION

[0023] The present application will be further described below with reference to the accompanying drawings.

[0024] Referring to Figure 1 , a mechanical and electrical equipment knowledge graph link prediction method fused with a large language model, the method comprising the following steps: Step 1: Combine fine-tuned large language model (LLM, Large Language Model) and prompt engineering to construct mechanical and electrical equipment knowledge graph (EKG), the process is as follows: Step (1.1) Data acquisition and processing, the process is as follows: Step (1.1.1) Collect unstructured text data related to mechanical and electrical equipment, and store the collected data for processing; Use crawler technology to obtain mechanical and electrical equipment related encyclopedia data from the Internet; Wherein, the crawler technology (Web Crawling), also known as web spider or web robot, is an automatic program that automatically crawls information on the Internet; Step (1.1.2) Collect structured data in the mechanical and electrical equipment Internet of Things system and store it in a relational database; ​Step (1.1.3) For unstructured text data, excessively long text data is truncated to adapt to the input length limit of the large language model: ; wherein, represents the maximum input length acceptable by the large language model, represents the collected unstructured text data, represents the text data obtained after truncation.

[0025] Step (1.2) Fine-tuning of the large language model, the process is: Step (1.2.1) Construct an entity extraction fine-tuning dataset, in which dataset, the entities and entity types in the original text of the mechanical and electrical equipment are labeled, and the entity types include subsystem, component, fault category, fault phenomenon, fault reason, maintenance type, maintenance project, and maintenance countermeasure; Step (1.2.2) Construct a relationship extraction fine-tuning dataset, in which dataset, based on the entities labeled in step (1.2.1), further label the complete triples in the original text, but the entity type is no longer labeled repeatedly; Step (1.2.3) Large language model prompt word design; The prompt words of the step (1.2.3) include entity extraction prompt words and relationship extraction prompt words, and are designed as follows: Entity extraction prompt words : You are an expert in the field of mechanical and electrical equipment-related entity recognition, you need to refer to the following entity types [subsystem, component, fault category, fault phenomenon, fault reason, maintenance type, maintenance project, maintenance countermeasure], and extract relevant industrial entities from <text_input>. The output format is <output_format>, and when no entity is found, output "no entity found"; each line of the output must be in JSON format; Relationship extraction prompt words : You are an expert in the field of mechanical and electrical equipment-related relationship extraction, you need to extract the relationship between entities from <text_input>, the output format is <output_format>; when there is no relationship, output "no triple found"; each line of the output must be in JSON format; wherein, <text_input> is the input original text, i.e. ; <output_format> is the set input format, for entity extraction, the model is required to output entities and entity types; and for relationship extraction, the <output_format> requires the model to directly output complete triples.

[0026] Step (1.2.4) fine-tunes the large language model based on LoRA (Low-Rank Adaptation) fine-tuning technology and in combination with the prompt word, to construct the entity extraction and relationship extraction large language models, respectively, as shown in the following formula: Figure 1 As shown in the EKG construction part of the formula, Annotated represents the annotated fine-tuning data set, which is input into the pre-trained LLM and fine-tuned in combination with the prompt prompt and LoRA to obtain the fine-tuned LLM. LoRA in step (1.2.4) is a parameter-efficient large language model fine-tuning method. Through LoRA technology, the reasoning ability of the large language model in specific domain tasks can be enhanced in the case of low resources, thereby enhancing its adaptability in the mechanical and electrical equipment field. Step (1.2.5) trains the entity extraction large language model based on LoRA fine-tuning using the entity extraction fine-tuning data set. By decomposing the pre-training weight matrix of the large language model into two low-rank matrices, the parameter size of the training is reduced, and the reasoning ability of the model in the specific field is improved: ; wherein, represents the weight matrix of the fine-tuned entity extraction large language model, and represent the dimensions of the weight matrix; represents the original pre-training weight matrix of the large language model; represents the weight matrix that needs to be updated; , represents two low-rank matrices, is the rank of the matrix; Step (1.2.6) again fine-tunes the relationship extraction large language model based on LoRA fine-tuning using the relationship extraction fine-tuning data set: ; wherein, represents the weight matrix of the fine-tuned relationship extraction large language model; represents the weight matrix that needs to be updated; , represents two low-rank matrices obtained by low-rank decomposition on ; Step (1.2.7) steps (1.2.5) and (1.2.6) respectively use two fine-tuning training sets to fine-tune the large language model, obtaining the entity extraction large language model and the relationship extraction large language model , which are used for subsequent triple extraction of unstructured text; wherein the initial pre-training weights of the large language model are all After fine-tuning, and learn different weight matrices and adapted to their respective specific tasks and are applied to inference of specific tasks.

[0027] Step (1.3) performs entity and relation extraction based on the fine-tuned large language model to automatically extract triples from a large amount of unstructured text data, as shown in Figure 1 Raw represents an untagged data set, which is input into the fine-tuned LLM for inference; the process is as follows: Step (1.3.1) first performs entity extraction. For a given input text, it is combined with the pre-defined and then input into the model to obtain the entity extraction result: ; wherein represents the input text, is the entity result of the output text; Step (1.3.2) performs relation extraction according to the entity extraction result. The input text, pre-defined , and entity extraction result are combined and input into the model to obtain the final output triple result: ; wherein represents the triples obtained by reasoning on the text; Step (1.4) as shown in Figure 1 , for structured data with clear entity and relation, the corresponding triples obtained after analysis and screening are directly used for construction of EKG; Step (1.5) constructs the electrical and mechanical equipment knowledge graph based on the triple information extracted from unstructured data and structured data, wherein and represent the entity set and the relation set, respectively, and the data is stored in a graph database; Second, for the constructed EKG, an encoder with a multi-layer graph attention network is designed to realize the embedding representation update of the knowledge graph. Figure 1 ​The EKG is encoded by TransE, and the representation space of the input result is The LLM encoder part contains different large language models, which are used to encode unstructured data, and the representation space of the output result is and is aligned with the knowledge graph representation space through linear transformation, and the result of the initial encoding is represented using , , In the multi-layer encoder architecture, the HKG is first processed using a head attention mechanism, different are calculated, and after regularization and combination operations, the is obtained. The HKG module in the subsequent message passing module performs subgraph pruning according to , and outputs the adjacency matrix of the HKG structure, and the new entity embedding and the relationship embedding ; In the EKG aggregation module, the EKG is aggregated using a head attention mechanism, and represents the attention weight between triples, and the final output result is ; The second step is as follows: Step (2.1) is based on the construction of a large language model text encoder, and the process is as follows: Step (2.1.1) inputs the unstructured text obtained in step (1.1.3) into the large language model, and extracts the hidden state output of the last layer of the model: ; wherein is the large language model encoder, is the last layer hidden state output of the large language model related to the text ; Step (2.1.2) processes the last layer hidden state of the large language model using the following processing flow as the output of the text encoder: 1) For the encoder architecture model, the [CLS] marker output in the last layer is selected as the text embedding representation, and this step is represented by the formula , wherein the [CLS] marker is the first sequence of the hidden state output, which is usually used as the overall representation of the sequence; 2) For the decoder architecture of the large language model, the last non-padding marker embedding in the last layer output sequence is selected as the text embedding representation, and this step is represented by the formula ; 3) For large language models of encoder-decoder architecture, the present application calculates the average value of all embedding representations of the last layer hidden state as the final text embedding representation, which is represented by the formula , wherein represents the mean value calculation of all embedding representations of ; Step (2.1.3) inputs the output result of the text encoder into the full connection layer and the activation function layer to convert the feature dimension: ; wherein, is a linear conversion function, is an activation function, is the embedding representation of the output th text; wherein, and represent the text representation space and the knowledge graph representation space respectively, and the full connection layer and the activation function are common techniques in deep learning; Step (2.2) construction of heterogeneous knowledge graph (HKG) of mechanical and electrical equipment, the process is: Step (2.2.1) all entities and relationships in EKG are represented as nodes in HKG, at this time the node set in HKG is ; all are also nodes in HKG, and represents the text information node set; Step (2.2.2) the edges in HKG are defined as follows: in the initial HKG, each text information node in is connected to all nodes in , and for each node in , the subgraph matrix of is represented by ; The subgraph of contains itself and all text information nodes connected to ; Step (2.3) construction of HKG text information aggregation module, the process is: Step (2.3.1) based on TransE, the initial embedding representation of EKG is obtained, wherein the embedding of entities and relationships is represented by and respectively, and the feature dimension of is ; TransE is a commonly used knowledge graph embedding method; Step (2.3.2) uses the graph attention network to fuse the embedding representation of entities and relationships with text features. In this step, the present invention uses To jointly express or : ; ; in, is the parameterized linear transformation matrix, For the shared attention mechanism, Represents a node set The Nodes ( or ), is a commonly used nonlinear activation function. The function is used to calculate the relative attention value, Representation node With the Attention weights between text items; In order to obtain more stable results in step (2.3.3), the present invention adds a multi-head attention mechanism to calculate the attention weights between nodes, which can be expressed as: ; in, represents the number of attention heads, To pass the Attention heads Calculated.

[0028] Step (2.4) HKG pruning module construction process is as follows: Step (2.4.1) defines hyperparameters , used to measure the amount of text information that needs to be retained; Step (2.4.2) calculates the value obtained in step (2.3.3) Combine according to the nodes, that is, use Representation node The attention weight matrix between each text information node; Step (2.4.3) combined and To prune HKG, the process is as follows: Step (2.4.3.1) Each node in Update the embedded representation: ; ; in, Function returns the maximum The index of the attention value, Defined by step (1.3.1) Article text, For index operations, Represents the associated attention mask. By pooling unimportant text nodes, a new entity relationship embedding representation is obtained: ; in, represents the element-wise product operation, is an embedded representation that integrates text information, but at this time Only with The text embeddings with the highest correlation are aggregated; Step (2.4.3.2) calculates Normalize and input the activation function to obtain the output result of the HKG pruning module. This step can be expressed as ,at this time Embedding representation representing the updated entity Or the embedding representation of the relationship ; is a commonly used activation function. It is a normalization method; Step (2.4.3.3) for Each node in ,right The subgraph structure is updated: ; in, Represents the adjacency matrix of row index and column index, indicating that the adjacency matrix will be connected to the Links between texts with low relevance are removed. yes The subgraph adjacency matrix output of ; Step (2.5) EKG feature aggregation module is constructed. For the new entity and relationship embedding representation calculated in step (2.4), the triple-level attention mechanism is used to aggregate neighborhood information. The process is as follows: Step (2.5.1) combines the entity and relation embeddings in the triple to obtain the embedding representation of the triple: ; in, is the parameterized linear transformation matrix, 、 、 is the embedding representation of the head entity, the relation and the tail entity fused with the text information, is the vector combination operation, is the embedding representation of the triple (i.e. ) composed of the three; Step (2.5.2) calculates the attention value of the triple through the weight matrix and the nonlinear activation function ; wherein, is the weight matrix, is the absolute attention value of the triple calculated; Step (2.5.3) calculates the relative attention value using ; wherein, represents the embedding of the triple ( , , ), represents all the neighbor nodes of the entity , represents the set of relations between and its neighbor nodes ; Step (2.5.4) In order to obtain more stable results, the application adds a multi-head attention mechanism to calculate the relative attention value between triples, and the entity embedding can be updated as: ; wherein, represents the number of attention heads; Step (2.5.5) normalizes and inputs it into the activation function to obtain the output of the encoder model, i.e. ; Step (2.5.6) takes the relation embedding representation calculated in step (2.4.3.2) as the output of the encoder model, i.e. .

[0029] Thirdly, the decoded knowledge graph embedding is decoded in combination with the decoder to perform the link prediction task, as shown in the decoder part of Figure 1 ; The process is as follows: Step (3.1) The application uses ConvKB as the decoder module, and the target of the link prediction is to calculate a triple ​​the higher the score, the more likely the triple is true. ConvKB is a commonly used knowledge graph link prediction decoder model; Step (3.2) The score function of ConvKB is defined as ; wherein, and denote the head entity and tail entity of the triple, respectively, and their embedding representations are calculated by step (2.5.5), the embedding representation of is obtained by step (2.5.6), denotes the convolution operation, denotes the layer convolution kernel, is the number of convolution kernels, denotes the weight matrix used to calculate the predicted score of the triple, and are shared hyperparameters independent of ; Step (3.3) The loss function is defined as follows: ; ;

[0030] wherein, is the knowledge graph data, is obtained by performing negative sampling operation on , is a set hyperparameter, denotes the square operation of the L2 norm of the parameter; negative sampling is a commonly used technique to obtain negative samples.

[0031] The mechanical and electrical equipment knowledge graph link prediction method of the fusion large language model of the embodiment is compared and explained as follows: Step one, give 12 kinds of knowledge graph link prediction methods, as follows: TransE: a translation-based link prediction method that learns vector representations of entities and relationships by minimizing the distance between the vectors of the head entity and the tail entity of a triple.

[0032] DistMult: a translation-based link prediction method that captures relationships between entities by using a symmetric three-linear product.

[0033] RotatE: a translation-based link prediction method that models entities and relationships in the complex plane.

[0034] Rotate4D: a translation-based link prediction method that models entities and relationships in the quaternion space.

[0035] R-GCN: A neural network-based method that learns the neighborhood information of triples through convolution techniques.

[0036] ConvE: A neural network-based method that uses multi-layer convolutional neural networks to learn different features.

[0037] ConvKB: A neural network-based method that represents triplets as 3-column matrices and performs information fusion through convolution.

[0038] CompGCN: A neural network-based approach that integrates multi-relation information into convolutional networks to learn representation features of multi-relation graphs.

[0039] KBGAT: A neural network-based method that uses triple embedding representations to replace entity embedding representations for neighborhood information aggregation.

[0040] KG-BERT: A language model-based approach that uses BERT to encode triples and their corresponding text descriptions into continuous text sequences to achieve knowledge reasoning.

[0041] SimKGC: A language model-based approach that combines pre-trained language models with contrastive learning methods to learn features from knowledge graphs.

[0042] PDKGC: A language model-based method that completes knowledge graph link prediction by training only on prompt words.

[0043] Step 2: The electromechanical equipment knowledge graph constructed for the present invention contains a total of 7,673 entity pairs and 5,996 unstructured texts.

[0044] Step 3: Define the evaluation indicators as follows: To verify the performance of the large language model text encoder, this paper uses the following evaluation indicators and selects link prediction experiments to evaluate the model performance: MRR: represents the average reciprocal of the number of true triplets in the test set. The larger the value, the better. The formula is as follows: ; in, represents the rank number of the triple, N is the total number of candidate entities.

[0045] Hits@n: indicates that in link prediction, the ranking is less than The proportion of triples, the larger the value, the better. ; in, denotes the number of triples satisfying the ranking less than The application selects Hits@1, Hits@3 and Hits@10 for evaluation.

[0046] Step four, analyze and compare the results; Referring to Table 1, the link prediction results of each model in the mechanical and electrical equipment knowledge graph are shown, and the optimal experimental indicators are marked in bold in Table 1, and the suboptimal is marked with an underline.

[0047] Table 1 is a link prediction result table of each model in the mechanical and electrical equipment knowledge graph,

[0048] From Table 1, compared with the traditional translation-based and neural network-based methods, the language model-based method has achieved better results, which shows that using pre-trained language models or large language models for assistance can obtain more accurate knowledge graph embedding representations and improve the accuracy of link prediction. Among these methods, the method proposed in the application achieves the optimal results in MRR, Hits@1 and Hits@10, and the suboptimal result in Hits@3. PDKGC is only inferior to the method of the application, and the MRR, Hits@1 and Hits@10 values are 0.035, 0.026 and 0.02 lower than the optimal result respectively. KG-BERT and PDKGC use entity and relationship names to model entity relationships, however, the semantic information of a single entity name is far less than a paragraph of text used by the application; at the same time, the application combines the graph pruning technique to fuse text information, fully excavates more important features, and further aggregates neighborhood information through a triple-level graph attention network, which may be the reason why the application achieves the optimal result. In the traditional method, Rotate4D achieves better results, but the results of each indicator are still about 0.03-0.07 lower than the application. Although the traditional method considers the semantic information or graph structure information between entities and relationships, compared with the application, it lacks text information to supplement entities and relationships, which leads to the model being unable to further excavate the deep features of EKG.

[0049] The fusion large language model-based mechanical and electrical equipment knowledge graph link prediction method of the embodiment is compared as follows: Since most open source large language models have many versions with different parameter quantities, and the parameter quantity is also an important indicator to measure the performance of the large language model, therefore, the present application takes Qwen and Llama as an example, selects the 0.5B, 1.5B, 3B and 7B versions of Qwen2.5 and the 1B, 3B and 8B versions of Llama3 as the large language model text encoder in the method proposed in the present application to explore the influence of parameter quantity on the performance of the method proposed in the present application. Table 2 shows the MRR index results in the link prediction experiment, in the Qwen2.5 model, the 7B version with the largest parameter quantity achieves the best MRR result, and as the parameter quantity increases, the model performance also shows an upward trend. While the Llama3 model is the same as the Qwen2.5, as the parameter quantity increases, the model performance gradually improves. This also proves that under the condition of having enough computing resources, it is helpful to choose a large language model with larger parameter quantity to improve the performance of the model.

[0050] Table 2 is a table of MRR index results in the link prediction experiment,

[0051] Embodiment 4 The mechanical and electrical equipment knowledge graph link prediction method of the fusion large language model of the present embodiment is compared and explained as follows: Since part of the data recorded by human may have errors or abnormal phenomena, the Internet of Things system may also cause abnormal data recording due to network failure and other reasons. Therefore, when there is noise interference in the EKG, it is very important whether the present application can normally cope with such phenomena and has relatively stable performance.

[0052] In view of the above phenomenon, the present application randomly increases or deletes part of the edges in the test set to analyze the stability of the method, and table 3 and table 4 respectively show the experimental results of deleting and adding edges. It can be found from the data of the two tables that abnormal data and noise will affect the performance of the model, but the influence is mainly on the MRR and Hits1 indicators, and the influence on Hits3 and Hits10 is small. The Hits10 indicator indicates that in the link prediction experiment, the proportion of triples with a ranking less than 10, the larger the value, the better the overall performance of the method. Therefore, the two experiments in table 3 and table 4 show that although the method proposed in the present application will be disturbed by abnormal data to a certain extent, it still has stability in overall performance and has certain practicality in actual application scenarios.

[0053] Table 3 is a table of experimental results of the proportion of randomly deleted edges,

[0054] Table 4 is a table of experimental results of randomly adding edges,

[0055] The embodiments of the present specification are merely illustrative of the implementation forms of the inventive concept, and are only used for the purpose of illustration. The protection scope of the present application should not be regarded as being limited to the specific forms shown in the embodiments, and the protection scope of the present application also encompasses equivalent technical means that can be thought of by those skilled in the art according to the inventive concept.

Claims

1. A method for predicting links in a knowledge graph of electromechanical equipment integrating a large language model, characterized in that: The method comprises the following steps: The first step is to combine fine-tuning the large language model with prompt engineering to build the electromechanical equipment knowledge graph EKG. The process is as follows: Step (1.1) Data collection and processing; Step (1.2) fine-tuning of the large language model; Step (1.3) performs entity and relation extraction based on the fine-tuned large language model, automatically extracting triples from a large amount of unstructured text data; Step (1.4) For structured data with clear entity relationships, corresponding triples are obtained through analysis and screening, and are directly used for EKG construction; Step (1.5) Construct a knowledge graph of electromechanical equipment based on the triple information extracted from unstructured data and structured data ,in and Represent entity sets and relationship sets respectively, and store data in graph databases; In the second step, for the constructed EKG, an encoder with a multi-layer graph attention network is designed to update the embedding representation of the knowledge graph. The process is as follows: Step (2.1) builds a text encoder based on a large language model; Step (2.2) Construction of heterogeneous knowledge graph HKG of electromechanical equipment; Step (2.3) Construction of HKG text information aggregation module; Step (2.4) HKG pruning module construction; Step (2.5) EKG feature aggregation module is constructed. For the new entity and relationship embedding representations calculated in step (2.4), a triple-level attention mechanism is used to aggregate neighborhood information. The third step is to combine the decoder to decode the encoded knowledge graph embedding and perform the link prediction task.

2. The electromechanical equipment knowledge graph link prediction method integrating a large language model according to claim 1 is characterized in that: The process of step (1.1) is: Step (1.1.1) collects unstructured text data related to electromechanical equipment and stores the collected data for processing; Use crawler technology to obtain encyclopedia data related to electromechanical equipment from the Internet; Step (1.1.2) collects structured data from the electromechanical equipment IoT system and stores it in a relational database; In step (1.1.3), for unstructured text data, the overly long text data is truncated to fit the input length limit of the large language model.

3. The electromechanical equipment knowledge graph link prediction method integrating a large language model as claimed in claim 2 is characterized in that: The process of step (1.2) is: Step (1.2.1) constructs an entity extraction fine-tuning dataset, in which entities and entity types in the original text of electromechanical equipment are labeled, where entity types include subsystem, component, fault category, fault phenomenon, fault cause, maintenance type, maintenance item, and maintenance countermeasures; Step (1.2.2) constructs a relation extraction fine-tuning dataset. In this dataset, based on the entities marked in step (1.2.1), the complete triples in the original text are further marked, but the entity types are no longer marked repeatedly. Step (1.2.3) Design prompt words for the large language model, which include prompt words for entity extraction and prompt words for relationship extraction; In step (1.2.4), the fine-tuning dataset is used to fine-tune the large language model based on the LoRA fine-tuning technology and combined with the prompt words to build the entity extraction and relation extraction large language models respectively; Step (1.2.5) Based on LoRA fine-tuning, use the entity extraction fine-tuning dataset to train the entity extraction large language model; Step (1.2.6) is again based on LoRA fine-tuning, using the relation extraction fine-tuning dataset to train the relation extraction large language model; Step (1.2.7) Step (1.2.5) and Step (1.2.6) respectively use two fine-tuning training sets to fine-tune the large language model and obtain the entity extraction large language model Large language model with relation extraction , and is used for subsequent triple extraction of unstructured text.

4. The electromechanical equipment knowledge graph link prediction method integrating a large language model according to any one of claims 1 to 3, characterized in that: The process of step (1.3) is: Step (1.3.1) first performs entity extraction. For a given input text, compare it with the predefined Combine and then input the model , get entity extraction results ; Step (1.3.2) performs relation extraction based on the results of entity extraction, and then converts the input text, predefined , entity extraction results Combine and input model , get the final output triple result.

5. The electromechanical equipment knowledge graph link prediction method integrating a large language model as described in claim 2 or 3 is characterized in that: The process of step (2.1) is as follows: Step (2.1.1) inputs the unstructured text obtained in step (1.1.3) into the large language model and extracts the hidden state output of the last layer of the model; Step (2.1.2) uses the following processing flow to process the last hidden state of the large language model as the output of the text encoder: 1) For the encoder architecture model, the [CLS] token output by the last layer is selected as the text embedding representation; 2) For large language models with decoder architectures, the last non-padded token in the last layer output sequence is chosen as the text embedding representation; 3) For the large language model of the encoder-decoder architecture, the average of all embedded representations of the last hidden state is calculated as the final text embedding representation; Step (2.1.3) inputs the output of the text encoder into the fully connected layer and the activation function layer to perform feature dimension conversion to obtain , For the Embedded representation of a text.

6. The electromechanical equipment knowledge graph link prediction method integrating a large language model as claimed in claim 5 is characterized in that: The process of step (2.2) is: In step (2.2.1), all entities and relationships in EKG are represented as nodes in HKG. The node set in HKG is ; all Also as a node in HKG, use Represents a set of text information nodes; Step (2.2.2) The edges in HKG are defined as follows: In the initial HKG, Each text information node in All nodes in are connected, and for each Nodes in ,use express The subgraph matrix of The subgraph contains Self and all Connected text information nodes .

7. The electromechanical equipment knowledge graph link prediction method integrating a large language model as claimed in claim 6 is characterized in that: The process of step (2.3) is: Step (2.3.1) obtains the initial embedding representation of EKG based on TransE, where the embedding of entities and relations are respectively and to express, and The feature dimensions of ; Step (2.3.2) uses the graph attention network to fuse the embedding representations of entities and relations with text features; Step (2.3.3) In order to obtain more stable results, add a multi-head attention mechanism to calculate the attention weights between nodes ; The process of step (2.4) is: Step (2.4.1) defines hyperparameters , used to measure the amount of text information that needs to be retained, Step (2.4.2) calculates the value obtained in step (2.3.3) Combine according to the nodes, that is, use Representation node The attention weight matrix between each text information node; Step (2.4.3) combined and Perform HKG pruning.

8. The electromechanical equipment knowledge graph link prediction method integrating a large language model as claimed in claim 7 is characterized in that: The process of step (2.4.3) is: Step (2.4.3.1) Each node in Update the embedding representation by pooling unimportant text nodes to obtain a new entity relationship embedding representation ; Step (2.4.3.2) calculates Normalize and input the activation function to obtain the output result of the HKG pruning module; Step (2.4.3.3) for Each node in ,right The subgraph structure is updated.

9. The electromechanical equipment knowledge graph link prediction method integrating a large language model as claimed in claim 7 is characterized in that: The process of step (2.5) is: Step (2.5.1) combines the entity and relation embeddings in the triple to obtain the embedding representation of the triple; Step (2.5.2) is done by using the weight matrix and nonlinear activation function Calculate the attention value of the triple; Step (2.5.3) use Function calculates relative attention value; In order to obtain more stable results, step (2.5.4) adds a multi-head attention mechanism to calculate the relative attention value between triplets. The entity embedding can be updated as ; Step (2.5.5) Normalize and input into the activation function to obtain the output of the encoder model; Step (2.5.6) takes the relation embedding representation calculated in step (2.4.3.2) as the output of the encoder model.

10. The electromechanical equipment knowledge graph link prediction method integrating a large language model according to any one of claims 1 to 3, characterized in that: The process of the third step is as follows: Step (3.1) uses ConvKB as the decoder module. The goal of link prediction is to calculate a triplet through the score function The higher the score, the greater the possibility of the triple being established; The score function of step (3.2) ConvKB is defined as ; in, and Represent the head entity and tail entity of the triple respectively, and their embedding representation is calculated by step (2.5.5), The embedding representation of is obtained by step (2.5.6), represents the convolution operation, Indicates the layer convolution kernel, is the number of convolution kernels, represents the weight matrix used to calculate the prediction score of the triple, and All with Unrelated shared hyperparameters; The loss function in step (3.3) is defined as follows: ; ; in, is the knowledge graph data, Through Perform negative sampling operation to obtain, is the set hyperparameter, Indicates the square operation of the L2 norm of the parameter.

Citation Information

Patent Citations

  • Knowledge reasoning method based on industrial mechinery fault diagnosis knowledge graph

    CN113961718A

  • Knowledge graph link prediction method based on multi-source heterogeneous data fusion

    CN115391563A

  • Knowledge graph construction method and device based on pre-trained large language model

    CN117851610A

  • Predictive maintenance method for electromechanical equipment fused with time sequence knowledge graph

    CN119005321A

  • Knowledge graph link prediction method fusing multi-source information

    CN119204195A

Cited By

  • Business influence driven parameter fine tuning and adaptive structure pruning-based fault prediction method and system

    CN121350511A

  • Power transformation maintenance operation knowledge graph construction method and device and computer equipment

    CN122264068A

  • A power transformation maintenance operation knowledge graph construction method and device and computer equipment

    CN122264068B