Engineering control file generation method and device, equipment and storage medium

By introducing knowledge graphs and model fine-tuning technology into large language models, the hallucination problem of large language models when generating PLC/DCS codes is solved, the reliability and consistency of the code are improved, and the security and accuracy of the generated engineering control files are ensured.

CN120805867APending Publication Date: 2025-10-17HANGZHOU HOLLYSYS AUTOMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511033173.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-25
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Large language models may produce inaccurate or unreasonable outputs (called "hallucinations") when generating PLC/DCS code, resulting in reduced reliability of the generated industrial control code.

Method used

By using knowledge graphs to assist large language models in generating engineering control documents, obtaining analysis results of equipment control subtasks, and retrieving corresponding prior knowledge and instances from the target knowledge graph, the target engineering control documents are generated, and model fine-tuning technology is used to improve the performance of LLM in the industrial field.

Benefits of technology

It reduces the illusion of large language models, improves the reliability of generated engineering control files, reduces code defects caused by type mismatch or interface errors, and ensures the security and consistency of the code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120805867A_ABST
    Figure CN120805867A_ABST
Patent Text Reader

Abstract

The invention discloses an engineering control file generation method and device, equipment and a storage medium, and relates to the technical field of artificial intelligence, and the method comprises the steps: obtaining a target control function description document, and decomposing the target control function description document through a target large language model, so as to obtain equipment control subtasks corresponding to all control functions; analyzing each equipment control subtask to obtain a corresponding analysis result, and retrieving target priori knowledge and a target instance corresponding to the analysis result from the target knowledge graph by using a retrieval enhancement generation technology to obtain a corresponding retrieval result; and generating a target engineering control file corresponding to the target control function description document based on the retrieval result. The knowledge graph is utilized to assist the large language model to generate the engineering control file, so that the illusion of the large language model is reduced, and the reliability of the generated engineering control file is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to an engineering control file generation method, device, equipment and storage medium. BACKGROUND

[0002] Large language models are trained on vast amounts of text data. With their massive training parameters, LLMs (Large Language Models) excel in various natural language processing (NLP) tasks, such as natural language understanding, code generation, and reasoning. In the field of software development, LLMs have shown potential in code snippet generation, error detection, and optimization suggestions based on best practices, thereby improving coding efficiency.

[0003] A knowledge graph is a structured way of representing information using interconnected entities and relationships. In a knowledge graph, concepts are represented as nodes, and connections between nodes represent relationships between them. Knowledge graphs can effectively organize, integrate, and access complex heterogeneous data. In manufacturing, a knowledge graph can represent relationships between equipment, products, materials, and processes, thereby supporting production planning, resource allocation, and fault diagnosis. In asset management, a knowledge graph can integrate asset information from different sources, such as equipment specifications, maintenance history, and sensor data, thereby enabling more effective asset management and predictive maintenance.

[0004] Currently, to reduce the workload of engineers, a large language model is often used to generate PLC (Programmable Logic Controller) / DCS (Distributed Contorl System) code. However, this approach has the problem that the LLM may produce inaccurate or unreasonable outputs (referred to as "hallucinations"), thereby reducing the reliability of the generated industrial control code. SUMMARY

[0005] Therefore, the purpose of the present application is to provide an engineering control file generation method, device, equipment and storage medium, which can generate engineering control files by using a knowledge graph to assist a large language model, thereby reducing the hallucinations of the large language model and ensuring the reliability of the generated engineering control files. The specific solutions are as follows:

[0006] In a first aspect, the present application provides an engineering control file generation method, comprising:

[0007] obtaining a target control function description document, and decomposing the target control function description document by using a target large language model to obtain a device control subtask corresponding to each control function in the target control function description document;

[0008] analyzing each device control subtask to obtain a corresponding analysis result, and retrieving target prior knowledge and target instances corresponding to the analysis result from a target knowledge graph by using retrieval enhancement generation technology to obtain a corresponding retrieval result;

[0009] generating a target engineering control file corresponding to the target control function description document based on the retrieval result; wherein the target prior knowledge includes interfaces and data types of target devices corresponding to the target control function description document, and the target instances include association relationships between each target device and association relationships between a same target device and corresponding function blocks and variables.

[0010] Optionally, before the target control function description document is obtained, the method further comprises:

