A method for generating equipment test model code based on large models
By designing equipment digital test requirements analysis modules, large model training code collection and processing modules, equipment test model code library modules, large model pre-training and fine-tuning modules, the problems of insufficient data and code quality optimization in equipment test model code generation are solved, and efficient and accurate code generation is achieved.
Patent Information
- Application Number
- CN202411539775.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2044-10-31
AI Technical Summary
The existing technology has problems of insufficient data and optimization of code quality in the code generation process of equipment testing model, which limits the widespread application of this technology.
Equipment digital test requirements analysis module, large model training code collection and processing module, equipment testing model code library module, large model pre-training and fine-tuning module were designed. Through the collaborative work of these modules, high-quality equipment testing model codes are quickly generated.
It significantly improves the speed and accuracy of code generation, reduces the time for manual code writing, ensures the accuracy and reliability of generated code, and improves the adaptability and universality of code.
Smart Images

Figure CN119248238B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of electronic engineering and computer science, and particularly relates to a method for generating code of an equipment test model based on a large model. Background Art
[0002] With the continuous improvement of the complexity of equipment systems, traditional manual code writing and maintenance have been difficult to meet the needs of modern equipment development. Especially for complex equipment test models, manual coding is not only time-consuming and laborious, but also prone to introducing human errors, affecting the quality and stability of the code. In order to improve the efficiency and reliability of code generation, in recent years, code generation technologies driven by large models have gradually received attention. The 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 a large amount of code data. However, in the prior art, problems such as insufficient data and code quality optimization still exist in the process of generating equipment test model code, which limits the wide application of this technology. Summary of the Invention
[0003] To solve the above technical problems, the present invention provides a method for generating code of an equipment test model 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, which can quickly generate code of the equipment test model to a certain extent, reduce the time for manual code writing, improve the 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 code of an equipment test model based on a large model, comprising:
[0006] Step (1), designing an equipment digital test requirement analysis module for extracting digital test requirements for generating modeling code of the equipment test model by constructing an equipment digital test identification framework system in combination with requirement specifications;
[0007] Step (2), designing a large model training code collection and processing module for preparing a required basic equipment test model code set according to equipment characteristics and the generated digital test requirements, and performing data enhancement in the case where the basic equipment test model code set is insufficient to support high-quality code generation to generate a high-quality equipment test model code data set;
[0008] Step (3), designing an equipment test model code library module for structurally storing the high-quality code data set, constructing a knowledge graph based on the structured data, and designing a vectorized dynamic query function for dynamic combination when generating code of the equipment test model;
[0009] Step (4), design a large model pre-training and fine-tuning module, and 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, and use reinforcement learning to enhance the called equipment test model code to generate the final equipment test model code.
[0010] Further, the said 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 large model, and combine the keywords and semantic patterns in the requirement information to identify the key elements in the experiment;
[0012] Step (1.2), according to the identified key elements in the experiment, design the experiment scenario, generate parameters for each element in the experiment scenario, and define the interaction rules for the confrontation between the two sides, such as the victory and defeat judgment criteria, time process, force loss model, etc. under the combat environment;
[0013] Step (1.3), construct an equipment digital test and appraisal framework system for parametric test simulation, and screen out the optimal modeling requirements.
[0014] Further, the said step (2) includes:
[0015] Step (2.1), prepare the historical equipment test model code data set, including the real test equipment test model code, digital test equipment test model code, open source code library, and code samples manually written by domain experts. Perform structured processing on the historical equipment test model code data set, annotate it according to the function, performance, and modular standards, and at the same time perform semantic transformation on the code to expand the diversity of the data set and generate codes with diversity but still maintaining semantic consistency;
[0016] Step (2.2), when the scale of the historical equipment test model code data set is insufficient, generate augmented equipment test model code based on the large model. The augmented equipment test model code is combined with the equipment physical behavior simulation model for automated verification and scoring, and high-quality equipment test model code that meets the functional requirements is screened out to form a high-quality equipment test model code data set.
[0017] Further, the said step (3) includes:
[0018] Step (3.1), classify and store the high-quality equipment test model code, common code templates, and solutions as structured data, divide the code fragments into multiple functional modules, construct a modular code library, and the call of each module dynamically generates code according to the functional requirements of the equipment;
[0019] Step (3.2): Perform static analysis on the dependency relationships of code snippets, extract relevant metadata from the code snippets, construct the association between the code snippets and the metadata, store the equipment test model code snippets and the associated metadata in a graph database in a structured manner, determine the nodes and relationship edges of each code snippet, and construct a knowledge graph of the code snippets;
[0020] Step (3.3): Construct a query mechanism, embed the code snippets into a high-dimensional vector space, and dynamically combine the vector retrieval query with the code snippets most similar to the current requirement, all upstream code snippets on which the most similar code snippets depend, and which downstream code snippets depend on the most similar code snippets.
[0021] Furthermore, the said step (4) includes:
[0022] Step (4.1): Perform adaptive adjustment on the large model for generating the base code, extract the topological structure and physical characteristics of the equipment test model, and perform secondary pre-training based on the topological structure and physical characteristics;
[0023] Step (4.2): Use a high-quality equipment test model code dataset for fine-tuning, construct a chain of thought prompt to guide the large model for generating code to perform step-by-step reasoning according to the steps of natural language requirements, complex task decomposition, construction of the equipment test model mathematical equation, and generation of the equipment test model code;
[0024] Step (4.3): Decompose the complex equipment test model code generation task into multiple short sequence generation tasks, define the generated code snippets and the strategy for generating the next code segment for each short sequence, call the required equipment test model code based on the knowledge graph, and combine a 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 is given; if the decomposition is incorrect or not decomposed, a penalty is given, and finally, the ability to generate the equipment test model code is enhanced.
[0025] The beneficial effects of the present invention are as follows:
[0026] (1) Through the pre-training and fine-tuning technologies of the large model, the present invention can automatically generate high-quality code according to the equipment digital test requirement analysis module, reduce manual participation, and avoid errors in manual 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 generality.
[0027] (2) By constructing a knowledge graph of equipment test model code, the present invention can effectively store the equipment test model code, facilitating subsequent tasks to search for the equipment test model code in the knowledge graph, ensuring the execution efficiency and stability of the code under complex working conditions, thereby realizing the efficient generation and reliable application of the equipment test model code. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a principle block diagram of a method for generating equipment test model code based on a large model of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0029] The following further describes the present invention in detail with reference to the drawings.
[0030] The present invention relates to 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 collection and processing module design of large model training code, the equipment test model code library module design, and the large model pre-training and fine-tuning module design. It can generate equipment test model code quickly 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 Figure 1 shown. Taking the missile trajectory model as an example, a method for generating equipment test model code based on a large model is demonstrated. The specific implementation is as follows:
[0032] Step (1): Design an equipment digital test requirement analysis module. This module extracts the specific requirements for generating the modeling code of the equipment test model by constructing an equipment digital test and evaluation system in combination with the requirement description. The specific implementation is as follows:
[0033] ① Through semantic parsing of natural language description documents or structured documents in XML or JSON format, combined with keywords and semantic patterns in the requirement documents, key elements in the test are identified, such as equipment type, performance indicators, opposing parties, test environment, and other parameters.
[0034] ② First, the functional requirements and performance indicators of the missile trajectory model need to be clarified. By establishing an equipment digital test and evaluation framework system, the missile test objectives are clarified as precision strike or penetration test, and the digital test scenario model is determined, including the deployment of both attacking and defending parties, environment model, control model, etc. Based on large-scale parametric digital tests, the selection, parameters, thrust magnitude, cruising mileage, etc. of the missile equipment are determined, and thus the modeling requirements and functional objectives of the missile trajectory model can be determined.
[0035] ③According to the application scenarios and system requirements of the missile, define the key functional requirements, including initial velocity, ballistic trajectory, aerodynamic characteristics, flight time, etc. At the same time, 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 the robustness of the model 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 augmentation is carried out. The specific implementation is as follows:
[0037] ①To achieve high-quality code generation, a data set of equipment test model codes needs to be prepared. This data set should include code samples of historical missile ballistic models, such as flight control algorithm and trajectory optimization algorithm codes, missile six-degree-of-freedom dynamics model codes, environmental model codes, etc. At the same time, code samples handwritten by domain experts are also crucial. These samples can provide the calculation logic of flight parameters and external disturbance modeling under a specific missile model. In addition, relevant numerical algorithms and simulation codes can be obtained from open-source code libraries.
[0038] ②When the scale of the data set is insufficient, generate equipment test model codes by distilling a code generation large model with a larger number of parameters. In the specific implementation process, the generator generates new equipment control logic according to the existing code templates, while the discriminator automatically evaluates the generated code. By introducing an 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 codes with different ballistic characteristics or operating 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 modularly disassembling and optimizing historical codes, which is convenient for subsequent calls and dynamic combinations when generating 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 segment should include code content, code description, code tags, code dependency information, and version control information. According to the functional requirements and performance indicators of the equipment, this code library should be organized in a modular manner, covering modules such as trajectory calculation, attitude adjustment, and flight control algorithms. The modular design helps the model to quickly call the required functions when generating codes, thereby improving the code generation efficiency and ensuring the quality of the generated codes.
[0041] ②Conduct a deep analysis of the dependencies on historical code. Use knowledge graph technology to structurally store equipment code snippets and their associated metadata, perform static analysis on the dependencies of code snippets, identify the inputs, outputs, dependent libraries, or dependent functions of each code snippet, and extract relevant metadata from the code snippets, including variables, functions, classes, and dependent libraries. Build the association between code snippets and metadata, structurally store the equipment test model code and its metadata 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 query for the code snippets most similar to the current requirements through vector retrieval. Query all upstream code snippets on which a certain code snippet depends, 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 ability of the large model. The specific implementation is as follows:
[0044] ①Under the specific requirements of the equipment field, first perform adaptive adjustment on the base code generation large model, extract the topological structure and physical characteristics of the equipment test model, and perform secondary pre-training based on these structures. The code generation large model enhances the understanding of complex equipment structures by capturing the relationships between internal subsystems of the equipment, so that the generated code can more accurately reflect the actual operation requirements of the equipment. When generating code, use the code generation large model to learn the code structure and logic of ballistic calculation from the basic dataset to achieve automatic code generation. The generated code can meet the requirements 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 handle complex simulation tasks.
[0045] ②To make the large model better adapt to the code generation requirements of missile trajectories, it is also necessary to perform domain-specific fine-tuning on the code generation large model after secondary pre-training. Retrain the large model with a dedicated dataset of the missile trajectory model so that it can learn the fine-grained requirements and complex functional logics in ballistic 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 code generation ability to ensure that the generated code can meet the actual missile simulation requirements.
[0046] ③ Use reinforcement learning to decompose the complex equipment test model code task into multiple short sequence generation tasks. By introducing the Markov decision process, formulate a strategy for generating the next code segment for each generated code snippet, and gradually generate high-quality code in combination with the multi-task reinforcement learning strategy. During the reinforcement learning process, define a fine-grained reward mechanism 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 generate equipment test model code quickly to a certain extent, reduce the time of manual code writing, improve the development efficiency, and ensure the accuracy and reliability of the code in combination with the code test and evaluation module generated by the large model.
[0048] The specific embodiments described above have further detailed the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only the specific embodiments of the present invention and is not used to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope 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 digital test requirements for equipment test model 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 structure the storage of the high-quality equipment test model code data set, build a knowledge graph based on the structured data, and design a vectorized dynamic query function for dynamic combination when generating equipment test model code; including: Step (3.1), classifying and storing high-quality equipment test model code data sets, common code templates and solutions as structured data, wherein the structured data includes multiple code snippets, and building a modular code library according to the functional requirements and performance indicators of the equipment; Step (3.2), statically analyzing the dependencies of the code snippets, extracting relevant metadata from the code snippets, building associations between the code snippets and the metadata, storing the code snippets and the associated metadata in a structured manner in a graph database, determining the nodes and relationship edges of each code snippet, and building a knowledge graph of the code snippets; Step (3.3), construct a query mechanism, embed the code snippet into a high-dimensional vector space, use the vector to retrieve the code snippet that is most similar to the current requirement, query all upstream code snippets that the most similar code snippet depends on, and which downstream code snippets depend on the most similar code snippet, to achieve efficient query and dynamic combination, and generate equipment test model code; Step (4): design a large model pre-training and fine-tuning module, use the high-quality equipment test model code data set and the vectorized dynamic query function to pre-train and fine-tune the base code generation large model, use reinforcement learning to enhance the code generated by the base code generation large model, 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 (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 pre-training based on the topological structure and physical characteristics; Step (4.2), using a high-quality equipment test model code data set to fine-tune the base code generation model, and construct a thinking chain prompt to guide the base 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) decomposes the complex equipment test model code generation task into multiple short sequence generation tasks, defines the generated code fragment and the strategy for generating the next code fragment for each short sequence, combines the multi-task reinforcement learning strategy for code enhancement, and generates the final equipment test model code.
Citation Information
Patent Citations
Software development management system
CN117971166A
Virtual test model verification method under weak communication small sample
CN117972378A