Process industry safety knowledge graph error detection method and system based on large language model
By using a large language model-based approach, a knowledge graph vector library is generated and multi-round reasoning analysis is performed. This solves the problems of omissions and conflicts in error detection in knowledge graphs, improves detection efficiency and result reliability, and is suitable for automatic error detection of safety knowledge graphs in the process industry.
Patent Information
- Application Number
- CN202411757282.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-12-03
AI Technical Summary
When existing technologies fail to detect errors in large-scale, complex, and relational knowledge graphs, manual and rule-based logical reasoning methods may lead to omissions or conflicts, resulting in unreliable analysis results from knowledge graph applications.
A method based on a large language model is adopted to generate a knowledge graph vector library through vector space encoding and text similarity matching. The large language model is used to perform multi-turn dialogue reasoning analysis to detect triple errors. The error detection context is formed by combining graph pattern matching and guides the updating of the knowledge graph.
It enables the automatic discovery of errors in knowledge graphs without high resource consumption and manual intervention, improving detection efficiency, ensuring the credibility and interpretability of analysis results, and reducing the limitations of expert rules and information overload problems.
Smart Images

Figure CN119740644B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of artificial intelligence, and particularly relates to a process industry safety knowledge graph error detection method and system based on a large language model. BACKGROUND
[0002] With increasingly refined industrial production processes, the complexity of systems and the security risks they face are gradually increasing. In the face of increasingly complex equipment failure and malicious attacks, functional safety and information security problems are intertwined and complex scenarios, manual analysis faces information overload, lack of persistence and other problems. Based on the idea of knowledge data fusion, the knowledge graph technology is used to fuse various types of knowledge such as communication, control, process and safety involved in the process industry safety analysis process, and based on artificial intelligence methods, the process of manual processing is simulated to greatly improve the efficiency of safety event discovery, evaluation and disposal 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 initial constructed knowledge graph has some entity type, relationship and attribute knowledge triple error problems. Therefore, the detection and correction of errors in the process industry safety knowledge graph is a 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. The manual error detection method traverses and analyzes the knowledge graph through domain experts, and when the node association is too complex, there is often an information overload problem that leads to the omission of important decision factors. The rule-based knowledge graph error detection method defines detection rules by domain experts and determines the correctness of the triple through logical reasoning, but the rule definition process based on expert knowledge has the problems of high labor cost in large-scale knowledge graph applications, incomplete rule sets and even conflicts.
[0004] In view of the above analysis, the existing technology has the technical problems that need to be solved urgently. In the large-scale complex correlation knowledge graph triple correctness detection, due to the conflict or omission problem of manual and rule-based logical reasoning methods, the existing constructed knowledge graph may have errors, which leads to the untrustworthiness of the application analysis results.
[0005] Through the above analysis, the existing problems and defects of the prior art are:
[0006] In the large-scale complex correlation knowledge graph triple correctness detection, due to the conflict or omission problem of manual and rule-based logical reasoning methods, the existing constructed knowledge graph may have errors, which leads to the untrustworthiness of the application analysis results. SUMMARY
[0007] In view of the problems in the prior art, the present application provides a process industry safety knowledge graph error detection method based on a large language model.
[0008] The present application is implemented in a process industry safety knowledge graph error detection method based on a large language model, which comprises:
[0009] Step 1, based on the constructed process industry safety knowledge graph, obtain the set of all knowledge triples <head entity, relation, tail entity> to be detected, encode the nodes and relations in the knowledge graph into vector space based on the knowledge graph embedding method, and generate a knowledge graph vector library; according to the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and the task prompt word template;
[0010] Step 2, extract a single knowledge triple to be detected from the knowledge graph triple set, retrieve the top K similar nodes from the knowledge graph vector library by vector similarity matching method according to the similarity from high to low, and combine the similar nodes with the detected triple to retrieve the similar nodes and corresponding N-order neighbor nodes and corresponding edges from the knowledge graph by text similarity matching method, combine them to form a similar subgraph, and further expand the similar subgraph based on the graph pattern matching method, and the retrieval results are combined to form a knowledge graph error detection context;
[0011] Step 3, input the large language model error triple detection prompt word formed by text conversion of the detected triple and the knowledge graph error detection context subgraph according to the pre-defined template format and pre-defined conversion rules into the large language model, analyze the detected triple according to the entity type, relation type and attribute error detection order based on the text description context formed by the similar subgraph, output the judgment result of whether the detected triple has error and the corresponding reasoning process, and guide the knowledge graph update based on the judgment result.
[0012] Further, the knowledge graph triple set and the vector library of step 1 specifically comprise: based on the constructed process industry safety knowledge graph, extracting all triples in the knowledge graph according to different knowledge graph representation modes such as RDF and attribute graph, and storing them in the format of <head entity, relation, 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] The construction of the knowledge graph error detection large language model prompt template in step 1 includes: first, determining the system prompt sentence template that is specific to the current large language model based on the large language model dialogue standard prompt template; then, constructing the 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 determined whether the current node has a type error problem based on the mode of similar nodes and their corresponding relationships; for relationship type error detection, it should be determined based on the types of the head node and the tail node and the connection mode of similar edges; for attribute type error, it can be determined through the attribute values and types of similar nodes.
[0014] Further, the step 2 of retrieving corresponding similar nodes and neighbor nodes based on a single to-be-detected triple includes: first, retrieving the corresponding encoding vector from the vector library based on the to-be-detected triple, and sorting according to the similarity from high to low, retrieving the top K similar nodes of non-to-be-detected triples in the knowledge graph based on vector cosine similarity; then, combining them with the to-be-detected triple, and based on the type and attribute description text of the head entity, relationship and tail entity in the triple, retrieving similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph based on a text similarity evaluation algorithm, combining the retrieval results to obtain a similar subgraph; finally, based on the merged subgraph, retrieving a similar graph structure subgraph through graph structure pattern retrieval; combining the above three retrieval results to form the context of the to-be-detected triple; wherein, the subgraph merging process is to merge if both have the same head or tail node.
[0015] Further, the step 3 of based on a pre-defined template, inputting the to-be-detected knowledge graph triple and the context information into a large language model after text conversion, and determining whether the knowledge graph triple has an error through multiple rounds of dialogue of nodes, relationships and attributes, and outputting the reasoning process;
[0016] The knowledge graph triple error determination reasoning process is the textual output of the reasoning analysis step of the large language model in the knowledge graph error detection process.
[0017] Further, the triple error detection process based on a pre-defined template through multiple rounds of dialogue includes three stages: node type error detection, node relationship type detection and attribute detection.
[0018] The node type error detection inputs the to-be-detected knowledge graph triple node and the corresponding context subgraph description text into the large language model through the large language prompt word template, and outputs the determination result of whether the node type has an error;
[0019] The relationship type detection specific process is: if the type of the head entity or the tail entity is wrong, directly outputting that the knowledge graph triple exists error, and outputting the specific error reasoning process in text form; if the head entity and the tail entity type is correct, inputting the to-be-detected node and the edge and the corresponding context subgraph description text into the large language model through the relationship error detection large language model task prompt word template, and outputting the result of the determination of whether the relationship type exists error;
[0020] Optionally, the attribute detection specific process is: if the head entity type, the tail entity type and the corresponding relationship are all correct, inputting the text description corresponding to the triple and the context subgraph corresponding text description into the large language model according to the attribute detection template, and outputting the result of the determination of whether the corresponding attribute exists error.
[0021] Further, the step 3 is based on the large language model reasoning result to update the knowledge graph; based on the large language model, the correct or incorrect identification of the node type, the relationship type and the attribute of the to-be-detected triple in the knowledge graph is obtained, and the knowledge graph updating process is guided; the guiding updating process can be selected to directly update the knowledge graph based on the large language model reasoning result or to update after secondary verification in an artificial manner.
[0022] Another purpose of the present application is to provide a process industry safety knowledge graph error detection system based on a large language model, comprising:
[0023] A template definition module is used to obtain a set of all to-be-detected knowledge triples based on the constructed process industry safety knowledge graph, to perform vector space coding on the nodes and relationships in the knowledge graph based on a knowledge graph embedding method, to generate a knowledge graph vector library, to predefine a knowledge graph error detection large language model system and a task prompt word template according to the knowledge graph ontology and the selected large language model;
[0024] A question generation module is used to extract a single to-be-detected triple and the corresponding context from the knowledge graph triple set, to retrieve the first K similar nodes from the knowledge graph vector library in descending order of similarity through a vector similarity matching method, to combine the similar nodes with the to-be-detected triple, to retrieve similar nodes and corresponding N-order neighbor nodes from the knowledge graph through a text similarity matching method, to combine them to form a similar subgraph, to further expand the similar subgraph based on a graph pattern matching method, and to jointly form a knowledge graph error detection context.
[0025] An error determination module is configured to input a large language model error triple detection prompt word formed by textually converting a to-be-detected triple and a knowledge graph error detection context subgraph according to a predefined template format and a predefined conversion rule into a large language model, analyze the to-be-detected triple based on a text description context formed by a similar subgraph according to an entity type, a relationship type, and an attribute error detection sequence, output a determination result of whether the to-be-detected triple has an error and a corresponding reasoning process, and guide knowledge graph updating based on the determination result.
[0026] Another object of the present application is to provide a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to enable the processor to perform the steps of the large language model-based process industry safety knowledge graph error detection method.
[0027] Another object of the present application is to provide a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to enable the processor to perform the steps of the large language model-based process industry safety knowledge graph error detection method.
[0028] Another object of the present application is to provide an information data processing terminal for implementing the large language model-based process industry safety knowledge graph error detection system.
[0029] In combination with the above technical solutions and solved technical problems, the technical solution to be protected by the present application has the following advantages and positive effects:
[0030] First,
[0031] The present application provides a large language model-based process industry safety knowledge graph error detection method, which is based on graph retrieval enhancement generation technology, uses the constructed process industry safety knowledge graph as an external knowledge source, forms a knowledge triple detection context through text, vector, and graph structure model multiple retrieval methods, and uses the reasoning ability of a large language model in combination with external knowledge input to output the correctness of the to-be-detected triple and the corresponding reasoning process in a dialogue mode without high resource consumption and complex model fine-tuning processes. The method has the processing ability of large-scale knowledge graph nodes and complex relationships, realizes the automatic discovery process of error triples in the knowledge graph without human intervention, solves the omission or conflict problems caused by manual and rule methods, and greatly improves the efficiency of knowledge graph error detection.
[0032] 1. The application provides a process industry safety knowledge graph error detection method based on a large language model. In the preparation stage, first, based on the process industry safety knowledge graph, the entire knowledge triple set is obtained, and based on the knowledge graph embedding method, the nodes and relationships in the knowledge graph are converted into vector space to generate a knowledge graph corresponding vector library; 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, first, a single to-be-detected triple is extracted from the knowledge graph triple set; then, similar nodes and their N-order neighbor nodes are retrieved and filtered from the knowledge graph library by vector and text matching to form a similar subgraph, and the similar subgraph is expanded based on graph pattern matching to form a triple error detection context. The triple information and the context are input into the large language model according to the pre-defined prompt word template, the representation patterns of the similar nodes and neighbor nodes are compared and analyzed based on the large language model, the correctness of the to-be-detected triple is determined, and the knowledge graph is updated based on the result.
[0033] The application is based on the scenario that the proportion of error triples in the constructed knowledge graph is low, based on the association mode of similar nodes and neighbor nodes, and through the reasoning and analysis capability of the large language model, the generation idea is enhanced based on graph retrieval under the condition of reducing labor cost, the efficiency of knowledge graph error detection is improved, the explainability of the analysis process is preserved through the graph-based analysis process, and the problems of detection result conflict or omission caused by the completeness of human expert rule setting are avoided.
[0034] 2. Further, the process industry safety knowledge graph error detection method based on a large language model provided by the application utilizes the superiority of large language model reasoning, reduces the limitations of expert rules in traditional methods, and provides explainable answers compared with machine learning methods.
[0035] 3. Further, the process industry safety knowledge graph error detection method based on a large language model provided by the application does not need to introduce supervised corpus compared with the traditional "pre-training + fine-tuning" large model paradigm, and can avoid the problem of too large difference between the downstream task and the basic large model.
[0036] 3. Further, the process industry safety knowledge graph error detection method based on a large language model provided by the application provides global and multi-level context information including node text and graph structure for the large model compared with the traditional RAG system based on semantic similarity retrieval fragment, and the GraphRAG method effectively improves the accuracy of large language model reasoning.
[0037] 4、Further, the process industry safety knowledge graph error detection method based on a large language model provided by the present application effectively improves the error detection efficiency, improves the reliability of the knowledge graph, and thus guarantees the effectiveness of process industry safety reasoning and decision-making.
[0038] Second, as the creative evidence of the claims of the present application, it is also embodied in the following important aspects:
[0039] (1) The expected income and commercial value of the technical solution of the present application after transformation are:
[0040] The present application provides an automatic knowledge graph error detection method based on a large language model. No field expert intervention is required during the error detection process, and the determination result has strong explainability. The large-scale time consumption and information overload problems caused by human factors in actual industrial production are solved, and the large language model does not need to be fine-tuned in the application process, making it easier to deploy in actual industrial applications.
[0041] (2) The technical solution of the present application solves the technical problems that people have been eager to solve but have always failed to succeed:
[0042] How to apply human knowledge in intelligent analysis algorithm is the core problem of the transition of artificial intelligence from perceptual intelligence to cognitive intelligence. In the present application, how to ensure the accuracy of human knowledge representation is solved. Through detection and correction of whether there is an error triple 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 application overcomes technical bias:
[0044] The present application uses a complete knowledge graph as an external knowledge base for large language model reasoning and analysis, and effectively alleviates the problem of unreliable application in actual industrial production caused by the "illusion" of large language models through retrieval enhancement generation method. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 is a flow chart of the process industry safety knowledge graph error detection method based on a large language model provided by the embodiment of the present application.
[0046] Figure 2 is a structural block diagram of the process industry safety knowledge graph error detection system based on a large language model provided by the embodiment of the present application.
[0047] Figure 3 is a principle schematic diagram of the process industry safety knowledge graph error detection method based on a large language model provided by the embodiment of the present application.
[0048] Figure 4is a whole 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 application.
[0049] Figure 5 is a specific embodiment diagram for illustrating steps in a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in combination with embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0051] As shown in Figure 1 , a process industry safety knowledge graph error detection method based on a large language model provided by an embodiment of the present application includes the following steps:
[0052] S101, based on the constructed process industry safety knowledge graph, obtain a complete set of knowledge triples <head entity, relationship, tail entity> to be detected, perform vector space coding on the nodes and relationships in the knowledge graph based on a knowledge graph embedding method, generate a knowledge graph vector library, and according to the knowledge graph ontology and the selected large language model, predefine a knowledge graph error detection large language model system and a task prompt word template;
[0053] S102, extract a single knowledge triple to be detected from the knowledge graph triple set, retrieve the top K similar nodes from the knowledge graph vector library in order of similarity from high to low through a vector similarity matching method, combine the similar nodes with the knowledge triple to be detected, retrieve similar nodes and corresponding N-order neighbor nodes and their corresponding relationships from the knowledge graph through a text similarity matching method, combine them to form a similar subgraph, further expand the similar subgraph based on a graph pattern matching method, and jointly form a knowledge graph error detection context from the retrieval results;
[0054] S103, input the large language model error triple detection prompt word formed by text conversion of the knowledge triple to be detected and the knowledge graph error detection context subgraph according to the pre-defined template format through the pre-defined conversion rule into the large language model, analyze the knowledge triple to be detected according to the entity type, relationship type and attribute error detection order based on the text description context formed by the similar subgraph, output the determination result of whether the knowledge triple to be detected has an error and the corresponding reasoning process, and guide the knowledge graph update based on the determination result.
[0055] The S101 knowledge graph triple set and vector library construction provided by the embodiment of the application specifically comprises: based on the constructed process industry safety knowledge graph, all triples in the knowledge graph are extracted according to different knowledge graph representation modes such as RDF and attribute graph, and are 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] The S101 knowledge graph construction error detection large language model prompt template comprises the following steps: first, determining a system prompt sentence template special for the current large language model based on a 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; for node type error detection, whether the current node has a type error problem should be determined based on the mode of similar nodes and their corresponding relationships; for relationship type error detection, it should be determined based on the types of the head node and the tail node and the connection mode of similar edges; for attribute type error, it can be determined through the attribute values and types of similar nodes.
[0057] The S102 based on a single to-be-detected triple to retrieve corresponding similar nodes and neighbor nodes provided by the embodiment of the application comprises the following steps: first, retrieving the corresponding encoding vector from the vector library based on the to-be-detected triple, and retrieving K high-similarity similar nodes of non-to-be-detected triples in the knowledge graph based on vector cosine similarity, then combining the similar nodes with the to-be-detected triple nodes, and based on the types and attribute description texts of the head entity, relationship and tail entity in the triple, retrieving similar nodes and their N-order neighbor nodes and relationships from the original knowledge graph based on a text similarity evaluation algorithm to form a similar adjacency relationship subgraph; then, based on the similar adjacency relationship subgraph, a similar graph structure subgraph is retrieved through a graph structure mode; the above retrieval results are combined to form the context of the to-be-detected triple; wherein, if the two have the same head or tail node, the subgraphs are combined.
[0058] The S103 based on a pre-defined template, which inputs the to-be-detected knowledge graph triple and the context information into a large language model, and determines whether the knowledge graph triple has an error through a multi-round dialogue mode of nodes, relationships and attributes, and outputs the reasoning process; the knowledge graph triple error determination reasoning process is the textual output of the reasoning analysis S10 of the large language model in the knowledge graph error detection process.
[0059] The embodiment of the application provides a three-tuple error detection process based on a predefined template through a multi-round dialogue mode, which comprises three stages of node type error detection, node relationship type detection and attribute detection.
[0060] The node type error detection inputs the knowledge graph three-tuple node to be detected and the corresponding context subgraph description text into a large language model through a large language prompt word template, and outputs a node type error judgment result.
[0061] The relationship type detection specifically comprises: if the type of the head entity or the tail entity is incorrect, the knowledge graph three-tuple is directly outputted as incorrect, and the specific error reasoning process is outputted in the form of text; if the types of the head entity and the tail entity are correct, the node and the edge to be detected and the corresponding context subgraph description text are inputted into a large language model through a relationship error detection large language model task prompt word template, and a relationship type error judgment result is outputted.
[0062] Optionally, the attribute detection specifically comprises: if the types of the head entity and the tail entity and the corresponding relationship are correct, the text description of the three-tuple and the corresponding context subgraph text description are inputted into a large language model according to an attribute detection template, and an attribute error judgment result is outputted.
[0063] The embodiment of the application provides S103, updating the knowledge graph based on the reasoning result of the large language model; identifying the correctness of the node type, the relationship type and the attribute of the three-tuple to be detected in the knowledge graph based on the large language model, and guiding the knowledge graph updating process; the guiding updating process can update the knowledge graph based on the reasoning result of the large language model directly or update the knowledge graph after secondary verification in an artificial manner.
[0064] As shown in Figure 2 The embodiment of the application provides a process industry safety knowledge graph error detection system based on a large language model, which comprises:
[0065] A template definition module is configured to obtain a set of all knowledge three-tuples to be detected based on the constructed process industry safety knowledge graph, perform vector space coding on the nodes and relationships in the knowledge graph based on a knowledge graph embedding method, generate a knowledge graph vector library, and predefine a knowledge graph error detection large language model system and a task prompt word template based on the knowledge graph ontology and a selected large language model.
[0066] A question generation module is configured to extract a single to-be-detected triple from a set of triples of a knowledge graph, retrieve K similar nodes from a vector library in descending order of similarity through a vector similarity matching method, combine the similar nodes with the to-be-detected triple, retrieve similar nodes and corresponding N-order neighbor nodes from the knowledge graph through a text similarity matching method, combine the similar nodes and the corresponding N-order neighbor nodes to form a similar subgraph, further expand the similar subgraph based on a graph pattern matching method, and jointly form a knowledge graph error detection context based on the retrieval results of the similar subgraph.
[0067] An error determination module is configured to input a large language model error triple detection prompt word formed by textually converting a to-be-detected triple and a knowledge graph error detection context subgraph according to a predefined template format and a predefined conversion rule into a large language model, analyze the to-be-detected triple based on a text description context formed by the similar subgraph in the order of entity type, relationship type, and attribute error detection, output a determination result of whether the to-be-detected triple has an error and a corresponding reasoning process, and guide knowledge graph updating based on the determination result.
[0068] Another object of the present application is to provide a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to enable the processor to perform the steps of the large language model-based process industry safety knowledge graph error detection method.
[0069] Another object of the present application is to provide a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to enable the processor to perform the steps of the large language model-based process industry safety knowledge graph error detection method.
[0070] Another object of the present application is to provide an information data processing terminal for implementing the large language model-based process industry safety knowledge graph error detection system.
[0071] The present application is embodied as follows:
[0072] As shown in Figure 3 The present application provides a large language model-based process industry safety knowledge graph error detection method, which will be described in detail below with reference to an information safety knowledge graph constructed based on multi-domain safety knowledge such as communication, control, and process in an actual catalytic cracking unit. Figure 4 The method comprises the following steps:
[0073] Step 1: In the detection preparation stage, based on the constructed catalytic cracking unit information security knowledge graph, all knowledge triples <head entity, relation, tail entity> contained in the knowledge graph are obtained by retrieval as the set of all triples to be detected; the knowledge graph embedding method is used to perform vector space coding on the nodes and relations in the knowledge graph to generate a knowledge graph vector library; according to the knowledge graph ontology and the selected large language model, the entity, relation and attribute error detection large language model system and task prompt word template of the knowledge graph are defined in advance respectively;
[0074] Step 2: In the error detection stage, first, a single triple to be detected is extracted from the knowledge graph triple set, and the top K similar nodes are retrieved from the knowledge graph vector library in descending order of similarity by the vector cosine similarity matching method, and then the similar nodes and their N-order neighbor nodes and corresponding relations are retrieved from the knowledge graph by the text similarity matching method to form a similar neighbor subgraph, and then the similar graph structure subgraph is retrieved by the graph pattern matching method, and finally the retrieval results are merged to form a knowledge graph error detection context;
[0075] Step 3: In the error detection stage, the triple to be detected and the knowledge graph error detection context subgraph are converted into text according to the pre-defined template format and through the pre-defined conversion rule to form a large language model error triple detection prompt word input into the large language model, and according to the output of the detected triple judgment result and the corresponding reasoning process, the knowledge graph is updated.
[0076] In an embodiment of the present application, in step 1, the constructed catalytic cracking unit information security knowledge graph represents the safety knowledge involved in the production process of the catalytic cracking unit through graphing. The construction of the triple set and the vector library of the knowledge graph includes:
[0077] Based on the constructed catalytic cracking unit information security knowledge graph, we choose to use Neo4j attribute graph as the storage of the knowledge graph, extract all triples in the knowledge graph through Cypher statement, and store them in the format of <head entity, relation, tail entity>; train the knowledge graph embedding model, in this embodiment, choose TransE model as the knowledge graph embedding model. Wherein, A EM is the knowledge graph vector set, EM i is the triple vector representation, which is represented in the form of head entity vector EM ih , relation vector EM ir and tail entity vector EM it ; vectorize the knowledge graph to get the following results:
[0078] A EM= {EM1, EM2,..., EM i ,...,EM m}
[0079] EM i = <EM 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 the nodes and edges output by the trained model are stored, which can be stored in the computer memory or hard disk, forming a knowledge graph vector library.
[0084] In an embodiment of the present application, in step 1, the construction of the knowledge graph error detection large language model prompt template includes:
[0085] First, determine the system prompt template that is exclusive to the current large language model based on the selected large language model dialogue standard prompt template; then, construct different large language model task prompt word templates based on the nodes, relationships and attribute types of knowledge graph error detection;
[0086] Here, the GPT-4o model with strong Chinese language processing capability is selected as the knowledge graph error detection large language model, and the system prompt word template is set as: "You are an expert in knowledge graph error triple detection, now you need to output the results and judgments based on the input information and the corresponding context, please strictly reason and analyze according to the given context. Please give the conclusion first and then give the specific reasoning process of the error reason."
[0087] Since there are differences in the determination criteria for node type, relationship type and attribute error determination, different task prompt word templates need to be formulated for the three types of tasks. Among them:
[0088] The prompt word template for the node type determination large language task is defined as: "Please determine whether the input triple head node and tail node type is incorrect according to the similar nodes and the corresponding relationship association mode in the given context, and the given context is: {}, and the triple to be determined is: {}."
[0089] The prompt word template for the relationship type determination large language task is defined as: "Please determine whether the input triple relationship type is incorrect according to the similar head node, tail node and corresponding edge type in the given context, and the given context is: {}, and the triple to be determined is: {}."
[0090] The prompt word template for the attribute determination large language task is defined as: "Please determine whether the input triple node attribute is incorrect according to the attribute name and attribute value type of the similar node in the given context, and the given context is: {}, and the triple to be determined is: {}."
[0091] In an 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] The encoding vector corresponding to the vector information of the triple to be detected is retrieved from the vector library, and the knowledge graph node set of the top K nodes with high similarity in the non-triple to be detected is retrieved based on the vector cosine similarity, and the set is merged with the head and tail node set of the triple to be detected; the vector cosine similarity is defined as:
[0093]
[0094] Where, EM i1 · EM i2 is the dot product of two vectors, ||EM i1 ||, ||EM i1 || is the norm of two vectors, i.e. the length of the vector; if the directions of two vectors are consistent, the cosine similarity is close to 1; if the directions are opposite, it is close to -1; if they are completely unrelated, it is close to 0;
[0095] Based on the merged head and tail node set, 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 triple text information to form a knowledge graph subgraph (N is a positive integer), forming the initial context subgraph of the triple to be detected; wherein the subgraph formation process is If both have the same head or tail node, they are merged; 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), N(B), that is, the number of identical words; N(A)∪N(B) describes the union size of N(A), N(B), that is, the total number of words contained in the text description character set of node A and node 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, so as to expand the initial text graph and form a knowledge graph triple error detection context subgraph.
[0099] In an embodiment of the present application, in step 3, based on the retrieved similar subgraph, it is converted into text description according to the rules to form the knowledge graph error triple detection context, based on the pre-defined 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 the knowledge graph triple exists error is realized through the multi-round dialogue mode of node, relationship and attribute, and the reasoning process is output;
[0100] The process of converting the retrieved similar subgraph into text description according to the rules is to directly take the triple head entity as the sentence subject, the relationship as the sentence predicate, and the tail entity as the sentence object. If there are multiple triples, they are spliced into sentences. Figure 5 The knowledge graph error triple context based on the large language model is shown in the schematic diagram. The triple to be detected is “<TV1001, CONTROL, T1001>”, and the corresponding triple in the context subgraph retrieved through text and vector similarity is “<T1001, HAS STATE, TI1001>, <TI1001, INPUT, TIC1001>, <TIC1001, CONTROL, TV1001>”, and the subgraph retrieved through graph pattern matching is “<TV1001, CONTROL, T1001>, <T1001, HAS STATE, TI1001>, <TI1001, INPUT, TIC1001>, <TIC1001, CONTROL, TV1001>”. Figure ThreeIf the tuple <T1304, HAS STATE, LI1311>, <LI1311, INPUT, LICA1311>, <LICA1311, INPUT, FIC1311>, <LICA1311, CONTROL, FV1311>, <FIC1311, CONTROL, FV1311> is converted into the text description "The raw oil heat loop temperature regulating valve adjustment data confusion, where the raw oil heat loop temperature regulating valve is an actuator type, the data confusion is an attack technology type, and they have a regulating relationship", and the context triple is converted into the text description "The data confusion has a raw oil temperature, the raw oil temperature value is input to the raw oil temperature controller and controls the raw oil temperature regulating valve through the raw oil temperature controller, where the 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 regulating valve is an actuator type" through the text and vector retrieval, and the context triple is converted into the text description "The stabilizing tower has a stabilizing tower bottom liquid level, the stabilizing tower bottom liquid level value is input to the stabilizing tower bottom liquid level controller and the gasoline hydrogenation flow controller at the same time, and the stabilizing tower bottom liquid level controller outputs a control quantity to the gasoline hydrogenation flow controller to realize the adjustment of the flow control valve of the gasoline hydrogenation" through the graph pattern matching retrieval. Finally, the above text, vector, and context text description information obtained through graph pattern matching are filled into the corresponding large language model error detection prompt word template to form a large language model error detection question.
[0101] The input of the to-be-detected triple and the context text description information into the large language model for knowledge graph triple error judgment reasoning process is the textual output of the reasoning analysis step in the knowledge graph error detection process of the large language model; specifically:
[0102] First, based on the knowledge graph node type error detection large language prompt 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 node type error judgment result; For example: You are an expert in knowledge graph error triple detection, you need to output the corresponding result and judgment logic based on the input information and the corresponding context according to the specific task requirements, please strictly reason and analyze according to the context. Please give the conclusion first and then give the specific reasoning process of the error reason. The given task is: please determine whether the type of the head node and the tail node of the input triple is wrong according to the similar node and the corresponding relationship in the given context. The given context is: "The raw oil heat loop controller controls the raw oil heat loop temperature regulating valve, the raw oil heat loop temperature controller is a controller type, and the raw oil heat loop temperature regulating valve is an actuator type, and they have a regulating relationship" and "The raw oil heat loop temperature regulating valve regulates the raw oil flow, where the raw oil heat loop temperature regulating valve is an actuator type and the raw oil flow is a state type, and their relationship is a regulating relationship." The triple to be judged is "< raw oil heat loop temperature controller, control, raw oil heat loop temperature regulating valve >".
[0103] According to the following process, if the type of the head entity or the tail entity is wrong, output that the knowledge graph triple is wrong, and output the specific error reasoning process in text form;
[0104] After reasoning and analysis by the large language model, the final output result is: "The triple T1001 to be detected has type error and should be of type PLANT, the reason is as follows: the triple to be detected and its neighbor nodes constitute 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 type TECHNIQUE, which violates the similar subgraph pattern and may have type abnormalities, please confirm."
[0105] If the head entity and the tail entity type are correct, then through the relationship error detection large language model task prompt template, input the node and edge to be detected and the corresponding context subgraph description text into the large language model, and output the relationship type error judgment result;
[0106] Optionally, if the head, tail entity type and corresponding relationship are correct, input the text description of the triple and the corresponding context subgraph text description into the large language model according to the attribute detection template, and output the attribute error judgment result;
[0107] According to the determination result of the large language model on whether the knowledge triple node and the relationship type are wrong and the corresponding textual reasoning process, the updating process of the knowledge graph is guided; wherein, according to the result guiding the updating process of the knowledge graph triple, the secondary verification can be carried out by manually reading the analysis result of the large language model, and after confirming that there is no error, the original knowledge graph is updated in a manual manner, or the original triple nodes and relationship types in the knowledge graph can be automatically updated by automatically extracting the corresponding reasoning result through a rule manner.
[0108] The embodiment of the application tests the accuracy of knowledge graph error detection based on the constructed catalytic cracking unit information security knowledge graph with 9721 summary nodes, 17550 edges and 90 attribute types under the support of the GPT-4o large language model. A total of 201 node type abnormalities and 472 edge type abnormalities are detected. After manual confirmation, the number of node type abnormalities is 154, the number of edge type abnormalities is 350, the total time consumption is 1 hour and 42 minutes, the maximum node degree of detection is 495, and compared with the manual detection method, the efficiency is improved.
[0109] It should be noted that the embodiments of the present application can be realized by hardware, software or a combination of software and hardware. The hardware part can be realized by special logic; the software part can be stored in the memory and executed by the appropriate instruction execution system, such as microprocessor or special designed hardware. Those skilled in the art can understand that the above devices and methods can be realized by computer executable instructions and / or included in processor control code, such as carrier medium, such as magnetic disk, CD or DVD-ROM, programmable memory, such as read-only memory (firmware), or data carrier, such as optical or electronic signal carrier. The device and its modules of the present application can be realized by hardware circuit, such as ultra large scale integrated circuit or gate array, semiconductor, such as logic chip, transistor, or programmable hardware device, such as field programmable gate array, programmable logic device, etc. It can also be realized by software executed by various types of processors, or by a combination of the above hardware circuit and software, such as firmware.
[0110] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any modification, equivalent replacement and improvement within the technical range disclosed by the present application, which is made by those skilled in the art within the spirit and principle of the present application, should be covered within the protection scope of the present application.
Claims
1. A method for error detection in process industry safety knowledge graphs based on large language models, characterized in that, Includes the following steps: Step 1: Based on the constructed process industry safety knowledge graph, obtain the set of all knowledge triples to be detected <head entity, relation, tail entity>. Based on the knowledge graph embedding method, perform vector space encoding on the nodes and relations in the knowledge graph to generate a knowledge graph vector library. According to the knowledge graph ontology and the selected large language model, predefine the knowledge graph error detection large language model system and task prompt word templates. Step 2: Extract a single triplet to be detected from the knowledge graph triplet set. Using the vector similarity matching method, retrieve the top K similar nodes from the knowledge graph vector library according to the similarity from high to low. Then, merge the similar nodes with the triplet to be detected and retrieve the similar nodes and corresponding N-order neighbor nodes and relationships from the knowledge graph using the text similarity matching method. Merge them to form a similar subgraph. Further expand the similar subgraph based on the graph pattern matching method, and combine the retrieval results to form the knowledge graph error detection context. Step 3: Input the error triple detection prompt words of the large language model into the large language model after the triple to be detected and the corresponding error detection context are converted into text by the predefined conversion rules according to the predefined template format. Based on the text description context composed of similar subgraphs, the triple to be detected is analyzed according to the entity type, relation type and attribute error detection order. The judgment result of whether the triple to be detected has errors and the corresponding reasoning process are output, and the knowledge graph is updated based on the judgment result.
2. The error detection method for process industry safety knowledge graph based on a large language model as described in claim 1, 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, extracting all triples in the knowledge graph according to two different knowledge graph representation modes, RDF and attribute graph, and storing them in the format of <head entity, relation, tail entity>; the knowledge graph vector library generation process involves selecting a knowledge graph embedding model, training the knowledge graph embedding model based on the constructed knowledge graph, and storing the vector results of the nodes and edges output by the finally trained model to form a knowledge graph vector library; Step 1, constructing the knowledge graph error detection prompt template for the large language model, includes: First, determining a system prompt statement template specific to the current large language model based on the standard prompt template for large language model dialogue; then, constructing corresponding large language model task prompt word templates based on the nodes, relationships, and attribute types detected in the knowledge graph; specifically, for node type error detection, the current node should be determined based on the pattern of similar nodes and their corresponding relationships to determine if there is a type error; for relationship type error detection, it should be determined based on the types of the head and tail nodes and the connection patterns of similar edges; for attribute type errors, it can be determined through the attribute values and types of similar nodes.
3. The error detection method for process industry safety knowledge graph based on a large language model as described in claim 1, characterized in that, Step 2, the process of retrieving corresponding similar nodes and neighboring nodes based on a single triplet to be detected, includes: first, retrieving the corresponding encoding vector from the vector library based on the triplet to be detected, and sorting them according to similarity; then, retrieving the K similar nodes in the knowledge graph that are not the triplet to be detected based on vector cosine similarity; then, merging them with the triplet to be detected, and using the type and attribute description text of the head entity, relation, and tail entity in the triplet, retrieving similar nodes and their N-order neighboring nodes and relations from the original knowledge graph based on the text similarity evaluation algorithm, and merging the retrieval results into subgraphs; finally, obtaining similar graph structure subgraphs based on the merged subgraphs through graph structure pattern retrieval; and merging the above retrieval results to form the context of the triplet to be detected; wherein, the subgraph merging process is to merge them if they have the same head or tail node.
4. The error detection method for process industry safety knowledge graph based on a large language model as described in claim 1, characterized in that, In step 3, based on a predefined template, the knowledge graph triples to be detected and contextual information are input into a large language model. The model then uses a multi-turn dialogue method involving nodes, relationships, and attributes to determine whether the knowledge graph triples contain errors and outputs the reasoning process. The reasoning process for determining errors in knowledge graph triples is the textual output of the reasoning and analysis steps of the large language model during the knowledge graph error detection process.
5. The error detection method for process industry safety knowledge graph based on a large language model as described in claim 4, characterized in that, The triplet error detection process based on predefined templates and using a multi-turn dialogue method 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 the node type has an error. The specific process of relation type detection is as follows: if the type of the head entity or the tail entity is incorrect, the knowledge graph triple is directly output as incorrect, and the 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 relation error detection task prompt word template, and the result of the judgment of whether the relation type is incorrect is output. The specific process of attribute detection is as follows: if the head and tail entity types and their corresponding relationships are correct, then the text descriptions corresponding to their triples and the text descriptions corresponding to the context subgraphs 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 error detection method for process industry safety knowledge graph based on a large language model as described in claim 1, characterized in that, Step 3 involves updating the knowledge graph based on the reasoning results of the large language model; identifying the correctness of the node type, relation type, and attributes of the triples to be detected in the knowledge graph based on the large language model, and guiding 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 to update it after secondary verification by manual means.
7. A process industry safety knowledge graph error detection system based on a large language model, implementing the error detection method for process industry safety knowledge graphs based on any one of claims 1-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 a set of all knowledge triples <head entity, relation, tail entity> to be detected based on the constructed process industry safety knowledge graph. It performs vector space encoding on the nodes and relations in the knowledge graph based on the knowledge graph embedding method to generate a knowledge graph vector library. Based on the knowledge graph ontology and the selected large language model, it predefines the knowledge graph error detection large language model system and task prompt word templates. The problem generation module is used to extract a single triplet to be detected and its corresponding context from the triplet set of the knowledge graph. It retrieves the top K similar nodes from the knowledge graph vector library by sorting them from high to low similarity using a vector similarity matching method. After merging the similar nodes with the triplet to be detected, it retrieves similar nodes and their corresponding N-order neighbor nodes from the knowledge graph using a text similarity matching method. These are then merged to form a similarity subgraph. The similarity subgraph is further expanded based on a graph pattern matching method, and the retrieval results are used to form the knowledge graph error detection context. The error determination module is used to input the error triple detection prompts formed by the textual transformation of the triple to be detected and the error detection context of the knowledge graph through predefined transformation rules into the large language model according to the predefined template format. Based on the text description context composed of similar subgraphs, the module analyzes the triple to be detected in the order of entity type, relation type, and attribute error detection, outputs the determination result of whether the triple to be detected has an error and the corresponding reasoning process, and guides the knowledge graph update based on the determination result.
8. A computer device, characterized in that, The computer device includes a memory and a processor. The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the error detection method for process industry safety knowledge graph 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, causes the processor to perform the steps of the error detection method for process industry safety knowledge graph based on a large language model as described in any one of claims 1-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
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