[0011] constructing a knowledge graph framework, obtaining historical prior knowledge corresponding to a historical control function description document, and filling the knowledge graph framework with the historical prior knowledge to obtain an initial knowledge graph;

[0012] instantiating the historical prior knowledge to obtain historical instances corresponding to the historical prior knowledge, and filling the initial knowledge graph with the historical instances to obtain the target knowledge graph.

[0013] Optionally, before the target control function description document is obtained, the method further comprises:

[0014] selecting a pre-training large language model from each of the preset initial large language models according to the code generation capability of each preset initial large language model;

[0015] fine-tuning the pre-training large language model by using a target model fine-tuning technology and industry knowledge corresponding to the target control function description document to obtain the target large language model; wherein the target model fine-tuning technology includes LoRA and QLoRA.

[0016] Optionally, the target control function description document corresponding to the target engineering control file is generated based on the retrieval result, comprising:

[0017] determining a first subtask and a second subtask from each device control subtask based on the retrieval result; wherein the first subtask is a subtask that has a corresponding function block, and the second subtask is a subtask that does not have a corresponding function block;

[0018] generating, by using the target instance and the target large language model, first control code corresponding to the first sub-task, and generating, by using the target large language model, current second control code corresponding to the second sub-task;

[0019] determining whether the first control code and the current second control code are compatible, and if the first control code and the current second control code are compatible, combining the first control code and the current second control code to generate the target engineering control file corresponding to the target control function description document.

[0020] Optionally, the engineering control file generation method further comprises:

[0021] If the first control code and the current second control code are incompatible, generating, by using the target large language model, new second control code corresponding to the second sub-task, determining the new second control code as the current second control code, and jumping to the step of determining whether the first control code and the current second control code are compatible.

[0022] Optionally, after generating the target engineering control file corresponding to the target control function description document based on the search result, the method further comprises:

[0023] generating a test script corresponding to the target engineering control file, and testing the target engineering control file by using the test script;

[0024] determining whether the target engineering control file passes the test, and if the target engineering control file fails the test, jumping to the step of analyzing each device control sub-task to generate a new engineering control file corresponding to the target control function description document.

[0025] In a second aspect, the present application provides an engineering control file generation device, comprising:

[0026] a document decomposition module configured to obtain a target control function description document, and decompose the target control function description document by using a target large language model to obtain device control sub-tasks corresponding to each control function in the target control function description document;

[0027] a data search module configured to analyze each device control sub-task to obtain corresponding analysis results, and search for target prior knowledge and target instances corresponding to the analysis results from a target knowledge graph by using search enhancement generation technology to obtain corresponding search results;

[0028] The file generation module is configured to generate a target engineering control file corresponding to the target control function description document based on the search result; wherein the target priori knowledge comprises interfaces and data types of target devices corresponding to the target control function description document, and the target instance comprises association relationships among the target devices and association relationships among a same target device, a corresponding function block and a variable.

[0029] Optionally, the document decomposition module further comprises:

[0030] The framework construction unit is configured to construct a knowledge graph framework, acquire historical priori knowledge corresponding to historical control function description documents, and fill the knowledge graph framework with the historical priori knowledge to acquire an initial knowledge graph.

[0031] The knowledge graph filling unit is configured to instantiate the priori knowledge to acquire historical instances corresponding to the historical priori knowledge, and fill the initial knowledge graph with the historical instances to acquire the target knowledge graph.

[0032] In a third aspect, the present application provides an electronic device, comprising:

[0033] The memory is configured to save a computer program.

[0034] The processor is configured to execute the computer program to implement the engineering control file generation method.

[0035] In a fourth aspect, the present application provides a computer readable storage medium configured to save a computer program, wherein the computer program is executed by a processor to implement the engineering control file generation method.

