Equipment test model code generation method based on large model
By designing and equipping digital test requirements analysis modules, large model training code collection and processing modules, code base modules and large model pre-training and fine-tuning modules, the problems of traditional manual code consuming and insufficient data are solved, and high quality is achieved. Fast equipment test model code generation ensures the accuracy and reliability of the code.
Patent Information
- Application Number
- CN202411539775.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-10-31
AI Technical Summary
Traditional hand-made code writing is difficult to meet the needs of complex equipment testing models, it is time-consuming and labor-intensive and easy to introduce human errors. The existing large-model-driven code generation technology has limitations in insufficient data and code quality optimization.
Design equipment digital test requirements analysis module, large model training code collection and processing module, equipment testing model code base module and large model pre-training and fine-tuning module, and generate high-quality equipment through data augmentation, structured storage, knowledge graph and reinforcement learning. Test model code, reduce manual writing, and improve the efficiency and accuracy of code generation.
It significantly improves the speed and accuracy of code generation, ensures the adaptability and universality of the code, avoids human errors, and realizes efficient generation and reliable application of equipment test model code.
Smart Images

Figure CN119248238A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of electronic engineering and computer science, and in particular relates to a method for generating equipment test model codes based on a large model. Background Art
[0002] As the complexity of equipment systems continues to increase, traditional manual code writing and maintenance can no longer meet the needs of modern equipment development. Especially for complex equipment test models, manual coding is not only time-consuming and labor-intensive, but also prone to human errors, affecting the quality and stability of the code. In order to improve the efficiency and reliability of code generation, large model-driven code generation technology has gradually received attention in recent years. Code generation technology based on large-scale pre-trained models can automatically generate high-quality code that meets the functional and performance requirements of equipment by learning massive code data. However, in the prior art, in the process of equipment test model code generation, problems such as insufficient data and code quality optimization still exist, limiting the widespread application of this technology. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides a method for generating equipment test model code based on a large model. The method designs an equipment digital test requirement analysis module, a large model training code collection and processing module, an equipment test model code library module, and a large model pre-training and fine-tuning module. The method can quickly generate equipment test model code to a certain extent, reduce the time for manual code writing, improve development efficiency, and ensure the accuracy and reliability of the code.
[0004] To achieve the above object, the present invention adopts the following technical solutions:
[0005] A method for generating equipment test model code based on a large model, comprising:
[0006] Step (1), designing an equipment digital test requirement analysis module, which is used to extract the digital test requirements for equipment test model modeling code generation by building an equipment digital test identification framework system in combination with the requirement description;
[0007] Step (2), designing a large model training code collection and processing module, which is used to prepare the required basic equipment test model code set according to the equipment characteristics and the generated digital test requirements, and when the basic equipment test model code set is insufficient to support high-quality code generation, perform data enhancement to generate a high-quality equipment test model code data set;
[0008] Step (3), designing an equipment test model code library module, which is used to perform structured storage on the high-quality code data set, construct a knowledge graph based on the structured data, and design a vectorized dynamic query function for dynamic combination when generating equipment test model code;
[0009] Step (4): design a large model pre-training and fine-tuning module, use the high-quality code set and vectorized dynamic query function to perform secondary pre-training and fine-tuning on the base code large model, call the required equipment test model code based on the knowledge graph, use reinforcement learning to enhance the called equipment test model code, and generate the final equipment test model code.
[0010] Furthermore, the step (1) includes:
[0011] Step (1.1), accept the requirement specification document provided by the user, analyze the requirement information in the requirement specification document through the big model, combine the keywords and semantic patterns in the requirement information, and identify the key elements in the experiment;
[0012] Step (1.2): Based on the identified key elements of the experiment, design the experiment scenario, generate parameters for each element in the experiment scenario, and define the interaction rules of the confrontation between the two sides, such as the victory and defeat judgment criteria in the combat environment, time process, force loss model, etc.
[0013] Step (1.3): construct a digital test and identification framework system for equipment to perform parametric test simulation and screen out the optimal modeling requirements.
[0014] Furthermore, the step (2) includes:
[0015] Step (2.1), prepare a historical equipment test model code dataset, including real test equipment test model code, digital test equipment test model code, open source code base, and code samples manually written by domain experts, structure the historical equipment test model code dataset, annotate it according to function, performance, and modularity standards, and perform semantic transformation on the code, thereby expanding the diversity of the dataset and generating code that is diverse but still maintains semantic consistency;
[0016] Step (2.2): When the historical equipment test model code data set is insufficient, an expanded equipment test model code is generated based on the large model. The expanded equipment test model code is automatically verified and scored in combination with the equipment physical behavior simulation model to screen out high-quality equipment test model codes that meet functional requirements, thus forming a high-quality equipment test model code data set.
[0017] Furthermore, the step (3) includes:
[0018] Step (3.1), classify and store high-quality equipment test model codes, common code templates and solutions as structured data, divide code snippets into multiple functional modules, build a modular code library, and dynamically generate code for each module based on the functional requirements of the equipment;
[0019] Step (3.2): statically analyze the dependencies of the code snippets, extract relevant metadata from the code snippets, build associations between the code snippets and the metadata, store the equipment test model code snippets and the associated metadata in a structured manner in a graph database, determine the nodes and relationship edges of each code snippet, and build a knowledge graph of the code snippets;
[0020] Step (3.3), construct a query mechanism, embed the code snippet into a high-dimensional vector space, and dynamically combine the vector retrieval query to find the code snippet that is most similar to the current requirement, all the upstream code snippets that the most similar code snippet depends on, and which downstream code snippets depend on the most similar code snippet.
[0021] Furthermore, the step (4) includes:
[0022] Step (4.1), adaptively adjusting the base code generation large model, extracting the topological structure and physical characteristics of the equipment test model, and performing secondary pre-training based on the topological structure and physical characteristics;
[0023] Step (4.2), use the high-quality equipment test model code data set for fine-tuning, build a thinking chain prompt to guide the code generation model to perform step-by-step reasoning according to the steps of natural language requirements, complex task decomposition, equipment test model mathematical equation construction, and equipment test model code generation;
[0024] Step (4.3): Decompose the complex equipment test model code generation task into multiple short sequence generation tasks, define the generated code fragments and the strategy for generating the next code fragment for each short sequence, call the required equipment test model code based on the knowledge graph, and combine the multi-task reinforcement learning strategy for code enhancement. During the reinforcement learning process, if the task is successfully decomposed and the corresponding mathematical equation is generated, a reward will be given. If the decomposition is wrong or not decomposed, a penalty will be given, ultimately achieving the enhancement of the equipment test model code generation capability.
[0025] The beneficial effects of the present invention are:
[0026] (1) The present invention can automatically generate high-quality code based on the equipment digital test requirement analysis module through the pre-training and fine-tuning technology of the large model, reducing manual participation and avoiding errors in human writing. Compared with traditional methods, this method can significantly improve the speed and accuracy of code generation, and at the same time, combined with the equipment test model code library module, ensure that the generated code has wide adaptability and versatility.
[0027] (2) By constructing a knowledge graph of equipment test model codes, the present invention can effectively store equipment test model codes, facilitate subsequent tasks in finding equipment test model codes in the knowledge graph, and ensure the execution efficiency and stability of the code under complex working conditions, thereby realizing efficient generation and reliable application of equipment test model codes. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The present invention is a principle block diagram of a method for generating equipment test model code based on a large model. DETAILED DESCRIPTION
[0029] The present invention is described in further detail below in conjunction with the accompanying drawings.
[0030] The present invention relates to a method for generating equipment test model code based on a large model, comprising the design of an equipment digital test requirement analysis module, a large model training code collection and processing module, an equipment test model code library module, and a large model pre-training and fine-tuning module. The method can quickly generate equipment test model code to a certain extent, reduce the time for manual code writing, improve development efficiency, and ensure the accuracy and reliability of the code.
[0031] The structural block diagram of the present invention is as follows: Figure 1 As shown, a missile trajectory model is taken as an example to demonstrate the equipment test model code generation method based on a large model. The specific implementation method is as follows:
[0032] Step (1) designs an equipment digital test requirement analysis module. This module extracts the specific requirements for equipment test model modeling code generation by building an equipment digital test identification system in combination with the requirement description. The specific implementation is as follows:
[0033] ① Through semantic analysis of natural language description documents or structured documents in XML or JSON format, combined with keywords and semantic patterns in the requirements document, key elements in the test, such as equipment type, performance indicators, opposing parties, test environment and other parameters, can be identified.
[0034] ② First, it is necessary to clarify the functional requirements and performance indicators of the missile trajectory model. By establishing a digital test and identification framework system for equipment, it is clear that the missile test target is a precision strike or penetration test, and the digital test scenario model is determined, including the deployment of both offensive and defensive sides, environmental models, control models, etc. The selection, parameters, thrust size, cruising range, etc. of the missile equipment are determined based on large-scale parametric digital tests, thereby determining the modeling requirements and functional objectives of the missile trajectory model.
[0035] ③ According to the application scenarios and system requirements of the missile, define key functional requirements, including initial velocity, ballistic trajectory, aerodynamic characteristics and flight time, and determine the target functions of code generation, such as ballistic calculation, flight parameter simulation and attitude control algorithm. In terms of performance indicators, focus on calculation accuracy, real-time performance, efficiency and model robustness to ensure that the generated code can remain stable under different conditions.
[0036] Step (2): Design a large model training code collection and processing module. This module prepares the required basic equipment test model code set according to the equipment characteristics and digital test requirements. When the data is insufficient to support high-quality code generation, data enhancement is performed. The specific implementation is as follows:
[0037] ① In order to achieve high-quality code generation, an equipment test model code dataset needs to be prepared. This dataset should include code samples of historical missile trajectory models, such as flight control algorithm and trajectory optimization algorithm code, missile six-degree-of-freedom dynamics model code, environmental model code, etc. At the same time, code samples manually written by domain experts are also crucial. These samples can provide flight parameter calculation logic and external disturbance modeling under specific missile models. In addition, relevant numerical algorithms and simulation codes can be obtained from open source code libraries.
[0038] ② When the data set is not large enough, the equipment test model code is generated by distilling a large code generation model with a larger number of parameters. In the specific implementation process, the generator generates new equipment control logic based on the existing code template, and the discriminator automatically evaluates the generated code. By introducing the equipment physical behavior simulation model, the functionality, robustness and safety of the code are automatically verified and scored. In addition, the code generation model can be used to generate new code with different ballistic characteristics or running in different environments. Through these methods, the generalization ability of the code generation model is improved to ensure that it can cope with different types of missiles and environmental changes.
[0039] Step (3): Design an equipment test model code library module. This module establishes an efficient equipment test model code library by modularizing and optimizing the historical code, which is convenient for dynamic combination in subsequent calls and generation of equipment codes. The specific implementation is as follows:
[0040] ①Classify and store the historically generated equipment test model codes, common code templates and solutions as structured data. Each code snippet should contain code content, code description, code label, code dependency information, and version control information. According to the functional requirements and performance indicators of the equipment, the code library should be organized in a modular way, covering modules such as trajectory calculation, attitude adjustment and flight control algorithm. Modular design helps the model to quickly call the required functions when generating code, thereby improving the efficiency of code generation and ensuring the quality of the generated code.
[0041] ② Conduct in-depth analysis of the dependencies of historical codes, use knowledge graph technology to store equipment code snippets and their associated metadata in a structured manner, perform static analysis of the dependencies of code snippets, identify the input, output, dependent library or dependent function of each code snippet, and extract relevant metadata from the code snippet, including variables, functions, classes, and dependent libraries, build associations between code snippets and metadata, store equipment test model codes and their metadata in a structured manner in a graph database, and determine the nodes and relationship edges of each code snippet;
[0042] ③ Build an efficient query mechanism, embed code snippets into a high-dimensional vector space, and use vector retrieval to query the code snippets that are most similar to the current requirements. Query all upstream code snippets that a certain code snippet depends on, and which downstream modules depend on it, to achieve efficient query and dynamic combination to support rapid reuse and optimized generation.
[0043] Step (4): Design a large model pre-training and fine-tuning module. This module performs secondary pre-training and fine-tuning on the base code large model and uses reinforcement learning to improve the code generation capability of the large model. The specific implementation is as follows:
[0044] ① Under the specific needs of the equipment field, the base code generation model is first adaptively adjusted to extract the topological structure and physical characteristics of the equipment test model, and secondary pre-training is performed based on these structures. The code generation model captures the relationship between the internal subsystems of the equipment and enhances the understanding of the complex equipment structure, so that the generated code can more accurately reflect the actual operation requirements of the equipment. When generating code, the code generation model is used to learn the code structure and logic of ballistic calculation from the basic data set to achieve automatic code generation. The generated code can meet the needs of different missile types and flexibly adjust the generation logic according to external influences and initial conditions. In this way, the automatically generated code will have high adaptability and can effectively cope with complex simulation tasks.
[0045] ② In order to make the large model better adapt to the generation requirements of missile trajectory code, it is also necessary to fine-tune the code generation large model that has been pre-trained twice for specific fields. The large model is retrained through a dedicated data set of the missile trajectory model so that it can learn the fine-grained requirements and complex functional logic in trajectory modeling, such as trajectory optimization, wind resistance calculation, and attitude adjustment strategies in complex environments. In this way, the code generation large model will gradually improve its ability to generate code, ensuring that the code it generates can meet the actual missile simulation requirements.
[0046] ③ Use reinforcement learning to decompose the complex equipment testing model code task into multiple short sequence generation tasks. By introducing the Markov decision process, a strategy for generating the next code segment is formulated for each generated code segment, and combined with the multi-task reinforcement learning strategy to gradually generate high-quality code. In the reinforcement learning process, a fine-grained reward mechanism is defined to ensure its logical rationality and functional consistency.
[0047] In summary, the present invention discloses a method for generating equipment test model code based on a large model, including the design of an equipment digital test requirement analysis module, the design of a large model training code and processing module, the design of an equipment test model code library module, and the design of a large model pre-training and fine-tuning module. It can quickly generate equipment test model code to a certain extent, reduce the time for manual code writing, improve development efficiency, and combine the code testing and evaluation module generated by the large model to ensure the accuracy and reliability of the code.
[0048] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating equipment test model code based on a large model, characterized in that: The method comprises: Step (1), designing an equipment digital test requirement analysis module, which is used to extract the digital test requirements for equipment test model modeling code generation by building an equipment digital test identification framework system in combination with the requirement description; Step (2), designing a large model training code collection and processing module, which is used to prepare the required basic equipment test model code set according to the equipment characteristics and the generated digital test requirements, and when the basic equipment test model code set is insufficient to support high-quality code generation, perform data enhancement to generate a high-quality equipment test model code data set; Step (3), designing an equipment test model code library module, which is used to perform structured storage on the high-quality code data set, construct a knowledge graph based on the structured data, and design a vectorized dynamic query function for dynamic combination when generating equipment test model code; Step (4): Design a large model pre-training and fine-tuning module, use the high-quality code set and vectorized dynamic query function to perform secondary pre-training and fine-tuning on the base code large model, use reinforcement learning to enhance the called equipment test model code, call the required equipment test model code based on the knowledge graph, and generate the final equipment test model code.
2. The method for generating equipment test model code based on a large model according to claim 1, characterized in that: The step (1) comprises: Step (1.1), accept the requirement specification document provided by the user, analyze the requirement information in the requirement specification document through the big model, combine the keywords and semantic patterns in the requirement information, and identify the key elements in the experiment; Step (1.2), design the test scenario based on the identified key elements in the test, generate parameters for each element in the test scenario, and define the interaction rules for the confrontation between the two parties; Step (1.3): construct a digital test and identification framework system for equipment to perform parametric test simulation and screen out the optimal modeling requirements.
3. The method for generating equipment test model code based on a large model according to claim 1, characterized in that: The step (2) comprises: Step (2.1), prepare a historical equipment test model code dataset, including real test equipment test model code, digital test equipment test model code, open source code base, and code samples manually written by domain experts, structure the historical equipment test model code dataset, annotate it according to function, performance, and modularity standards, and perform semantic transformation on the code; Step (2.2): When the historical equipment test model code data set is insufficient, an expanded equipment test model code is generated based on the large model. The expanded equipment test model code is automatically verified and scored in combination with the equipment physical behavior simulation model to screen out high-quality equipment test model codes that meet functional requirements, thus forming a high-quality equipment test model code data set.
4. The method for generating equipment test model code based on a large model according to claim 1, characterized in that: The step (3) comprises: Step (3.1), classify and store high-quality equipment test model codes, common code templates and solutions as structured data, divide code snippets into multiple functional modules, build a modular code library, and dynamically generate code for each module based on the functional requirements of the equipment; Step (3.2): statically analyze the dependencies of the code snippets, extract relevant metadata from the code snippets, build associations between the code snippets and the metadata, store the equipment test model code snippets and the associated metadata in a structured manner in a graph database, determine the nodes and relationship edges of each code snippet, and build a knowledge graph of the code snippets; Step (3.3), construct a query mechanism, embed the code snippet into a high-dimensional vector space, and dynamically combine the vector retrieval query to find the code snippet that is most similar to the current requirement, all the upstream code snippets that the most similar code snippet depends on, and which downstream code snippets depend on the most similar code snippet.
5. The method for generating equipment test model code based on a large model according to claim 1, characterized in that: The step (4) comprises: Step (4.1), adaptively adjusting the base code generation large model, extracting the topological structure and physical characteristics of the equipment test model, and performing secondary pre-training based on the topological structure and physical characteristics; Step (4.2), use the high-quality equipment test model code data set for fine-tuning, build a thinking chain prompt to guide the code generation model to perform step-by-step reasoning according to the steps of natural language requirements, complex task decomposition, equipment test model mathematical equation construction, and equipment test model code generation; Step (4.3): Decompose the complex equipment test model code generation task into multiple short sequence generation tasks, define the generated code fragments and the strategy for generating the next code fragment for each short sequence, call the required equipment test model code based on the knowledge graph, and combine the multi-task reinforcement learning strategy for code enhancement. During the reinforcement learning process, if the task is successfully decomposed and the corresponding mathematical equation is generated, a reward will be given. If the decomposition is wrong or not decomposed, a penalty will be given, ultimately achieving the enhancement of the equipment test model code generation capability.
Citation Information
Patent Citations
Software development management system
CN117971166A
Virtual test model verification method under weak communication small sample
CN117972378A
Code generation method and device, program and storage medium
CN118672593A
Software development verification method based on large model
CN118690375A
Method and system for dynamically generating executable source codes for applications
US20220188079A1
Cited By
Extensible structured text generation method and device in PLC field, equipment and medium
CN120085869A
Sewage treatment activated sludge model generation method based on large language model
CN121617484A
Unmanned driving code generation and visual development system based on knowledge base
CN121918812A
