Process industry safety knowledge graph error detection method and system based on large language model
Through the process industrial safety knowledge graph error detection method based on large language model, similar nodes and neighbor nodes are retrieved using vector and text matching to form similar subgraphs, which solves the conflicts or omissions in knowledge graph error detection in the prior art, and realizes automatic discovery and correction of error triples in the knowledge graph, improving detection efficiency and reliability.
Patent Information
- Application Number
- CN202411757282.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-03
AI Technical Summary
The existing technology has conflicts or omissions in the correctness detection of large-scale complex correlation knowledge graph triplets, resulting in the inability to effectively discover and correct errors in the knowledge graph, which in turn leads to the unreliability of application analysis results.
The process industrial safety knowledge graph error detection method based on large language models is adopted, and the vector library is generated through the knowledge graph embedding method, and similar nodes and neighbor nodes are retrieved using vector similarity matching and text similarity matching methods to form similar subgraphs, and error detection and correction are performed through the large language model.
It realizes automatic discovery and correction of error triplets in the knowledge graph, solves omissions or conflicts caused by manual and regular methods, and improves the efficiency and reliability of knowledge graph error detection.
Smart Images

Figure CN119740644A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a process industry safety knowledge graph error detection method and system based on a large language model. Background Art
[0002] With the increasingly sophisticated industrial production processes, the complexity of the system and the security risks it faces are gradually increasing. Faced with increasingly complex scenarios where functional safety and information security issues such as increasingly complex equipment failures and malicious attacks are intertwined, manual analysis faces problems such as information overload and lack of sustainability. Based on the idea of knowledge data fusion, the knowledge graph technology is used to integrate various types of knowledge such as communication, control, process and safety involved in the process of process industry safety analysis, and the simulation of manual processing based on artificial intelligence methods will greatly improve the efficiency of discovery, evaluation and disposal of safety incidents in complex scenarios. However, due to the existence of noise in multi-source heterogeneous data and imperfect automated extraction algorithms during the construction of the knowledge graph, the initially constructed knowledge graph has some knowledge triple errors such as entity types, relationships and attributes. Therefore, the detection and correction of errors in the process industry safety knowledge graph is the basic guarantee for the effectiveness of safety reasoning and decision-making.
[0003] Existing knowledge graph error detection generally uses manual or rule-based error detection methods. Manual error detection methods use domain experts to traverse and analyze knowledge graphs. When node associations are too complex, there is often an information overload problem that leads to the omission of important judgment factors. Rule-based knowledge graph error detection methods use domain experts to predefine detection rules and determine the correctness of triples through logical reasoning. However, the process of defining rules based on expert knowledge has problems such as high labor costs, incomplete rule sets, and even conflicts in large-scale knowledge graph applications.
[0004] In view of the above analysis, the technical problem that urgently needs to be solved in the existing technology is that in the correctness detection of triples in large-scale complex associated knowledge graphs, due to the possible conflicts or omissions between manual and rule-based logical reasoning methods, the errors in the existing constructed knowledge graphs cannot be effectively discovered and corrected, resulting in unreliable application analysis results.
[0005] Through the above analysis, the problems and defects of the prior art are as follows:
[0006] In the triple correctness detection of large-scale complex associated knowledge graphs, there may be conflicts or omissions between manual and rule-based logical reasoning methods, which may lead to errors in the existing constructed knowledge graphs and make the application analysis results unreliable. Summary of the invention
[0007] In view of the problems existing in the prior art, the present invention provides a process industry safety knowledge graph error detection method based on a large language model.
[0008] The present invention is implemented as follows: a process industry safety knowledge graph error detection method based on a large language model includes:
[0009] Step 1: Based on the constructed process industry safety knowledge graph, obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity>, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template;
[0010] Step 2: extract a single triple to be detected from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through the vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes and corresponding edges from the knowledge graph through the text similarity matching method, merge them into a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results together constitute the knowledge graph error detection context;
[0011] Step 3: According to the predefined template format, the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph through predefined conversion rules are input into the large language model; based on the text description context composed of similar subgraphs, the triple to be detected is analyzed according to the entity type, relationship type and attribute error detection order; the judgment result and corresponding reasoning process of whether the triple to be detected has an error are output, and the knowledge graph is updated based on the judgment result.
[0012] Furthermore, the construction of the knowledge graph triple set and vector library in step 1 specifically includes: based on the constructed process industry safety knowledge graph, according to different knowledge graph representation modes such as RDF and property graph, all triples in the knowledge graph are extracted and stored in the format of <head entity, relationship, tail entity>; the knowledge graph vector library generation process selects a knowledge graph embedding model, trains the knowledge graph embedding model based on the constructed knowledge graph, and stores the vector results of the nodes and edges output by the finally trained model to form a knowledge graph vector library;
[0013] Step 1 of constructing a large language model prompt template for knowledge graph error detection includes: first, determining a system prompt sentence template specific to the current large language model based on the large language model dialogue standard prompt template; then, constructing a corresponding large language model task prompt word template based on the nodes, relationships, and attribute types of the knowledge graph error detection; wherein, for node type error detection, it should be based on the pattern of similar nodes and their corresponding relationships to determine whether the current node has a type error problem; for relationship type error detection, it should be based on the types of the head node and the tail node and the connection pattern of similar edges; for attribute type errors, it can be determined by the attribute values and types of similar nodes.
[0014] Furthermore, the step 2, based on a single triple to be detected, retrieves the corresponding similar nodes and neighbor nodes, and the process includes: first, based on the triple to be detected, retrieves the corresponding encoding vector from the vector library, and sorts them according to the similarity, and retrieves the first K similar nodes of the non-triplets to be detected in the knowledge graph based on the vector cosine similarity; then, after merging it with the triple to be detected, retrieves the similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph based on the text similarity evaluation algorithm through the type and attribute description text of the head entity, relationship and tail entity in the triple, and merges the retrieval results to obtain a similar subgraph; finally, based on the merged subgraph, retrieves a similar graph structure subgraph through the graph structure pattern; merges the above three retrieval results to form the context of the triple to be detected; wherein, the subgraph merging process is to merge them if they have the same head or tail node.
[0015] Furthermore, in step 3, based on a predefined template, the knowledge graph triple to be detected and the context information are input into the large language model in the form of text, and a multi-round dialogue method of nodes, relationships and attributes is used to determine whether there is an error in the knowledge graph triple, and the reasoning process is output;
[0016] The knowledge graph triple error judgment reasoning process is the textual output of the reasoning analysis step of the large language model in the process of knowledge graph error detection.
[0017] Furthermore, the triplet error detection process based on predefined templates through multi-round dialogue includes three stages: node type error detection, node relationship type detection, and attribute detection;
[0018] The node type error detection uses a large language prompt word template to input the knowledge graph triple node to be detected and the corresponding context subgraph description text into the large language model, and outputs the result of whether there is an error in the node type;
[0019] The specific process of the relationship type detection is as follows: if there is an error in the type of the head entity or the tail entity, the knowledge graph triple is directly output to indicate that there is an error, and the reasoning process of the specific error is output in text form; if the types of the head entity and the tail entity are correct, the node and edge to be detected and the corresponding context subgraph description text are input into the large language model through the relationship error detection large language model task prompt word template, and the result of the determination of whether there is an error in the relationship type is output;
[0020] Optionally, the specific process of attribute detection is: if the head and tail entity types and corresponding relationships are correct, the text description corresponding to the triple and the text description corresponding to the context subgraph are input into the large language model according to the attribute detection template, and the result of whether the corresponding attribute has an error is output.
[0021] Furthermore, in step 3, the knowledge graph is updated based on the reasoning results of the large language model; the node types, relationship types and correctness of the attributes of the triples to be detected in the knowledge graph are identified based on the large language model, and the knowledge graph update process is guided; the guided update process can choose to directly update the knowledge graph based on the reasoning results of the large language model or to update it after secondary verification manually.
[0022] Another object of the present invention is to provide a process industry safety knowledge graph error detection system based on a large language model, comprising:
[0023] The template definition module is used to obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity> based on the constructed process industry safety knowledge graph, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template;
[0024] The question generation module is used to extract a single triple to be detected and the corresponding context from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through the vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes from the knowledge graph through the text similarity matching method, merge them into a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results together form the knowledge graph error detection context;
[0025] The error judgment module is used to input the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph through predefined conversion rules into the large language model according to the predefined template format, analyze the triple to be detected according to the entity type, relationship type and attribute error detection order based on the text description context composed of similar subgraphs, output the judgment result and corresponding reasoning process of whether the triple to be detected has an error, and guide the update of the knowledge graph based on the judgment result.
[0026] Another object of the present invention is to provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the process industry safety knowledge graph error detection method based on a large language model.
[0027] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of the process industry safety knowledge graph error detection method based on a large language model.
[0028] Another object of the present invention is to provide an information data processing terminal, which is used to implement the process industry safety knowledge graph error detection system based on the large language model.
[0029] In combination with the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solutions to be protected by the present invention are as follows:
[0030] First,
[0031] The present invention proposes a method for detecting errors in process industry safety knowledge graphs based on a large language model. Based on graph retrieval enhancement generation technology, the constructed process industry safety knowledge graph is used as an external knowledge source. The knowledge triple detection context is formed through multiple retrieval methods of text, vector and graph structure models. The large language model reasoning ability is combined with external knowledge input. Under the premise of no high resource consumption and complicated model fine-tuning process, the correctness of the corresponding triples to be detected and the corresponding reasoning process are output through a dialogue method. The method proposed in the present invention has the processing ability of large-scale knowledge graph nodes and complex relationships, and realizes the automatic discovery process of erroneous triples in the knowledge graph without manual intervention, which solves the omission or conflict problems caused by manual and rule-based methods, and greatly improves the efficiency of knowledge graph error detection.
[0032] 1. The present invention provides a method for error detection of process industry safety knowledge graph based on a large language model. In the preparation stage, firstly, a set of all knowledge triples is obtained based on the process industry safety knowledge graph, and the nodes and relationships in the knowledge graph are transformed into vector space based on the knowledge graph embedding method to generate a vector library corresponding to the knowledge graph; then, according to the knowledge graph ontology and the selected large language model, the system and task prompt word template of the knowledge graph error detection large language model are defined. In the knowledge graph error detection stage, firstly, a single triple to be detected is extracted from the knowledge graph triple set; then, similar nodes and their N-order neighbor nodes are retrieved and screened from the knowledge graph library in sequence through vector and text matching to form similar subgraphs, and similar subgraphs are expanded based on graph pattern matching to form the context of triple error detection. According to the predefined prompt word template, the triple information and context are input into the large language model, and the representation mode comparison and reasoning analysis of similar nodes and neighbor nodes based on the large language model is realized to determine the correctness of the triple to be detected, and the knowledge graph is updated based on this result.
[0033] The present invention is based on the scenario where the proportion of erroneous triples in the constructed knowledge graph is low, based on the association pattern of similar nodes and neighboring nodes, and through the reasoning and analysis capability of a large language model. Under the condition of reducing labor costs, it enhances the generation idea based on graph retrieval. While improving the efficiency of error detection in the knowledge graph, the interpretability of the analysis process is retained through the analysis process in a graphical way, and at the same time, it avoids the problem of conflicts or omissions in detection results caused by the completeness of artificial expert rule settings.
[0034] 2. Furthermore, the present invention provides a process industry safety knowledge graph error detection method based on a large language model, which utilizes the excellence of large language model reasoning to reduce the limitations of expert rules in traditional methods, and provides explainable answers compared to machine learning methods.
[0035] 3. Furthermore, the process industry safety knowledge graph error detection method based on a large language model provided by the present invention does not require the introduction of supervised corpus compared to the traditional "pre-training + fine-tuning" large model paradigm, and can avoid the problem of excessive difference between downstream tasks and the basic large model.
[0036] 3. Furthermore, the process industry safety knowledge graph error detection method based on a large language model provided by the present invention provides a global, multi-level context information including the node’s own text and graph structure for the large model, compared to the traditional RAG system that retrieves fragments based on semantic similarity. The method based on graph retrieval enhanced generation (GraphRAG) provides the large model with global, multi-level context information, including the node’s own text and graph structure, thereby effectively improving the accuracy of the large language model reasoning.
[0037] 4. Furthermore, the process industry safety knowledge graph error detection method based on a large language model proposed in the present invention effectively improves the efficiency of error detection, enhances the reliability of the knowledge graph, and thereby ensures the effectiveness of process industry safety reasoning and decision-making.
[0038] Second, as auxiliary evidence of the inventiveness of the claims of the present invention, it is also reflected in the following important aspects:
[0039] (1) The expected benefits and commercial value of the technical solution of the present invention after transformation are:
[0040] The present invention provides an automatic knowledge graph error detection method based on a large language model. The error detection process does not require the intervention of domain experts, and the judgment results have strong interpretability, which solves the problems of large-scale time consumption and information overload caused by artificial factors in actual industrial production. In addition, there is no need to fine-tune the large language model during the application process, making it easier to deploy in actual industrial applications.
[0041] (2) The technical solution of the present invention solves a technical problem that people have been eager to solve but have never been able to solve successfully:
[0042] How to apply human knowledge in intelligent analysis algorithms is the core issue in the transition of artificial intelligence from perceptual intelligence to cognitive intelligence. The present invention focuses on solving the problem of how to ensure the accuracy of human knowledge representation. By detecting and correcting whether there are erroneous triples in the knowledge graph, the effectiveness of the expert knowledge input into the intelligent analysis algorithm is guaranteed.
[0043] (3) The technical solution of the present invention overcomes technical prejudice:
[0044] The present invention uses the complete knowledge graph as the external knowledge base for reasoning and analysis of the large language model, and effectively alleviates the problem of unreliable application of the large language model in actual industrial production due to the "hallucination" problem through a retrieval enhancement generation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a flow chart of a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present invention.
[0046] Figure 2 It is a structural block diagram of a process industry safety knowledge graph error detection system based on a large language model provided in an embodiment of the present invention.
[0047] Figure 3 It is a schematic diagram of the principle of a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present invention.
[0048] Figure 4It is an overall flow chart of a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present invention.
[0049] Figure 5 It is a specific embodiment diagram used to illustrate the steps in a process industry safety knowledge graph error detection method based on a large language model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0051] like Figure 1 As shown, a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present invention includes the following steps:
[0052] S101, based on the constructed process industry safety knowledge graph, obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity>, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template;
[0053] S102, extract a single triple to be detected from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through a vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes and their corresponding relationships from the knowledge graph through a text similarity matching method, merge them to form a similar subgraph, and further expand the similar subgraph based on a graph pattern matching method, and use the retrieval results to form a knowledge graph error detection context;
[0054] S103, according to the predefined template format, the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph through predefined conversion rules are input into the large language model, based on the text description context composed of similar subgraphs, the triple to be detected is analyzed according to the entity type, relationship type and attribute error detection order, the judgment result and corresponding reasoning process of whether the triple to be detected has an error are output, and the knowledge graph is updated based on the judgment result.
[0055] The knowledge graph triple set and vector library construction described in S101 provided in the embodiment of the present invention specifically includes: based on the constructed process industry safety knowledge graph, according to different knowledge graph representation modes such as RDF and attribute graph, all triples in the knowledge graph are extracted and stored in the format of <head entity, relationship, tail entity>; the knowledge graph vector library generation process selects a knowledge graph embedding model, trains the knowledge graph embedding model based on the constructed knowledge graph, and stores the vector results of the nodes and edges output by the finally trained model to form a knowledge graph vector library;
[0056] S101 constructs a large language model prompt template for knowledge graph error detection, including: first, determining a system prompt sentence template specific to the current large language model based on the large language model dialogue standard prompt template; then, constructing a corresponding large language model task prompt word template based on the nodes, relationships, and attribute types of the knowledge graph error detection; wherein, for node type error detection, it should be based on the pattern of similar nodes and their corresponding relationships to determine whether the current node has a type error problem; for relationship type error detection, it should be based on the types of the head node and the tail node and the connection pattern of similar edges; for attribute type errors, it can be determined by the attribute values and types of similar nodes.
[0057] S102 provided by an embodiment of the present invention, the process of retrieving corresponding similar nodes and neighbor nodes based on a single triple to be detected includes: first, retrieving the corresponding encoding vector from the vector library based on the triple to be detected, and retrieving K similar nodes of the non-triplets to be detected in the knowledge graph with high similarity based on the vector cosine similarity, and then merging them with the node of the triple to be detected, through the type and attribute description text of the head entity, relationship and tail entity in the triple, based on the text similarity evaluation algorithm, retrieve similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph to form a similar adjacency relationship subgraph; then and based on the similar adjacency relationship subgraph, retrieve a similar graph structure subgraph through the graph structure pattern; merge the above retrieval results to form the context of the triple to be detected; wherein, the subgraph merging process is to merge them if the two have the same head or tail node.
[0058] S103 provided in an embodiment of the present invention, based on a predefined template, inputs the knowledge graph triple to be detected and the context information into a large language model, and determines whether there is an error in the knowledge graph triple through a multi-round dialogue method of nodes, relationships and attributes, and outputs its reasoning process; the knowledge graph triple error judgment reasoning process is the textual output of the reasoning analysis S10 of the large language model during the knowledge graph error detection process.
[0059] The triplet error detection process provided by the embodiment of the present invention based on the predefined template through a multi-round dialogue method includes three stages: node type error detection, node relationship type detection and attribute detection;
[0060] The node type error detection uses a large language prompt word template to input the knowledge graph triple node to be detected and the corresponding context subgraph description text into the large language model, and outputs the result of whether there is an error in the node type;
[0061] The specific process of the relationship type detection is as follows: if there is an error in the type of the head entity or the tail entity, the knowledge graph triple is directly output to indicate that there is an error, and the reasoning process of the specific error is output in text form; if the types of the head entity and the tail entity are correct, the node and edge to be detected and the corresponding context subgraph description text are input into the large language model through the relationship error detection large language model task prompt word template, and the result of the determination of whether there is an error in the relationship type is output;
[0062] Optionally, the specific process of attribute detection is: if the head and tail entity types and corresponding relationships are correct, the text description corresponding to the triple and the text description corresponding to the context subgraph are input into the large language model according to the attribute detection template, and the result of whether the corresponding attribute has an error is output.
[0063] S103 provided in an embodiment of the present invention updates the knowledge graph based on the reasoning results of the large language model; identifies the correctness of the node type, relationship type and attribute of the triple to be detected in the knowledge graph based on the large language model, and guides the knowledge graph update process; the guided update process can choose to directly update the knowledge graph based on the reasoning results of the large language model or update it after secondary verification manually.
[0064] like Figure 2 As shown, a process industry safety knowledge graph error detection system based on a large language model provided by an embodiment of the present invention includes:
[0065] The template definition module is used to obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity> based on the constructed process industry safety knowledge graph, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template;
[0066] The question generation module is used to extract a single triple to be detected from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through the vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes from the knowledge graph through the text similarity matching method, merge them into a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results together constitute the knowledge graph error detection context;
[0067] The error judgment module is used to input the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph through predefined conversion rules into the large language model according to the predefined template format, analyze the triple to be detected according to the entity type, relationship type and attribute error detection order based on the text description context composed of similar subgraphs, output the judgment result and corresponding reasoning process of whether the triple to be detected has an error, and guide the update of the knowledge graph based on the judgment result.
[0068] Another object of the present invention is to provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the process industry safety knowledge graph error detection method based on a large language model.
[0069] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of the process industry safety knowledge graph error detection method based on a large language model.
[0070] Another object of the present invention is to provide an information data processing terminal, which is used to implement the process industry safety knowledge graph error detection system based on the large language model.
[0071] The present invention is specifically implemented:
[0072] like Figure 3 The present invention provides a method for detecting errors in a process industry safety knowledge graph based on a large language model. The specific implementation steps of the present invention will be described in detail below by taking the information security knowledge graph constructed by multi-domain security knowledge such as communication, control, and process in an actual catalytic cracking unit as an example. Figure 4 As shown, the following steps are included:
[0073] Step 1: In the detection preparation stage, based on the constructed catalytic cracking unit information security knowledge graph, all knowledge triples <head entity, relationship, tail entity> contained in the knowledge graph are retrieved as the set of all triples to be detected; the nodes and relationships in the knowledge graph are encoded in vector space by the knowledge graph embedding method to generate a knowledge graph vector library; according to the knowledge graph ontology and the selected large language model, the knowledge graph entity, relationship and attribute error detection large language model system and task prompt word template are pre-defined;
[0074] Step 2: In the error detection stage, first, a single triple to be detected is extracted from the knowledge graph triple set. The first K similar nodes are retrieved from the knowledge graph vector library in descending order of similarity through the vector cosine similarity matching method and merged with the triple to be detected. Then, similar nodes and their N-order neighbor nodes and corresponding relationships are retrieved from the knowledge graph through the text similarity matching method to form a similar neighbor subgraph. Then, the graph pattern matching method is used to retrieve the similar graph structure subgraph. Finally, the above retrieval results are merged into subgraphs to form the knowledge graph error detection context.
[0075] Step 3: In the error detection stage, the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph according to the predefined template format through predefined conversion rules are input into the large language model, and the knowledge graph is updated based on the output judgment result of the triple to be detected and the corresponding reasoning process.
[0076] In one embodiment of the present application, in step 1, the constructed catalytic cracking unit information security knowledge graph represents the security knowledge involved in the production process of the catalytic cracking unit in a graphical manner. The knowledge graph triple set and vector library construction specifically include:
[0077] Based on the constructed catalytic cracking unit information security knowledge graph, we choose to use Neo4j property graph as the repository of the knowledge graph, extract all triples in the knowledge graph through Cypher statements, and store them in the format of <head entity, relationship, tail entity>; train the knowledge graph embedding model. In this embodiment, the TransE model is selected as the knowledge graph embedding model. Among them, A EM is the knowledge graph vector set, EM i It is a triple vector representation, using the head entity vector EM ih , relationship vector EM ir and the tail entity vector EM it The knowledge graph is represented by a triplet; the knowledge graph is vectorized and encoded to obtain the following results:
[0078] A EM={EM1,EM2,...,EM i ,...,EM m}
[0079] EM i = ih ,EM ir ,EM it >
[0080] EM ih =(emh1,emh2,...,emh i ,...,emh d )
[0081] EM ir =(emr1,emr2,...,emr i ,...,emr d )
[0082] EM it =(emt t ,emt2,...,emt i ,...,emt d )
[0083] The vector results of nodes and edges output by the trained model are stored in computer memory or hard disk to form a knowledge graph vector library.
[0084] In one embodiment of the present application, in step 1, the step of constructing a large language model prompt template for knowledge graph error detection includes:
[0085] First, the system prompt template exclusive to the current large language model is determined based on the selected large language model dialogue standard prompt template; then, different large language model task prompt word templates are constructed based on the nodes, relationships, and attribute types of the knowledge graph error detection;
[0086] Here we choose the GPT-4o model with strong Chinese language processing capabilities as the large language model for knowledge graph error detection, and set the system prompt word template as: "You are an expert in knowledge graph error triple detection. Now you are required to output the logic of results and judgments based on the input information and corresponding context according to the specific task requirements. Please strictly perform reasoning and analysis based on the given context. Please give the conclusion first and then give the specific reasoning process of the cause of the error."
[0087] Since there are differences in the judgment criteria for node type, relationship type and attribute error judgment, different task prompt word templates need to be formulated for the three types of tasks.
[0088] For the node type determination large language task, the prompt word template is defined as: "Please judge whether there is an error in the type of the head node and tail node of the input triple based on the association pattern of similar nodes and corresponding relationships in the given context. The given context is: {}, and the triple to be determined is: {}."
[0089] The prompt word template for the relation type determination large language task is defined as: "Please judge whether there is an error in the relation type of the input triple based on the similar head node, tail node and corresponding edge type in the given context. The given context is: {}, and the triple to be determined is: {}."
[0090] The prompt word template for the attribute judgment large language task is defined as: "Please judge whether there is an error in the input triple node attribute based on the attribute name and attribute value type of similar nodes in the given context. The given context is: {}, and the triple to be judged is: {}."
[0091] In one embodiment of the present application, in step 2, the process of retrieving corresponding similar node neighbor nodes and relationships based on a single triple to be detected to form a large language model error detection context includes:
[0092] Retrieve the encoding vector corresponding to the vector information of the triple to be tested from the vector library, and retrieve the knowledge graph node set of the top K nodes with higher similarity in the non-triple to be tested based on the vector cosine similarity, and merge it with the head and tail node set of the triple to be tested; the vector cosine similarity is defined as:
[0093]
[0094] Among them, EM i1 ·EM i2 is the dot product of two vectors, ||EM i1 ||,||EM i1 || is the norm of the two vectors, that is, the length of the vectors; if the two vectors are in the same direction, the cosine similarity is close to 1; if they are in opposite directions, it is close to -1; if they are completely unrelated, it is close to 0;
[0095] Based on the merged head and tail node sets, the Jaccard text similarity evaluation algorithm is used to retrieve similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph through the triple text information to form a knowledge graph subgraph (N is a positive integer) to form the initial context subgraph of the triple to be detected; wherein, the process of aggregating to form a subgraph is to merge them if they have the same head or tail node; wherein, the Jaccard text similarity evaluation algorithm is defined as:
[0096]
[0097] A is the text description information corresponding to the head or tail node in the triple to be detected, B is the node retrieved from the knowledge graph that is similar to the text description information of node A, N(A) is the text description character set of node A, N(A)∩N(B) describes the intersection size of N(A) and N(B), that is, the number of identical words; N(A)∪N(B) describes the union size of N(A) and N(B), that is, the total number of words contained in the text description character sets of nodes A and B.
[0098] Based on the initial context subgraph, a subgraph similar to the input initial context subgraph is retrieved through subgraph pattern matching, and the retrieval result is merged with the initial context subgraph to expand the initial context word graph and form a knowledge graph triple error detection context subgraph.
[0099] In one embodiment of the present application, in step 3, based on the retrieved similar subgraphs, they are converted into text descriptions according to the rules to form a knowledge graph error triple detection context, based on the predefined task prompt word template, the knowledge graph triple to be detected and the context information are input into the large language model, and the judgment of whether there is an error in the knowledge graph triple is realized through a multi-round dialogue method of nodes, relationships and attributes, and its reasoning process is output;
[0100] The process of converting the retrieved similar subgraphs into text descriptions according to the rules is to directly use the triple head entity as the subject of the sentence, the relationship as the predicate of the sentence, and the tail entity as the object of the sentence. If there are multiple triples, they are concatenated according to the sentence; Figure 5 The figure shows the context composition diagram of the knowledge graph error triple based on the large language model. The triple to be detected is "<TV1001,CONTROL,T1001> ", which retrieves the triple in the corresponding context subgraph through text and vector similarity retrieval as "<T1001,HAS STATE,TI1001> ,<TI1001,INPUT,TIC1001> ,<TIC1001,CONTROL,TV1001> ", and the sub-retrieval obtained by graph pattern matching Figure 3Tuple<T1304,HASSTATE,LI1311> ,<LI1311,INPUT,LICA1311> ,<LICA1311,INPUT,FIC1311> ,<LICA1311,CONTROL,FV1311> ,<FIC1311,CONTROL,FV1311> , the triple to be detected is converted into "the raw oil heat circuit temperature control valve adjusts the data confusion, where the raw oil heat circuit temperature control valve is an actuator type, data confusion is an attack technology type, and there is a regulation relationship between them"; the corresponding text and vector retrieval obtains the context triple converted into a text description: "Data confusion has raw oil temperature, the raw oil temperature value is input into the raw oil temperature controller and the raw oil temperature control valve is controlled by the raw oil temperature controller, where data confusion is an attack technology type, the raw oil temperature is a state type, the raw oil temperature controller is a controller type, and the raw oil temperature control valve is an actuator type". The graph pattern matching retrieval obtains the context triple converted into a text description: "The stabilization tower has a stable tower bottom liquid level, the stable tower bottom liquid level value is simultaneously input into the stable tower bottom liquid level controller and the gasoline hydrogenation flow controller, and the stable tower bottom liquid level controller outputs the control amount to the gasoline hydrogenation flow controller to achieve the regulation of the gasoline hydrogenation flow control valve". Finally, the above text, vector and context text description information obtained by graph pattern matching are filled into the corresponding large language model error detection prompt word template to form a large language model error detection problem.
[0101] The input of the context text description information of the triple combination to be detected into the large language model to perform the knowledge graph triple error judgment reasoning process is the textual output of the reasoning analysis step of the large language model in the process of knowledge graph error detection; specifically:
[0102] First, based on the knowledge graph node type error detection large language prompt word template, input the knowledge graph triple node to be detected and the corresponding context subgraph description text into the large language model, and output the result of whether the node type is wrong; for example: you are an expert in knowledge graph error triple detection, and now you need to output the corresponding results and judgment logic based on the input information and the corresponding context according to the specific task requirements. Please strictly perform reasoning and analysis based on the context. Please give the conclusion first and then give the specific reasoning process of the cause of the error. The given task is: Please determine whether the type of the input triple head node and tail node is wrong based on the association pattern of similar nodes and corresponding relationships in the given context. The given context is: "The crude oil heat circuit controller controls the crude oil heat circuit temperature control valve, the crude oil heat circuit temperature controller is the controller type, the crude oil heat circuit temperature control valve is the actuator type, and there is a regulation relationship between them" and "The crude oil heat circuit temperature control valve regulates the crude oil flow, where the crude oil heat circuit temperature control valve is the actuator type, the crude oil flow is the state type, and the relationship between them is a regulation relationship." The triplet to be determined is "<raw oil heat circuit temperature controller, control, crude oil heat circuit temperature control valve>".
[0103] According to the following process, if there is an error in the type of the head entity or the tail entity, the knowledge graph triple is directly output to indicate that there is an error, and the specific reasoning process of the error is output in text form;
[0104] After the large language model reasoning analysis, the final output result is: "The type of the triple T1001 to be detected is wrong. It should be of PLANT type. The reasons are as follows: the triple T1001 to be detected and its neighbor nodes form the same subgraph pattern as T1304, FV1311, FIC1311, LI1311 and T1304, FV1311, LIC1311, LI1311, all of which are PLANT-ACTUATOR-CONTROLLER-STATE, but T1001 is of TECHNIQUE type, which violates the similar subgraph pattern. There may be a type anomaly. Please confirm."
[0105] If the types of the head entity and the tail entity are correct, the node and edge to be detected and the corresponding context subgraph description text are input into the large language model through the relationship error detection large language model task prompt word template, and the result of the judgment whether there is an error in the relationship type is output;
[0106] Optionally, if the head and tail entity types and corresponding relationships are correct, the text description corresponding to the triple and the text description corresponding to the context subgraph are input into the large language model according to the attribute detection template, and the corresponding attribute error determination result is output;
[0107] The updating process of the knowledge graph is guided by the judgment results of the large language model on whether there are errors in the knowledge triple nodes and relationship types and the corresponding textual reasoning process; wherein, the updating process of the knowledge graph triples guided by the results can be secondary verification by manually reading the large language model analysis results, and after confirmation, the original knowledge graph can be manually updated, or the corresponding reasoning results can be automatically extracted by rules to automatically update the nodes and relationship types of the original triples in the knowledge graph.
[0108] With the support of the GPT-4o large language model, the embodiment of the present invention tested the accuracy of knowledge graph error detection based on a catalytic cracking unit information security knowledge graph constructed with 9721 summary points, 17550 edges, and 90 attribute types. A total of 201 node type anomalies and 472 edge type anomalies were detected. After manual confirmation, the number of confirmed node type anomalies was 154 and the number of edge type anomalies was 350. The total time consumed was 1 hour and 42 minutes, and the maximum node degree detected was 495, which has a more prominent efficiency improvement compared to manual detection methods.
[0109] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. It can be understood by a person of ordinary skill in the art that the above-mentioned devices and methods can be implemented using computer executable instructions and / or contained in a processor control code, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. Such code is provided on the carrier medium. The device and its modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, etc., or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, and can also be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.
[0110] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.
Claims
1. A process industry safety knowledge graph error detection method based on a large language model, characterized in that: The following steps are involved: Step 1: Based on the constructed process industry safety knowledge graph, obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity>, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template; Step 2: extract a single triple to be detected from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through the vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes and relationships from the knowledge graph through the text similarity matching method, merge them into a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results together constitute the knowledge graph error detection context; Step 3: According to the predefined template format, the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the corresponding error detection context subgraph through predefined conversion rules are input into the large language model; based on the text description context composed of similar subgraphs, the triple to be detected is analyzed according to the entity type, relationship type and attribute error detection order; the judgment result and corresponding reasoning process of whether the triple to be detected is wrong are output, and the knowledge graph is updated based on the judgment result.
2. The process industry safety knowledge graph error detection method based on a large language model as claimed in claim 1 is characterized in that: The construction of the knowledge graph triple set and vector library in step 1 specifically includes: based on the constructed process industry safety knowledge graph, according to different knowledge graph representation modes such as RDF and attribute graph, all triples in the knowledge graph are extracted and stored in the format of <head entity, relationship, tail entity>; the knowledge graph vector library generation process selects a knowledge graph embedding model, trains the knowledge graph embedding model based on the constructed knowledge graph, and stores the vector results of the nodes and edges output by the finally trained model to form a knowledge graph vector library; Step 1 of constructing a large language model prompt template for knowledge graph error detection includes: first, determining a system prompt sentence template specific to the current large language model based on the large language model dialogue standard prompt template; then, constructing a corresponding large language model task prompt word template based on the nodes, relationships, and attribute types of the knowledge graph error detection; wherein, for node type error detection, it should be based on the pattern of similar nodes and their corresponding relationships to determine whether the current node has a type error problem; for relationship type error detection, it should be based on the types of the head node and the tail node and the connection pattern of similar edges; for attribute type errors, it can be determined by the attribute values and types of similar nodes.
3. The process industry safety knowledge graph error detection method based on a large language model as claimed in claim 1 is characterized in that: The step 2, based on a single triple to be detected, retrieves the corresponding similar nodes and neighbor nodes, and the process includes: first, based on the triple to be detected, retrieves the corresponding encoding vector from the vector library, and sorts them according to the similarity, and retrieves K similar nodes of the non-triplets to be detected in the knowledge graph based on the vector cosine similarity; then, after merging it with the triple to be detected, retrieves similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph based on the text similarity evaluation algorithm through the type and attribute description text of the head entity, relationship and tail entity in the triple, and merges the retrieval results into subgraphs; finally, based on the merged subgraph, retrieves a similar graph structure subgraph through the graph structure pattern; merges the above retrieval results to form the context of the triple to be detected; wherein, the subgraph merging process is to merge them if they have the same head or tail node.
4. The process industry safety knowledge graph error detection method based on a large language model as claimed in claim 1 is characterized in that: The step 3, based on the predefined template, inputs the knowledge graph triple to be detected and the context information into the large language model, and determines whether there is an error in the knowledge graph triple through a multi-round dialogue method of nodes, relationships and attributes, and outputs its reasoning process; The knowledge graph triple error judgment reasoning process is the textual output of the reasoning analysis step of the large language model in the process of knowledge graph error detection.
5. The process industry safety knowledge graph error detection method based on a large language model as claimed in claim 4 is characterized in that: The triplet error detection process based on predefined templates through multi-round dialogue includes three stages: node type error detection, node relationship type detection and attribute detection; The node type error detection uses a large language prompt word template to input the knowledge graph triple node to be detected and the corresponding context subgraph description text into the large language model, and outputs the result of whether there is an error in the node type; The specific process of the relationship type detection is as follows: if there is an error in the type of the head entity or the tail entity, the knowledge graph triple is directly output to indicate that there is an error, and its specific judgment reasoning process is output in text form; if the types of the head entity and the tail entity are correct, the node and edge to be detected and the corresponding context subgraph description text are input into the large language model through the relationship error detection large language model task prompt word template, and the result of the judgment on whether there is an error in the relationship type is output; Optionally, the specific process of attribute detection is: if the head and tail entity types and corresponding relationships are correct, the text description corresponding to the triple and the text description corresponding to the context subgraph are input into the large language model according to the attribute detection template, and the result of whether the corresponding attribute has an error is output.
6. The process industry safety knowledge graph error detection method based on a large language model as claimed in claim 1, characterized in that: The step 3 updates the knowledge graph based on the reasoning result of the large language model; identifies the correctness of the node type, relationship type and attribute of the triple to be detected in the knowledge graph based on the large language model, and guides the knowledge graph update process; the guided update process can choose to directly update the knowledge graph based on the reasoning result of the large language model or update it after secondary verification manually.
7. A process industry safety knowledge graph error detection system based on a large language model that implements the process industry safety knowledge graph error detection method based on a large language model as described in any one of claims 1 to 6, characterized in that: The process industry safety knowledge graph error detection system based on a large language model includes: The template definition module is used to obtain the set of all knowledge triples to be detected <head entity, relationship, tail entity> based on the constructed process industry safety knowledge graph, perform vector space encoding on the nodes and relationships in the knowledge graph based on the knowledge graph embedding method, and generate a knowledge graph vector library; based on the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word template; The question generation module is used to extract a single triple to be detected and the corresponding context from the knowledge graph triple set, retrieve the first K similar nodes from the knowledge graph vector library by sorting them from high to low similarity through the vector similarity matching method, merge the similar nodes with the triple to be detected, and then retrieve the similar nodes and the corresponding N-order neighbor nodes from the knowledge graph through the text similarity matching method, merge them into a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results together form the knowledge graph error detection context; The error judgment module is used to input the large language model error triple detection prompt words formed by textual conversion of the triple to be detected and the knowledge graph error detection context subgraph through predefined conversion rules into the large language model according to the predefined template format, analyze the triple to be detected according to the entity type, relationship type and attribute error detection order based on the text description context composed of similar subgraphs, output the judgment result and corresponding reasoning process of whether the triple to be detected has an error, and guide the update of the knowledge graph based on the judgment result.
8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the process industry safety knowledge graph error detection method based on a large language model as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to perform the steps of the process industry safety knowledge graph error detection method based on a large language model as described in any one of claims 1 to 6.
10. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the process industry safety knowledge graph error detection system based on a large language model as described in claim 7.
Citation Information
Patent Citations
Knowledge graph completion method and device, electronic equipment and storage medium
CN116166812A
Electric power data processing method and system based on knowledge graph
CN117931955A
Construction method and application of alarm auxiliary processing knowledge graph of petroleum refining device
CN118133950A
Standard detection method, system and equipment for providing judgment basis, medium and product
CN118657156A
Power equipment knowledge graph error detection method and system based on knowledge reconstruction
CN119046474A
Cited By
Elevator fault knowledge graph construction method based on large model prompt instruction
CN119917702A
Electronic product performance degradation analysis method and system based on large language model and program product
CN120144425A
A method, system, and program product for analyzing the performance degradation of electronic products based on large language models
CN120144425B
Medical document quality detection method and system based on large model and knowledge graph
CN120163144A
Method and system for quality detection of medical documents based on large model and knowledge graph
CN120163144B