[0036] The application first acquires a target control function description document, and decomposes the target control function description document by using a target large language model to acquire device control subtasks corresponding to each control function in the target control function description document, then analyzes each device control subtask to acquire a corresponding analysis result, and uses retrieval enhancement generation technology to retrieve target prior knowledge and target instances corresponding to the analysis result from a target knowledge graph to acquire a corresponding retrieval result, and finally generates a target engineering control file corresponding to the target control function description document based on the retrieval result; wherein the target prior knowledge includes interfaces and data types of target devices corresponding to the target control function description document, and the target instances include association relationships between each target device and association relationships between the same target device and corresponding function blocks and variables. As can be seen, by using a knowledge graph including interfaces and data types between devices and association relationships between devices to guide a large language model to generate an engineering control file, the application can reduce code defects caused by type mismatch or interface errors; by retrieving prior knowledge and target instances corresponding to the control function description document from the knowledge graph, and generating control engineering code based on the prior knowledge and target instances, the large model illusion can be reduced, and the reliability of the generated code file is improved; by splitting the document into different subtasks, and retrieving data for each subtask respectively, it is ensured that the data retrieved from the knowledge graph corresponds to the control function description document, and the large language model illusion is further reduced. BRIEF DESCRIPTION OF DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.

[0038] Figure 1 A flow chart of an engineering control file generation method disclosed by the present application is provided.

[0039] Figure 2 A flow chart of a specific engineering control file generation method disclosed by the present application is provided.

[0040] Figure 3 A knowledge graph structure diagram disclosed by the present application is provided.

[0041] Figure 4 A flow chart of a knowledge graph construction method disclosed by the present application is provided.

[0042] Figure 5A schematic structural view of an engineering control file generation device disclosed in the present application is shown in the figure.

[0043] Figure 6 A structural view of an electronic device disclosed in the present application is shown in the figure. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0045] At present, the way of generating PLC / DCS code has the problem that LLM may generate inaccurate or unreasonable output (referred to as "hallucination"). Therefore, the present application provides an engineering control file generation method, which generates engineering control files by using a knowledge graph to assist a large language model, reduces the hallucination of the large language model, and ensures the reliability of the generated engineering control files.

[0046] Referring to Figure 1 The embodiment of the present application discloses an engineering control file generation method, which comprises the following steps:

[0047] In step S11, a target control function description document is obtained, and a target large language model is used to decompose the target control function description document to obtain device control sub-tasks corresponding to each control function in the target control function description document.

[0048] The specific process of generating an engineering control file by using a knowledge graph in the embodiment is shown in the figure. Figure 2 After the system obtains the industrial control function description document, the document is split by using a large language model, and control function sub-tasks are extracted. The sub-tasks are analyzed by using a large language model, and corresponding data is retrieved from a knowledge graph. If all the sub-tasks are processed, the output content is integrated and converted into a PLC OpenXML format (an XML format based on IEC 61131-3 standard). The specific process is shown as follows:

[0049] 1. The large model decomposes the function description document (i.e. the target control function description document) into sub-tasks corresponding to relatively single control function requirements;

[0050] 2) The target large language model analyzes the subject and relationship according to the industry semantic dictionary for single control function requirements; this step mainly prepares to find the ontology and instance of the industry knowledge graph (i.e. the target knowledge graph), uses the dictionary and single control function description as input, and uses the prompt word method to decompose the single control function requirements.

[0051] 3) The large model calls MCP (Model Context Protocol) based on the decomposed semantics of single control function requirements to find the target knowledge graph; the following information is searched in the knowledge graph through the prompt word:

[0052] ① Find the ontology and instance from the knowledge graph ontology according to the ontology semantics in the requirements; for example, the flow meter is the ontology and PIC-001 is the instance; usually a control loop contains 2 or 3 instances;

[0053] ② Through the function description such as feedforward PID (proportional-integral-derivative), find the previous associated knowledge graph triples or code files through the ontology;

[0054] ③ Find the instance associated IO point table (saved to the instance in the engineering file);

[0055] ④ Use the above content as input, and cooperate with the prompt word large model to generate control code using the existing IO point reference original template example; (the related parameters of control logic can be set by the large model according to the template reference through the process parameter attribute of the knowledge graph instance; private function blocks and functions can be called by the large model through function block description and example template)

[0056] 4) The agent circulates the control function requirement document to complete the writing of all the function logic;

[0057] 5) Use the fine-tuning large model capability to translate the written control logic into standard PLCOpenXML (i.e. the target engineering control file);

[0058] 6) The PLCOpenXML file can be imported into the control system for use.

[0059] In this embodiment, before obtaining the target control function description document, the following steps are also included: constructing a knowledge graph framework, obtaining historical prior knowledge corresponding to the historical control function description documents, and using the historical prior knowledge to populate the knowledge graph framework to obtain a corresponding initial knowledge graph; instantiating the historical prior knowledge to obtain historical instances corresponding to the historical prior knowledge, and using the historical instances to populate the initial knowledge graph to obtain a target knowledge graph. In other words, in this embodiment, a knowledge graph needs to be constructed in advance, and the knowledge graph contains historical prior knowledge and corresponding instances.

