Method, in particular computer-assisted method, computer program product, and computer-readable medium
The method automates program code generation for industrial simulations using a system and user prompt to guide AI, addressing complexity and format limitations, facilitating efficient code creation and testing on diverse platforms.
Patent Information
- Application Number
- PCT/EP2024/079558
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-04-17
- Filing Date
- 2024-10-18
- Publication Date
- 2025-10-23
AI Technical Summary
Existing methods for creating program code for simulating industrial applications are complex and require manual effort, and existing AI systems often support only specific formats, making it difficult to automate code generation for diverse software platforms like Siemens' TIA Portal.
A method utilizing a system prompt and user prompt to guide artificial intelligence in generating program code, where the system prompt provides format instructions and the user prompt offers a functional description, enabling automated code generation in a standardized format like TAT, using a Large Language Model (LLM) like ChatGPT.
Enables efficient, automated generation of program code for simulations, allowing seamless integration and testing on platforms like Siemens' TIA Portal, reducing manual effort and ensuring compatibility across various formats.
Smart Images

Figure EP2024079558_23102025_PF_FP_ABST
Abstract
Description
[0001] Description
[0002] Method, in particular computer-aided method, computer program product and computer-readable medium
[0003] The present invention relates to a method, in particular a computer-aided method, for the automated generation of program code for simulating an application. Furthermore, the invention relates to a computer program product and a computer-readable medium, in particular a storage medium.
[0004] Many industrial applications are constantly in need of streamlining. The automation of industrial processes, for example, in product manufacturing, plays an important role in this. Special control devices, such as programmable logic controllers (PLCs), are often used to control systems. Such control devices typically have a computer unit and a multitude of signal inputs and outputs. These can be digital or analog inputs and outputs, for example.
[0005] Such control devices can be individually programmed by the user. This means, for example, that specific connections can be established between inputs and outputs to control applications or components of an industrial plant.
[0006] Real-world testing of the program code created for an application during such programming is extremely complex, as it would require virtually the entire industrial plant to be fully operational. Therefore, simulations are performed in appropriate software applications or software platforms, such as Siemens AG's TIA Portal. These simulations are also referred to as test cases. Such simulations or test cases do not require access to the corresponding real industrial plant.
[0007] To date, program code for simulating such applications has mostly been created manually. In principle, program code can also be created automatically using artificial intelligence, in particular a large language model. However, such AIs generally only support certain program code formats. This makes it difficult to automatically create program code for simulating applications for specific software platforms. The object of the present invention is therefore to provide a method by which program code for simulating an application can be created.
[0008] This object is achieved by a method, in particular a computer-aided method, for the automated generation of program code for the simulation of an application, the method comprising the following steps:
[0009] - Providing a system prompt containing instructions on the format and / or structure of the program code;
[0010] - Providing a user prompt containing a functional description of the application;
[0011] - automated generation of program code based on the system prompt and the user prompt for simulating the application using artificial intelligence.
[0012] The invention is based on the fundamental idea of separating instructions for the artificial intelligence to generate the program code. The system prompt contains instructions regarding the format or structure of the program code to be created using the artificial intelligence. In other words, the system prompt instructs the artificial intelligence to create program code in the desired format. The user prompt, on the other hand, contains a concrete functional description of the application. This means that the user prompt essentially describes the concrete function of the application and, in this regard, guides the artificial intelligence in creating the program code. The user prompt can be created directly by the operator, whereas the system prompt runs essentially in the background and cannot be perceived by an operator / programmer.An application is preferably understood to mean a control task of a plant, in particular an industrial plant, or of a part of a plant or an industrial process. In other words, the generated program code can be used to control a plant, in particular an industrial plant, or of a part of a plant or an industrial process.
[0013] In a further embodiment of the invention, the program code can be exported to a software platform. This software platform can be, for example, the TIA Portal, which is offered by Siemens AG. Specifically, it can be the TIA test suite. The program code is preferably used to simulate the application. In other words, the method according to the invention can comprise, as a further step, carrying out a corresponding simulation of the application. In this way, it can be checked whether the application, which is to be used, for example, in an industrial plant, is running without problems. For this purpose, the processes of the industrial plant in question or the respective application can be mapped. As a result, information about the pass or failure of the test or simulation can then be output.
[0014] The program code can be generated in a standardized format. Instructions regarding this format are preferably specified by the artificial intelligence system prompt. The standardized format can be the TAT format.
[0015] The system prompt can contain instructions about permissible commands. In other words, the system prompt can define commands that the artificial intelligence can use in the program code it generates. Preferably, the system prompt contains instructions about the structure of commands. In this way, the artificial intelligence can be generally instructed on how to use commands. For example, such instructions can specify that certain sections, e.g., PROPERTY and VAR sections, are only generated once in the program code. It can also be specified that each block, e.g., a STEP-END_STEP block, may only contain a single RUN function. It can also be specified that variable declarations and assignments must be at the beginning of the program code and, in particular, may not be executed after a RUN function.
[0016] The system prompt can also contain instructions for commenting program code. For example, it can specify that double slash characters should be used for code comments. The system prompt can also define additional requirements for specific blocks or block types. The system prompt can also contain a template that specifies the format for the program code.
[0017] The system prompt is preferably not visible to the operator / programmer. This means that the operator / programmer of an application has no knowledge of the system prompt; it is merely used in the background to instruct the artificial intelligence. The user prompt is preferably created or provided with content by an operator / programmer. The user prompt can contain the name of a function block. Furthermore, the user prompt can contain a functional description of the application. This is preferably created, for example, by an operator / programmer using an appropriate input mask. Creating the user prompt preferably requires great care on the part of the operator / programmer. Particular attention must be paid to the precise description of the specific problem. The required parameters must also be precisely named, taking care to ensure that no logical conflicts arise.
[0018] Furthermore, the user prompt can contain a specification of input and / or output parameters. This can be in the form of a parameter table, for example. The parameter table can be available in a standardized format, such as CSV format.
[0019] According to a preferred embodiment of the method according to the invention, the artificial intelligence is a Large Language Model (LLM) or one is used. Such an LLM is occasionally also referred to as a large language model. Such Large Language Models are preferably characterized by their ability to understand input in text form and generate texts from it. For example, the Large Language Model can be ChatGPT, preferably ChatGPT 3.5 or 4.0.
[0020] In a specific embodiment, a temperature of at least 0.1, in particular of at least 0.3, preferably of at least 0.5, and / or of at most 1.5, in particular of at most 1.0, preferably of at most 0.7, can be set for generating the program code using the Large Language Model. In the context of a Large Language Model, temperature is preferably also understood to mean randomness. In other words, temperature represents a hyperparameter that ultimately indicates the level of creativity in the generated program code.
[0021] To generate the program code, the parameter Top_P of the Large Language Model can be set to at least 0.5, in particular at least 0.7, preferably at least 0.9, and / or at most 1.5, in particular at most 1.2, preferably at most 1.0, particularly preferably 0.95. This value can be used to control the variety of answers, for example by only taking into account the top "P" % of the probable words. For generating the program code, the parameter Max_Tokens (number of words to be output or text length) of the Large Language Model is preferably set to at least 200, in particular at least 500, preferably at least 1000 and / or at most 8000, in particular at most 5000, preferably at most 3000. This parameter specifies the maximum length for the output.
[0022] In a further embodiment, the program code can be generated on an external computer device. This device is preferably connected to the operator via the Internet. In other words, the operator can enter an input on a local computer, which in particular includes the relevant information for the user prompt. The user prompt thus created can be transmitted, together with the system prompt (preferably invisible to the operator), to an external computer device, where the program code is generated using artificial intelligence. Alternatively, it is also conceivable for the program code to be generated locally on the operator's computer.
[0023] In a further embodiment, the system prompt and / or the user prompt can be sent to the external computer device or created there. After the program code has been generated, it can be sent back from an external computer device and stored locally by the operator, preferably on a (local) computer of the operator / programmer.
[0024] The invention further provides a computer program product comprising instructions which, when the program is executed by a computer, cause the computer to carry out the method according to the invention as described above.
[0025] Furthermore, the invention provides a computer-readable medium, in particular a storage medium, on which the computer program product is stored.
[0026] For further details of the invention, reference is made to the dependent claims and the following description of an embodiment with reference to the drawing. In the drawing:
[0027] Figure 1 shows the method according to the invention in a schematic representation; and
[0028] Figure 2 shows the structure of the system prompt and the user prompt for the method according to the invention in a schematic representation. Figure 1 initially shows a schematic representation of the method according to the invention. This initially comprises the provision of a system prompt 1, which contains instructions regarding the format and / or structure of the program code 4 to be generated. The method further comprises the provision of a user prompt 2, which contains a functional description of the specific application. Based on the system prompt 1 and the user prompt 2, a program code 4 is generated using artificial intelligence 3, in this case ChatGPT. This program code 4 is ultimately available in the specified TAT format, as shown on the right in Figure 1.
[0029] Figure 2 shows an example of the structure of System Prompt 1 and User Prompt 2. System Prompt 1 contains instructions about permissible commands and / or about the structure of commands, as well as a template that specifies the format for program code 4. In contrast, User Prompt 2 contains the name of a function block, a functional description of the application, and a parameter table for input and output parameters.
[0030] The method according to the invention makes it possible to generate program code in a simple, automated manner, in particular for carrying out simulations or test cases.
[0031] Although the invention has been illustrated and described in detail by the preferred embodiment, the invention is not limited to the disclosed examples and other variations may be derived therefrom by those skilled in the art without departing from the scope of the invention.
[0032] Regardless of the grammatical gender of a particular term, persons with male, female or other gender identities are included.
Claims
Patent claims 1. A method, in particular a computer-aided method, for the automated generation of program code (4) for the simulation of an application, comprising the following steps: - Providing a system prompt (1) containing instructions on the format and / or structure of the program code (4); - Providing a user prompt (2) containing a functional description of the application; - automated generation of a program code (4) based on the system prompt (1) and the user prompt (2) for the simulation of the application using artificial intelligence (3).
2. Method according to claim 1, characterized in that the program code (4) is exported to a software platform.
3. Method according to claim 1 or 2, characterized in that the program code (4) is used to simulate the application.
4. Method according to one of the preceding claims, characterized in that the program code (4) is generated in a standardized format, in particular in TAT format.
5. Method according to one of the preceding claims, characterized in that the system prompt (1) contains instructions about permissible commands and / or about the structure of commands.
6. Method according to one of the preceding claims, characterized in that the system prompt (1) contains instructions on commenting program code (4).
7. Method according to one of the preceding claims, characterized in that the system prompt (1) is not visible to an operator.
8. Method according to one of the preceding claims, characterized in that the user prompt (2) contains the name of a function block.
9. Method according to one of the preceding claims, characterized in that the user prompt (2) contains a functional description of the application, wherein the functional description is created in particular by an operator.
10. Method according to one of the preceding claims, characterized in that the user prompt (2) contains an indication of input and / or output parameters, and / or that the user prompt (2) contains a parameter table, in particular in a standardized format, preferably in csv format.
11. Method according to one of the preceding claims, characterized in that the artificial intelligence (3) is a large language model or such a model is used, wherein in particular ChatGPT, preferably ChatGPT 3.5 or 4.0, is used.
12. The method according to claim 11, characterized in that for generating the program code (4) using the large language model, a temperature (randomness) of at least 0.1, in particular of at least 0.3, preferably of at least 0.5, and / or of at most 1.5, in particular of at most 1.0, preferably of at most 0.7 is set.
13. The method according to claim 11 or 12, characterized in that for generating the program code (4) the parameter Top P of the Large Language Model is set to at least 0.5, in particular at least 0.7, preferably at least 0.9, and / or at most 1.5, in particular at most 1.2, preferably at most 1.0, particularly preferably 0.
95.
14. Method according to one of claims 11 to 13, characterized in that for generating the program code (4) the parameter Max Tokens (number of words to be output or text length) of the Large Language Model is set to at least 200, in particular at least 500, preferably at least 1000, and / or at most 8000, in particular at most 5000, preferably at most 3000.
15. Method according to one of the preceding claims, characterized in that the generation of the program code (4) takes place on an external computer device which is preferably connected to the operator via the Internet.
16. Method according to one of the preceding claims, characterized in that the system prompt (1) and / or the user prompt (2) are sent to the external computer device or created there.
17. The method according to claim 15 or 16, characterized in that the generated program code (4) is sent back by an external computer device and in particular stored locally.
18. A computer program product comprising instructions which, when executed by a computer, cause the computer to carry out the method according to one of the preceding claims.
19. A computer-readable medium, in particular a storage medium, on which the Computer program product according to claim 18.