Code one-key generation method and system for arrangement model
By decoupling and component arrangement of neural network models and training large models, the problems of high computing resources and low code generation accuracy in the existing technology are solved, efficient and accurate code generation is achieved, and it is suitable for edge-end applications.
Patent Information
- Application Number
- CN202510413196.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-04-03
AI Technical Summary
The existing code generation method based on large language models has high computing resources requirements, which is difficult to apply on the edge side, and the code generation accuracy is not high, making it prone to deviations.
By decoupling multiple neural network models, encapsulating them into different components, and simulating the orchestration and connection methods of components, building data sets, training large models, reducing computing resource requirements, and realizing one-click code generation.
It significantly reduces the time-consuming model calculation, improves the accuracy of code generation, is more efficient in code generation, and makes the generated code easier to apply and deploy on different edges and ends.
Smart Images

Figure CN119938032A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of code generation, and in particular to a one-click code generation method and system for an orchestration model. Background Art
[0002] CN118409741A discloses a code generation method based on a large language model, including the following steps: first, receiving the user input requirement document and the data model layer generated by the database field, and using the received data as the source text; forming prompt words based on the source text, the ChatGLM2 model obtains the function signature and outputs the text content; forming prompt phrases based on the source text, the WizardCoder model obtains the file path and code content, and outputs the text content; constructing folders and files based on the code path, writing the code content, and obtaining the conversion of the target programming language. This invention uses two large models, ChatGLM2 and WizardCoder. ChatGLM2 is used to understand user requirements and generate text, and WizardCoder generates code based on the text. Although the accuracy has been improved, it relies on two large models, which requires too much computing resources, making it difficult to apply on the edge side and difficult to deploy.
[0003] CN118210489A discloses a code generation method and system based on a large language model. The code generation method includes: generating a workflow from user requirements described in natural language using the large language model; converting the workflow into a flowchart and verifying it based on the flowchart; and generating executable code from the verified workflow using the large language model. This invention relies heavily on the accuracy of workflow generation. If deviations occur during the workflow generation process, the entire code generation result will be unreliable. Furthermore, this invention divides the process of using the large model into two parts: one part generates the workflow based on user requirements, and the other part generates code based on the workflow. This increases the instability of the large model generation results.
[0004] Therefore, there is an urgent need for a code generation method that requires low computing resources and has high code generation accuracy. Summary of the Invention
[0005] The present invention provides a one-click code generation method and system for an orchestration model to solve the technical problems mentioned in the background technology.
[0006] To achieve the above object, the technical solution of the present invention is achieved as follows: The present invention provides a one-click code generation method for an orchestration model, comprising the following steps: S1. Decouple multiple neural network models to obtain multiple single data processing logics, and encapsulate the multiple single data processing logics into different components; S2. Simulate different orchestration connection methods for all components, collect orchestration cases in multiple scenarios, generate text descriptions for each orchestration case and each component, and construct a dataset using multiple text descriptions. S3. Use the dataset to train the large model to obtain the trained large model, and deploy the trained large model to the device. S4. Use all components to orchestrate the required model, and then use the trained large model to generate code for the orchestrated required model with one click.
[0007] Furthermore, the components include at least data input / output, preprocessing, model selection, hyperparameter setting, deployment framework, deployment platform, and post-processing.
[0008] Furthermore, the plurality of components include components with the same component structure but inconsistent weight parameters.
[0009] Furthermore, the S2 specifically includes the following steps: S21. Simulate multiple different orchestration connection methods for all components and collect orchestration cases in multiple different scenarios. S22. Establish a mapping rule from function to text description for each component and each orchestration case; S23. Describe each component and each orchestration case in natural language, and standardize the sentence structure of all components and all orchestration cases; S24, based on the mapping rules and sentence structure of each component, a program is written to automatically generate a text description of each component, and then the dynamic parameters of each component are added to the text description of each component; S25. Based on the mapping rules and sentence structure of each arrangement, a program is written to automatically generate a text description of each arrangement, and then the dynamic parameters of all components in each arrangement are added to the text description of each arrangement; S26. Build a dataset using the text descriptions generated by each component and each orchestration.
[0010] Furthermore, the step S2 further includes the following steps: S27, add label information for each text description in the dataset; S28. Review the label information of each text description in the dataset to improve the accuracy of the samples in the dataset.
[0011] Furthermore, the tag information in S27 includes at least one or more of the task type, the used programming language, and the framework version.
[0012] Furthermore, the large model is a nine-grid 2B large model.
[0013] Furthermore, the S3 specifically includes the following steps: S31, dividing the data set into a training set and a validation set according to a preset ratio; S32. Set the loss function and use the training set to perform LoRA fine-tuning training on the large model. In each round of training, calculate the loss value based on the label information and the set loss function. Train for multiple rounds until the loss function converges or the number of training times reaches the set number. Then use the validation set for verification and select the set of weights with the highest accuracy as the weights of the large model to obtain the trained large model. S33. Deploy the trained large model to the device to achieve one-click code generation.
[0014] Furthermore, the S4 specifically includes the following steps: S41. Arrange the required model using all components, then use connecting lines to establish connections between previous and next components, and form a complete chain of thought based on the connections between previous and next components. S42, generating a text description of the complete thought chain by using the respective mapping rules and sentence structures of the components in the complete thought chain; S43, input the text description of the complete thought chain obtained in S42 into the trained large model for code generation, and obtain the code DM1 of the entire complete process; S44, isolating and splitting the complete thought chain obtained in S41 into multiple single thought chains according to components; then generating a text description of the single thought chain by using the respective mapping rules and sentence structures of each component in the single thought chain; S45. Input the text descriptions of the single thought chains into the trained large model one by one in the order of the single thought chains to obtain the corresponding codes; S46. Perform data preprocessing or data space alignment on the output of the previous single thought chain, convert it into a text description, and then add it to the input text of the next single thought chain to guide the large model to generate input code that matches the data type and size of the output of the previous single thought chain, ensuring that the interfaces between the previous and next single thought chains are completely consistent. S47, loop S46 multiple times until the codes output by each single thought chain are obtained, and the codes output by each single thought chain are merged to form the code DM2 that completes the processing flow; S48. Compare code DM1 with code DM2 to identify the portion of the code that has a difference that reaches a set difference, analyze and run verification on the portion that has a difference that reaches the set difference, and select and discard the portion of code DM1 that has a difference that reaches the set difference based on the verification result. After the selection is completed, code DM3 is obtained; S49. Perform a demonstration run on code DM3, display the input and output, and perform a final confirmation.
[0015] On the other hand, the present invention also provides a one-click code generation system for an orchestration model, including a computer device, which is programmed or configured to execute the above one-click code generation method.
[0016] Beneficial effects of the present invention: 1. The present invention discloses a one-click code generation method for an orchestration model. Compared with the prior art, the prior art mainly refers to CN118409741A, a code generation method based on a large language model. The present invention does not require high computing resources. At the same time, the present invention and the code of the required model obtained by the orchestration of the present invention are easy to apply and deploy on different edge sides, and have a wide range of applications. In addition, the present invention is mainly deployed on a model orchestration software platform for one-click code generation of an orchestration model.
[0017] 2. The one-click code generation method disclosed in the present invention not only improves the accuracy of code generation, but also significantly reduces the time consumption of model calculation, and the code generation efficiency is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 The figure is a flow chart of the one-key code generation method of the present invention. DETAILED DESCRIPTION
[0019] To facilitate understanding of the present invention, the present invention will be described more fully below with reference to the accompanying drawings. The drawings illustrate preferred embodiments of the present invention. However, the present invention may be implemented in many other forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and comprehensive understanding of the present disclosure.
[0020] Reference Figure 1 , the embodiment of the present application provides a one-click code generation method for an orchestration model, comprising the following steps: S1. Decouple multiple neural network models to obtain multiple single data processing logics, and encapsulate the multiple single data processing logics into different components; S2. Simulate different orchestration connection methods for all components, collect orchestration cases in multiple scenarios, generate text descriptions for each orchestration case and each component, and construct a dataset using multiple text descriptions. S3. Use the dataset to train the large model to obtain the trained large model, and deploy the trained large model to the device. S4. Use all components to orchestrate the required model, and then use the trained large model to generate code for the orchestrated required model with one click.
[0021] The present invention does not require high computing resources. At the same time, the present invention and the code of the required model obtained by the arrangement of the present invention are easy to apply and deploy on different edge sides, and have a wide range of applications. In addition, the present invention is mainly deployed on a model arrangement software platform, which is used to generate the code of the arrangement model with one click.
[0022] In some embodiments, the components include at least data input / output, preprocessing, model selection, hyperparameter setting, deployment framework, deployment platform, and post-processing.
[0023] In some embodiments, the plurality of components include components with the same component structure but inconsistent weight parameters.
[0024] In some embodiments, the step S2 specifically includes the following steps: S21. Simulate multiple different orchestration connection methods for all components and collect orchestration cases in multiple different scenarios. S22. Establish a mapping rule from function to text description for each component and each orchestration case; S23. Describe each component and each orchestration case in natural language, and standardize the sentence structure of all components and all orchestration cases; S24, based on the mapping rules and sentence structure of each component, a program is written to automatically generate a text description of each component, and then the dynamic parameters of each component are added to the text description of each component; S25. Based on the mapping rules and sentence structure of each arrangement, a program is written to automatically generate a text description of each arrangement, and then the dynamic parameters of all components in each arrangement are added to the text description of each arrangement; S26. Build a dataset using the text descriptions generated by each component and each orchestration.
[0025] In some embodiments, the step S2 further includes the following steps: S27, add label information for each text description in the dataset; S28. Review the label information of each text description in the dataset to improve the accuracy of the samples in the dataset.
[0026] In some embodiments, the tag information in S27 includes at least one or more of the task type, the used programming language, and the framework version.
[0027] In some embodiments, the large model is a nine-grid 2B large model. The present invention uses the nine-grid 2B large model for LoRA fine-tuning training. LoRA fine-tuning is an efficient fine-tuning method for large pre-trained models. It allows incremental task-specific knowledge to be learned by introducing low-rank matrices without changing the original model weights. This helps reduce the number of parameter updates, lowering computational cost and memory usage while maintaining good performance.
[0028] Before fine-tuning LoRA, first place the dataset file (.json) in the data folder under the project, and write the dataset file information to data / dataset_info.json. dataset_info.json is mainly used to record the file names of each dataset under data. file_name is the dataset file name, and file_sha1 file hash code can be left blank (the content is an empty string, that is, "file_sha1": "").
[0029] LoRA fine-tuning parameter configuration, taking single card training as an example, the following is a description of each parameter:
[0030] # Model Configuration
[0031] Model
[0032] - `model_name_or_path`: The path points to the storage location of the pre-trained model or dialogue model.
[0033] ## Training Method
[0034] - `stage`: training stage or mode, here set to `sft` (Supervised Fine-Tuning), which means fine-tuning.
[0035] - `do_train`: Whether to execute the training process, `true` means yes.
[0036] - `finetuning_type`: Fine-tuning type. Here we use `lora` (Low-Rank Adaptation), which is a lightweight fine-tuning method that only adjusts the weights of some layers.
[0037] - `lora_target`: specifies the specific model layer to which LoRA adaptation is applied. `q_proj` and `v_proj` usually correspond to the query and value projection layers of the attention mechanism in the Transformer model. It can also be all LoRA-adapted layers 'all'
[0038] Dataset Configuration
[0039] - `dataset`: a comma-separated list of datasets, e.g. `alpaca_en`, `alpaca_zh`, using the key names of the corresponding dataset dictionary in data / dataset_info.json.
[0040] - `template`: Template type, `9g` is used here, which is a data processing template for the model structure to be trained.
[0041] - `cutoff_len`: The maximum length of the input sequence. Input exceeding this length will be truncated.
[0042] - `max_samples`: The maximum number of samples, limiting the total number of samples loaded from the dataset.
[0043] - `val_size`: The ratio of the validation set to the total dataset, here it is 10%.
[0044] - `overwrite_cache`: If `true`, the cache of loaded data will be overwritten before each run.
[0045] - `preprocessing_num_workers`: The number of parallel worker processes used during data preprocessing to improve data loading efficiency.
[0046] Output Configuration
[0047] - `output_dir`: The directory where the model training output is saved, including logs, checkpoints, etc.
[0048] - `logging_steps`: The step interval for logging during training.
[0049] - `save_steps`: The number of steps between which model checkpoints are saved.
[0050] - `plot_loss`: Whether to draw and save the loss curve during training.
[0051] - `overwrite_output_dir`: If `true`, allows the training process to overwrite existing contents of the output directory.
[0052] ## Training Parameters
[0053] - `per_device_train_batch_size`: The training batch size per device.
[0054] - `gradient_accumulation_steps`: The number of steps for accumulating gradients, used to simulate larger batch training and reduce memory usage.
[0055] - `learning_rate`: Initial learning rate.
[0056] - `num_train_epochs`: total number of training epochs.
[0057] - `lr_scheduler_type`: learning rate scheduler type, here is the cosine annealing scheduler.
[0058] - `warmup_steps`: The number of steps in the learning rate warmup phase, which gradually increases to the initial learning rate.
[0059] - `fp16`: Whether to use mixed precision training (half-precision floating point numbers), which can speed up training and reduce memory consumption.
[0060] Evaluation Settings
[0061] - `per_device_eval_batch_size`: The batch size per device during evaluation.
[0062] - `evaluation_strategy`: evaluation strategy, `steps` means evaluation according to the specified number of steps.
[0063] - `eval_steps`: The number of steps to perform evaluation at.
[0064] During the LoRA fine-tuning process, the model will automatically be evaluated on the validation set and the validation set loss (i.e., loss function) will be calculated. The plot_loss parameter can specify the training loss curve.
[0065] In some embodiments, S3 specifically includes the following steps: S31, dividing the data set into a training set and a validation set according to a preset ratio; S32. Set the loss function and use the training set to perform LoRA fine-tuning training on the large model. In each round of training, calculate the loss value based on the label information and the set loss function. Train for multiple rounds until the loss function converges or the number of training times reaches the set number. Then use the validation set for verification and select the set of weights with the highest accuracy as the weights of the large model to obtain the trained large model. S33. Deploy the trained large model to the device to achieve one-click code generation.
[0066] In some embodiments, the S4 specifically includes the following steps: S41. Arrange the required model using all components, then use connecting lines to establish connections between previous and next components, and form a complete chain of thought based on the connections between previous and next components. S42, generating a text description of the complete thought chain by using the respective mapping rules and sentence structures of the components in the complete thought chain; S43, input the text description of the complete thought chain obtained in S42 into the trained large model for code generation, and obtain the code DM1 of the entire complete process; S44, isolating and splitting the complete thought chain obtained in S41 into multiple single thought chains according to components; then generating a text description of the single thought chain by using the respective mapping rules and sentence structures of each component in the single thought chain; S45. Input the text descriptions of the single thought chains into the trained large model one by one in the order of the single thought chains to obtain the corresponding codes; S46. Perform data preprocessing or data space alignment on the output of the previous single thought chain, convert it into a text description, and then add it to the input text of the next single thought chain to guide the large model to generate input code that matches the data type and size of the output of the previous single thought chain, ensuring that the interfaces between the previous and next single thought chains are completely consistent. S47, loop S46 multiple times until the codes output by each single thought chain are obtained, and the codes output by each single thought chain are merged to form the code DM2 that completes the processing flow; S48. Compare code DM1 with code DM2 to identify the portion of the code that has a difference that reaches a set difference, analyze and run verification on the portion that has a difference that reaches the set difference, and select and discard the portion of code DM1 that has a difference that reaches the set difference based on the verification result. After the selection is completed, code DM3 is obtained; S49. Perform a demonstration run on code DM3, display the input and output, and perform a final confirmation.
[0067] The one-click code generation method disclosed in the present invention not only improves the accuracy of code generation, but also significantly reduces the time consumption of model calculation, and the code generation efficiency is higher.
[0068] On the other hand, the present invention also provides a one-click code generation system for an orchestration model, including a computer device, which is programmed or configured to execute the above one-click code generation method.
[0069] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. In addition, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the ability of ordinary technicians in this field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the protection scope required by the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A one-click code generation method for an orchestration model, characterized in that: The steps include: S1. Decouple multiple neural network models to obtain multiple single data processing logics, and encapsulate the multiple single data processing logics into different components; S2. Simulate different orchestration connection modes for all components, collect orchestration cases in multiple different scenarios, generate text descriptions for each orchestration case and each component, and construct a data set using multiple text descriptions; S3. Use the data set to train the large model to obtain the trained large model, and deploy the trained large model to the device end; S4. Use all components to orchestrate the required model, and then use the trained large model to generate code for the orchestrated required model with one click.
2. The one-click code generation method for an orchestration model according to claim 1, characterized in that: The components include at least data input / output, preprocessing, model selection, hyperparameter setting, deployment framework, deployment platform, and post-processing.
3. The one-click code generation method of the arrangement model according to claim 1, characterized in that: The multiple components include components with the same component structure but inconsistent weight parameters.
4. The one-click code generation method for an orchestration model according to claim 1, characterized in that: The S2 specifically includes the following steps: S21. Simulate multiple times different orchestration connection modes for all components and collect orchestration cases in multiple different scenarios. S22, establishing a mapping rule from function to text description for each component and each orchestration case; S23. Describe each component and each orchestration case in natural language, and unify the sentence structure of all components and all orchestration cases; S24, according to the mapping rules and sentence structure of each component, and using a program to automatically generate a text description of each component, and then adding the dynamic parameters in each component to the text description of each component; S25, according to the mapping rules and sentence structure of each arrangement, and using a program to automatically generate a text description of each arrangement, and then adding the dynamic parameters of all components in each arrangement to the text description of each arrangement; S26. Build a dataset using the text descriptions generated by each component and each orchestration.
5. The one-click code generation method for an orchestration model according to claim 4, characterized in that: The S2 further comprises the following steps: S27, adding label information to each text description in the data set; S28. Review the label information of each text description in the dataset to improve the accuracy of the samples in the dataset.
6. The one-key code generation method of the arrangement model according to claim 5, characterized in that: The tag information in S27 at least includes one or more of the task type, the used programming language, and the framework version.
7. The one-click code generation method for an orchestration model according to claim 5, characterized in that: The large model is a nine-grid 2B large model.
8. The one-click code generation method for an orchestration model according to claim 5, characterized in that: The S3 specifically includes the following steps: S31, dividing the data set into a training set and a validation set according to a preset ratio; S32, set the loss function, use the training set to perform LoRA fine-tuning training on the large model, and in each round of training, calculate the loss value according to the label information and the set loss function, train multiple rounds until the loss function converges, or the number of training times reaches the set number, and then use the validation set for verification, select the set of weights with the highest accuracy as the weights of the large model, and obtain the trained large model; S33. Deploy the trained large model to the device to achieve one-click code generation.
9. The one-key code generation method of the arrangement model according to claim 4, characterized in that: The S4 specifically includes the following steps: S41. Arrange the required model using all components, then use connecting lines to establish connections between the previous and next components, and form a complete thinking chain based on the connections between the previous and next components; S42, generating a text description of the complete thought chain by using respective mapping rules and sentence structures for each component in the complete thought chain; S43, input the text description of the complete thought chain obtained in S42 into the trained large model for code generation, and obtain the code DM1 of the entire complete process; S44, isolating and splitting the complete thought chain obtained in S41 according to components into multiple single thought chains; Then, each component in a single thought chain is used to generate a text description of the single thought chain through its own mapping rules and sentence structure; S45, according to the sequence of the single thought chain, input the text description of the single thought chain into the trained large model one by one to obtain the corresponding code; S46, perform data preprocessing or data space alignment processing on the output result of the previous single thinking chain, convert it into a text description and add it to the input text of the next single thinking chain to guide the large model to generate input code that matches the data type and scale of the output result of the previous single thinking chain, ensuring that the interface between the previous and next single thinking chains is completely consistent; S47, loop S46 for multiple times until the codes output by each single thought chain are obtained, and the codes output by each single thought chain are merged to form the code DM2 that completes the processing flow; S48, comparing the code DM1 with the code DM2, identifying the part of the code whose difference reaches the set difference, analyzing and running verification on the part that reaches the set difference, selecting and discarding the part of the code DM1 that reaches the set difference according to the verification result, and obtaining the code DM3 after the selection and discarding; S49. Perform a demonstration run on code DM3, display the input and output, and make a final confirmation.
10. A one-click code generation system for an arrangement model, comprising a computer device, characterized in that: The computer device is programmed or configured to execute the one-key code generation method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Automatic process generation method and device, equipment and storage medium
CN116719911A
Real-time warehouse counting assembly line intelligent arrangement method, device and equipment, storage medium and program product
CN119311751A
Comprehensive management process design system and method based on AI code interpretation
CN119376711A
Intelligent model arrangement method and device, equipment and storage medium
CN119416862A
Cloud service-based code generation model training method and code generation method
WO2024169211A1