[0060] In addition, in this embodiment, before obtaining the target control function description document, it also includes: screening out a pre-trained large language model from each preset initial large language model according to the code generation capability of each preset initial large language model; using the target model fine-tuning technology and the industry knowledge corresponding to the target control function description document to fine-tune the pre-trained large language model to obtain the target large language model; wherein the target model fine-tuning technology includes LoRA (Low-Rank Adaptation, a model fine-tuning technology) and QLoRA.

[0061] Specifically, in order to improve the efficiency of LLM and reduce hallucinations, this embodiment needs to fine-tune the general LLM, use industry knowledge to train the LLM, and improve the performance of LLM in the industry.

[0062] Select a base model: Choose a pre-trained model (i.e., a pre-trained large language model) with good code generation capabilities. Considering the privacy and offline deployment requirements of the industrial field, give priority to open source inference models that support fine-tuning and upgrades and support Function Calling and MCP features.

[0063] Model fine-tuning: LoRA or QLoRA, choose a parameter-efficient fine-tuning method that only requires fine-tuning a small number of parameters, reducing computational costs.

[0064] The data prepared for fine-tuning is different from that for knowledge graphs. The data required for fine-tuning include:

[0065] 1) Large-scale pre-training corpus: standards (ISA-88, IEC 61131-3, etc.), industry terminology, etc.

[0066] 2) Control the naming of variables in the template;

[0067] The main functions of the target large language model are as follows:

[0068] 1) Semantically segment individual subtask text and match it with industry dictionaries for knowledge graph RAG (Retrieval-Augmented Generation);

[0069] 2) Implement sub-task semantic division on control specification documents;

[0070] 3) Large models can call knowledge graph MCP capabilities.

[0071] By utilizing LLM, the PLC / DCS programming process can be significantly accelerated, and efficiency can be improved through automatic code generation for routine tasks. Natural language interaction can simplify the programming process and lower the learning threshold for new engineers. For example, engineers can use simple natural language instructions to generate complex PLC code without manually writing each line of code. In addition, using LLM to automatically generate documents and test scripts can save a lot of time. Engineers can focus more time and effort on higher-level tasks such as system design and optimization.

[0072] Step S12, analyze each device control sub-task to obtain the corresponding analysis result, and use retrieval enhancement generation technology to retrieve the target prior knowledge and target instance corresponding to the analysis result from the target knowledge graph to obtain the corresponding retrieval result.

[0073] The retrieval process in this embodiment is a retrieval for different device control sub-tasks, rather than directly retrieving data from the target control requirement document. By decomposing the target requirement control document and retrieving the knowledge and instances corresponding to different sub-tasks, the relevance of the retrieval process is improved, thereby ensuring the reliability of the retrieved data.

[0074] The structure of the target knowledge graph in this embodiment is as shown in Figure 3 The knowledge graph ontology and the knowledge graph instance are included; the essence of the knowledge graph ontology is an abstract framework of industry consensus, and the essence of the knowledge graph instance is entity data of a specific scenario, for example, the device process layer in the ontology includes device type definition (such as cracking furnace, flow meter), process parameter attribute (such as range: float), device relationship constraint (such as flow meter-monitor-pipeline), etc. Prior knowledge data, control logic layer includes function block interface specification (such as PID. Input: REAL), safety constraint (such as temperature > 100℃ triggers alarm), engineering experience layer includes template structure definition (such as “device-function block-variable” triple);

[0075] The device process layer of the knowledge graph instance includes specific device position numbers (such as FIC-0X000A), actual parameter values (such as range = 0~500 ), the physical connection between devices (such as FT-101→regulating valve V-201), the control logic layer includes the specific parameters of the vendor function block (such as XX company PID_Block.Kp=2.5), the control logic chain in the historical project (such as [reaction furnace]→[controlled by]→[PID_Block]), the engineering experience layer includes: historical control loop templates (such as [furnace F-001]→[total controller FB]→[flow meter FT-001]); that is, the corresponding relationship between the ontology of the knowledge graph and the instance data of the knowledge graph, the ontology is used to store related prior knowledge, and the instance stores specific examples corresponding to the prior knowledge.

[0076] The programming method based on the large language model and the knowledge graph has different advantages compared with the prior art, and the comparison results are shown in Table 1:

[0077] Table 1 Comparison table of programming method advantages

[0078]

[0079] By retrieving data corresponding to the subtask from the target knowledge graph including the prior knowledge ontology and the corresponding instance, the LLM can generate more secure and reliable PLC / DCS code. The structured information in the knowledge graph can reduce errors and inconsistencies in the generated code. For example, by clearly defining the interfaces and data types between devices, code defects caused by type mismatches or interface errors can be reduced. In addition, the LLM can assist in code verification and confirmation, helping engineers to find and fix potential errors.

[0080] Step S13, generating a target engineering control file corresponding to the target control function description document based on the retrieval result; wherein the target prior knowledge includes the interface and data type of the target device corresponding to the target control function description document, and the target instance includes the association relationship between each target device and the association relationship between the same target device and the corresponding function block and variable.

[0081] In this embodiment, the process of generating the target engineering control file corresponding to the target control function description document based on the search result can specifically include: determining a first subtask and a second subtask from each device control subtask based on the search result; the first subtask is a subtask that has a corresponding function block, and the second subtask is a subtask that does not have a corresponding function block; generating a first control code corresponding to the first subtask using the target instance and the target large language model, and generating a current second control code corresponding to the second subtask using the target large language model; determining whether the first control code and the current second control code are compatible, if the first control code and the current second control code are compatible, combining the first control code and the current second control code to generate the target engineering control file corresponding to the target control function description document.

[0082] That is, if there is no instance corresponding to some subtasks (i.e., the second subtask) in the target knowledge graph, the control code corresponding to the subtask is directly generated using the target large language model; if there is an instance corresponding to the subtask (i.e., the first subtask) in the target knowledge graph, the control code corresponding to the first subtask is generated using the retrieved instance and the target large language model, and the control codes of the first subtask and the second subtask are combined to obtain the control engineering file.

[0083] If the first control code and the current second control code are incompatible, a new second control code corresponding to the second subtask is generated using the target large language model, the new second control code is determined as the current second control code, and the step of determining whether the first control code and the current second control code are compatible is jumped to.

[0084] In this embodiment, after generating the target engineering control file corresponding to the target control function description document based on the search result, the method further includes: generating a test script corresponding to the target engineering control file, and testing the target engineering control file using the test script; determining whether the target engineering control file passes the test, if the target engineering control file does not pass the test, jumping to the step of analyzing each device control subtask to generate a new engineering control file corresponding to the target control function description document.

[0085] That is, the embodiment can also generate a test script corresponding to the engineering control file using the large language model, and test the engineering control file using the test script, thereby ensuring the reliability of the generated engineering control file.

[0086] It can be seen that, by using the knowledge graph including the interfaces and data types between devices and the association relationship between devices to guide the large language model to generate the engineering control file, the code defects caused by type mismatch or interface error can be reduced; by retrieving the prior knowledge and target instance corresponding to the control function description document from the knowledge graph, and generating the control engineering code review according to the prior knowledge and the target instance, the large model illusion can be reduced, and the reliability of the generated code file is improved; by splitting the document into different sub-tasks, and respectively retrieving data for each sub-task, it is ensured that the data retrieved from the knowledge graph is highly corresponding to the control function description document, and the large language model illusion is further reduced.

[0087] Based on the foregoing embodiments, the present application describes the overall process of engineering control file generation. In order to make the technical solutions in the present application more complete, next, the present application will elaborate the process of constructing the knowledge graph, see Figure 4 As shown in the figure, the embodiment of the present application discloses a process of constructing a knowledge graph, comprising:

[0088] Step S21, constructing a knowledge graph framework, acquiring historical prior knowledge corresponding to the historical control function description document, and filling the knowledge graph framework with the historical prior knowledge to acquire a corresponding initial knowledge graph.

[0089] In this embodiment, first, the ontology / schema of the knowledge graph needs to be defined:

[0090] 1. Controlled device and process ontology modeling: conforming to the device type definition and relationship type (satisfying the device correspondence) of the petrochemical process industry in ISO 15926 and DEXPI (a data standard), etc.;

[0091] 2. Control system and code modeling: conforming to the industrial control engineering component type definition and relationship type according to IEC61131-3 standard; including various function blocks (FB, Funciton Block) and functions specific to each supplier, and attribute details are described;

[0092] 3. Ontology mapping relationship between control code variable definition and device bit number;

[0093] 4. Control loop code case, associated with the controlled device, usually containing the relationship of 1~3 device types.

[0094] The above data, i.e. historical prior knowledge, can be used to fill the knowledge graph framework, so as to obtain an initial knowledge graph including historical prior knowledge. It can be understood that the target knowledge graph in the embodiment also includes instances corresponding to the historical prior knowledge. After constructing the initial knowledge graph by using the historical prior knowledge, the initial knowledge graph needs to be enriched by using the corresponding instances.

[0095] Step S22, instantiating the historical prior knowledge to obtain historical instances corresponding to the historical prior knowledge, and filling the initial knowledge graph by using the historical instances to obtain a target knowledge graph.

[0096] In the embodiment, the historical prior knowledge needs to be instantiated. Specifically, the specific process of process design knowledge (i.e. historical prior knowledge) instance extraction is as follows:

[0097] 1. By using the input DEXPI and ISO 15926 standard formalized files, the engineering design knowledge of the project can be customized to extract tools to realize the mapping of standard files to knowledge graph instances.

[0098] 2. PFD (Process Flow Diagram, i.e. process flow diagram) and P&ID (Piping and Instrument Diagram, i.e. process piping and instrument flow diagram) are files that have not yet realized standardization. Therefore, a small model can be used for recognition to convert them into formalized files and then perform knowledge instance extraction.

[0099] The above process is as follows:

[0100] Analyzing the standardized engineering files (DEXPI / ISO 15926 format) to automatically map the equipment position number (such as FIC-0X000A / B) and design parameters to the instances of the equipment process ontology;

[0101] Using an image recognition model to extract the equipment entities associated by the control loop dotted line in the non-standard drawing (P&ID / PFD) to convert them into temporary instances and associate them to the equipment process ontology;

[0102] Dismantling the historical engineering control loop to extract the "equipment instance-function block-variable mapping" triple (such as "furnace F-001←[total controller FB]→flow meter FT-001") and store it as a reusable template instance.

[0103] 3. The template instance of the previously existing engineering project after control loop disassembly usually includes the following parts: controlled object and its key process parameter attributes, control loop function block, and IO mapping table (mapping relationship between control system variables (including soft points and hard points) and equipment variables)

[0104] 4、Case template for existing control loop, mostly for controlling 1~3 device instances of process parameters as input or output, intermediary function block (FB) and function contain parameters and input default value.

[0105] By storing safety guidelines and common safety code patterns in the knowledge graph, the LLM can generate more secure and reliable PLC / DCS code. Structured information in the knowledge graph can reduce errors and inconsistencies in generated code. At the same time, it solves the problem of large model illusion and poor reliability of knowledge graph, weakens the complete dependence on large model training, and reduces the cost of engineering customization for different sub-sectors.

[0106] Referring to Figure 5 The embodiment of the application discloses an engineering control file generation device, comprising:

[0107] The document decomposition module 11 is configured to obtain a target control function description document and decompose the target control function description document using a target large language model to obtain device control sub-tasks corresponding to each control function in the target control function description document;

[0108] The data retrieval module 12 is configured to analyze each device control sub-task to obtain corresponding analysis results, and use retrieval enhancement generation technology to retrieve target prior knowledge and target instances corresponding to the analysis results from a target knowledge graph to obtain corresponding retrieval results;

[0109] The file generation module 13 is configured to generate a target engineering control file corresponding to the target control function description document based on the retrieval results; wherein the target prior knowledge includes interfaces and data types of target devices corresponding to the target control function description document, and the target instances include association relationships between the target devices and association relationships between the same target device and corresponding function blocks and variables.

[0110] As can be seen, the application can reduce code defects caused by type mismatch or interface errors by using a knowledge graph including interfaces and data types between devices and association relationships between devices to guide a large language model to generate an engineering control file; by retrieving prior knowledge and target instances corresponding to the control function description document from the knowledge graph, and generating control engineering code based on the prior knowledge and target instances, the large model illusion can be reduced, and the reliability of the generated code file is improved; by splitting the document into different sub-tasks and retrieving data for each sub-task respectively, it is ensured that the data retrieved from the knowledge graph corresponds to the control function description document, and the large language model illusion is further reduced.

[0111] In some embodiments, the document decomposition module 11 further comprises:

[0112] a framework construction unit, configured to construct a knowledge graph framework, acquire historical prior knowledge corresponding to the historical control function description document, and fill the knowledge graph framework with the historical prior knowledge to acquire an initial knowledge graph;

[0113] a knowledge graph filling unit, configured to instantiate the prior knowledge to acquire historical instances corresponding to the historical prior knowledge, and fill the initial knowledge graph with the historical instances to acquire the target knowledge graph.

[0114] In some embodiments, the document decomposition module 11 further comprises:

[0115] a model screening unit, configured to screen a pre-training large language model from the preset initial large language models according to the code generation capabilities of the preset initial large language models;

[0116] a model fine-tuning unit, configured to fine-tune the pre-training large language model with a target model fine-tuning technology and industry knowledge corresponding to the target control function description document to acquire the target large language model; wherein the target model fine-tuning technology includes LoRA and QLoRA.

[0117] In some embodiments, the file generation module 13 can specifically comprise:

[0118] a task determination unit, configured to determine a first subtask and a second subtask from the device control subtasks based on the search results; wherein the first subtask is a subtask with a corresponding function block, and the second subtask is a subtask without a corresponding function block;

[0119] a code generation unit, configured to generate first control code corresponding to the first subtask with the target instance and the target large language model, and generate current second control code corresponding to the second subtask with the target large language model;

[0120] a file generation unit, configured to determine whether the first control code and the current second control code are compatible, and if the first control code and the current second control code are compatible, combine the first control code and the current second control code to generate the target engineering control file corresponding to the target control function description document.

[0121] In some embodiments, the engineering control file generation apparatus further comprises:

[0122] The step jump module is configured to, if the first control code and the current second control code are incompatible, generate a new second control code corresponding to the second subtask by using the target large language model, determine the new second control code as the current second control code, and jump to the step of judging whether the first control code and the current second control code are compatible.

[0123] In some embodiments, the file generation module 13 further comprises:

[0124] The file test unit is configured to generate a test script corresponding to the target engineering control file, and test the target engineering control file by using the test script.

[0125] The step jump unit is configured to determine whether the target engineering control file passes the test. If the target engineering control file fails the test, the step jump unit jumps to the step of analyzing each device control subtask to generate a new engineering control file corresponding to the target control function description document.

[0126] Further, the embodiment of the present application further discloses an electronic device, Figure 6 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the contents in the figure cannot be considered as any limitation on the use range of the present application.

[0127] Figure 6 A structural schematic diagram of an electronic device 20 provided by the embodiment of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the related steps in the engineering control file generation method disclosed in any of the preceding embodiments. In addition, the electronic device 20 in the embodiment can be an electronic computer.

[0128] In the embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which is not limited here; the input / output interface 25 is used to obtain external input data or output data to the outside world, and the specific interface type can be selected according to the specific application needs, which is not limited here.

[0129] In addition, the memory 22 can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc. as a carrier for storing resources, and the resources stored thereon can include an operating system 221, a computer program 222, etc. The storage mode can be temporary storage or permanent storage.

[0130] The operating system 221 is used to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the engineering control file generation method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include a computer program capable of completing other specific work.

[0131] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the engineering control file generation method disclosed above. For the specific steps of the method, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be described here.

[0132] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. For the same or similar parts between the embodiments, please refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and please refer to the method part for the relevant part.

[0133] The skilled person can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of the two. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in the above description. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0134] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0135] Finally, it needs to be pointed out that in this document, relational terms such as first and second and the like can only be intended to distinguish one entity or operation from another entity or operation without necessarily requiring or implying any actual such relationship or order between such entities or operations. Moreover, the terms "comprising", "including", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the stated element.

[0136] The above detailed description of the technical solutions provided by the present application has been provided, and the principles and implementation modes of the present application have been described by applying specific examples. The above description of the examples is only for the purpose of helping to understand the method of the present application and its core idea; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description of the content of the specification should not be understood as a limitation of the present application.

Claims

1. A method for generating an engineering control document, characterized in that: include: Obtaining a target control function description document, and decomposing the target control function description document using a target large language model to obtain device control subtasks corresponding to respective control functions in the target control function description document; Analyze each of the device control subtasks to obtain corresponding analysis results, and use retrieval enhancement generation technology to retrieve target prior knowledge and target instances corresponding to the analysis results from the target knowledge graph to obtain corresponding retrieval results; A target engineering control file corresponding to the target control function description document is generated based on the retrieval results; wherein, the target prior knowledge includes the interface and data type of the target device corresponding to the target control function description document, and the target instance includes the association relationship between each of the target devices and the association relationship between the same target device and the corresponding function block and variable.

2. The method for generating engineering control files according to claim 1, wherein: Before obtaining the target control function description document, the method further includes: Constructing a knowledge graph framework, obtaining historical prior knowledge corresponding to the historical control function description document, and using the historical prior knowledge to fill the knowledge graph framework to obtain a corresponding initial knowledge graph; The historical prior knowledge is instantiated to obtain historical instances corresponding to the historical prior knowledge, and the initial knowledge graph is filled with the historical instances to obtain the target knowledge graph.

3. The method for generating engineering control files according to claim 1, wherein: Before obtaining the target control function description document, the method further includes: Selecting a pre-trained large language model from each of the preset initial large language models according to the code generation capability of each of the preset initial large language models; The pre-trained large language model is fine-tuned using target model fine-tuning technology and industry knowledge corresponding to the target control function description document to obtain the target large language model; wherein the target model fine-tuning technology includes LoRA and QLoRA.

4. The method for generating engineering control files according to claim 1, wherein: Generating a target engineering control file corresponding to the target control function description document based on the search result includes: Determining a first subtask and a second subtask from each of the device control subtasks based on the search result; wherein the first subtask is a subtask having a corresponding function block, and the second subtask is a subtask not having a corresponding function block; generating a first control code corresponding to the first subtask using the target instance and the target large language model, and generating a current second control code corresponding to the second subtask using the target large language model; Determine whether the first control code and the current second control code are compatible. If the first control code and the current second control code are compatible, combine the first control code and the current second control code to generate the target engineering control file corresponding to the target control function description document.

5. The method for generating engineering control files according to claim 4, characterized in that: Also includes: If the first control code and the current second control code are incompatible, the target large language model is used to generate a new second control code corresponding to the second subtask, the new second control code is determined as the current second control code, and the process jumps to the step of determining whether the first control code and the current second control code are compatible.

6. The method for generating engineering control documents according to any one of claims 1 to 5, characterized in that: After generating the target engineering control file corresponding to the target control function description document based on the search result, the method further includes: Generate a test script corresponding to the target engineering control file, and use the test script to test the target engineering control file; Determine whether the target engineering control file passes the test. If the target engineering control file fails the test, jump to the step of analyzing each of the equipment control subtasks to generate a new engineering control file corresponding to the target control function description document.

7. A device for generating engineering control documents, characterized in that: include: a document decomposition module, configured to obtain a target control function description document and decompose the target control function description document using a target large language model to obtain device control subtasks corresponding to respective control functions in the target control function description document; A data retrieval module is used to analyze each of the device control subtasks to obtain corresponding analysis results, and use retrieval enhancement generation technology to retrieve target prior knowledge and target instances corresponding to the analysis results from the target knowledge graph to obtain corresponding retrieval results; A file generation module is used to generate a target engineering control file corresponding to the target control function description document based on the retrieval results; wherein the target prior knowledge includes the interface and data type of the target device corresponding to the target control function description document, and the target instance includes the association relationship between each of the target devices and the association relationship between the same target device and the corresponding function block and variable.

8. The engineering control file generating device according to claim 7, characterized in that: The document decomposition module further includes: A framework construction unit, configured to construct a knowledge graph framework, obtain historical prior knowledge corresponding to a historical control function description document, and fill the knowledge graph framework with the historical prior knowledge to obtain a corresponding initial knowledge graph; The knowledge graph filling unit is used to instantiate the prior knowledge to obtain historical instances corresponding to the historical prior knowledge, and use the historical instances to fill the initial knowledge graph to obtain the target knowledge graph.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the method for generating an engineering control document according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that Used to store a computer program, which, when executed by a processor, implements the engineering control file generation method according to any one of claims 1 to 6.