An artificial intelligence-based code generation method and system
Through the artificial intelligence model based on convolutional neural network, intelligently parsing and automatically generating subsequent functions frameworks in code files, the problem of not being able to automatically generate subsequent functions in the existing technology is solved, and a higher automation and intelligence of code generation is achieved.
Patent Information
- Application Number
- CN202510326400.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-03-19
AI Technical Summary
The existing technology cannot automatically generate subsequent functions that are not manually typed based on the overall information of the code file and the existing function data, resulting in programmers still needing to manually enter the function framework and content, which cannot effectively improve the automation and intelligence level of code generation.
Using an artificial intelligence model based on convolutional neural network, we intelligently parses and automatically generates the framework for the next written function by obtaining the execution task number, pre-order and subsequent task number of the current executable code file, and other basic information such as the function association information of the latest written function, thereby reducing manual input.
This realizes a framework without manually entering the next function. Programmers only need to confirm and fill in the content, and gradually complete the framework generation and content filling of each subsequent function, thereby greatly improving the automation and intelligence level of code generation and liberating the tedious work of programmers.
Smart Images

Figure CN119847533B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic digital data processing, and particularly to a code generation method and system based on artificial intelligence. Background Art
[0002] Code generation technology is an important technology in the cross - field of artificial intelligence and software engineering. It uses machine learning, natural language processing, and other AI algorithms to automatically write or assist in writing computer program code. This technology aims to improve programming efficiency, reduce error rates, and help non - professional developers quickly implement functions. The following is an overview of code generation technology and its typical application scenarios. Code generation technology usually relies on deep learning models, such as recurrent neural networks (RNNs), long short - term memory networks (LSTMs), Transformers, etc. These models are trained on large - scale code libraries to learn the structure, patterns, and logic of programming languages. By receiving natural language descriptions, pseudocode, existing code snippets, or high - level programming instructions as inputs, the models can output corresponding code snippets or complete programs.
[0003] Exemplarily, Chinese Patent Publication No. CN113361704A proposes a method and device for neural network code generation. The method includes: receiving information about hardware configured to perform neural network operations of a neural network, using a processor to generate a target mapping model that maps neural network operations to processing elements available for performing neural network operations based on the information and the structure of the neural network, and generating code for configuring the hardware to perform neural network operations based on the target mapping model.
[0004] Exemplarily, Chinese Patent Publication No. CN113849162A proposes a code generation method that combines model - driven and deep neural networks. The method includes the following steps: after modeling target requirements using an activity diagram, automatically generating logical structure code; using a trained deep neural network model to complete the generation of specific function code from natural language requirement descriptions. The present invention relies on the respective advantages of the two code generations to make up for each other's deficiencies, that is, using model - driven to solve the problems of long - distance dependencies and relatively small code granularity in natural - language - based code generation; and using natural - language - based generation to solve the problem of insufficient code detail information in model - driven code generation, ensuring the correctness of logic and long - structure as well as to a certain extent ensuring the correctness of code details for complex - function code.
[0005] It can be seen that the above-mentioned existing technologies only involve the automatic generation process from other languages to code, and cannot automatically generate subsequent functions that have not been manually typed in based on the overall information of the code file and the existing function data. As a result, after a programmer finishes writing a new function, they still need to manually type in the framework of the next function and then fill in the content, which cannot liberate the programmer from the cumbersome code typing work and cannot further improve the automation and intelligence levels of code generation. Summary of the Invention
[0006] To solve the technical problems in related fields, the present invention provides an artificial intelligence-based code generation method and system. By using an artificial intelligence model to automatically generate subsequent functions that have not been manually typed in based on the overall information of the code file and the existing function data, after a programmer finishes writing a new function, they do not need to manually type in the framework of the next function. Instead, the framework of the next function is automatically generated, and the programmer can directly fill in the content after confirmation. In this way, the framework generation and content filling of each subsequent function are gradually completed, thereby liberating the programmer from the cumbersome code typing work and further improving the automation and intelligence levels of code generation.
[0007] According to the first aspect of the present invention, an artificial intelligence-based code generation method is provided. The method includes:
[0008] Obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0009] Obtain the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file as the output of various function association information of the latest written function of the current executable code file;
[0010] Perform multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and output the convolutional neural network after performing multiple training actions as the convolutional neural network model. The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file;
[0011] Use the convolutional neural network model to intelligently analyze the function name of the next written function of the latest written function of the current executable code file based on the various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0012] Automatically generate the function framework corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file.
[0013] According to a second aspect of the present invention, there is provided an artificial intelligence-based code generation system, the system comprising:
[0014] A content capture device, configured to obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0015] A function parsing device, configured to obtain the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file as the function association information items of the latest written function of the current executable code file for output;
[0016] A successive training device, configured to perform multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing the multiple training actions, and output the convolutional neural network after performing the multiple training actions as a convolutional neural network model, wherein the number of times of the training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file;
[0017] An intelligent parsing device, respectively connected to the content capture device, the function parsing device, and the successive training device, configured to use the convolutional neural network model to intelligently parse the function name of the next written function of the latest written function of the current executable code file according to the function association information items of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0018] A framework generation device, connected to the intelligent parsing device, configured to automatically generate the function framework corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file.
[0019] Thus, the present invention has at least the following four key inventive concepts:
[0020] Inventive Concept A: Introduce sufficient and comprehensive multiple basic information for the intelligent parsing of the next writing function of the latest written function. The multiple basic information includes various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file. Among them, the various function association information of the latest written function of the current executable code file is the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file;
[0021] Inventive Concept B: Introduce an artificial intelligence model with a customized structure for the intelligent parsing of the next writing function of the latest written function. The artificial intelligence model is a convolutional neural network model, and the convolutional neural network model is a convolutional neural network after performing multiple training actions. Particularly importantly, the number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, so as to customize artificial intelligence models with different structures for different current executable code files;
[0022] Inventive Concept C: Use a convolutional neural network model to intelligently parse the function name of the next writing function of the latest written function of the current executable code file according to the various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file, and automatically generate the function framework corresponding to the intelligently parsed function name below the latest written function of the current executable code file. Thus, after a programmer finishes writing a function newly, there is no need to manually type in the framework of the next function, and the framework of the next function can be automatically generated. The programmer only needs to directly fill in the content after confirmation, and thus gradually complete the framework generation and content filling of each subsequent function, so as to liberate the programmer from the cumbersome code-typing work and further improve the automation level and intelligence level of code generation;
[0023] Inventive Concept D: In each training operation performed on a convolutional neural network, the function name of the function below a certain writing function that has been determined to be a certain executable code file in the past is used as the single output content of the convolutional neural network. The various function association information of the certain writing function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file are used as the multiple input contents of the convolutional neural network to complete the current training operation of the convolutional neural network, thereby ensuring the training effect of each training operation of the convolutional neural network. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The embodiments of the present invention will be described below with reference to the accompanying drawings, where:
[0025] Figure 1 FIG. is a technical flow chart of a code generation method and system based on artificial intelligence according to the present invention.
[0026] Figure 2 FIG. is a step flow chart of a code generation method based on artificial intelligence shown in Embodiment 1 of the present invention.
[0027] Figure 3 FIG. is a step flow chart of a code generation method based on artificial intelligence shown in Embodiment 2 of the present invention.
[0028] Figure 4 FIG. is a step flow chart of a code generation method based on artificial intelligence shown in Embodiment 3 of the present invention.
[0029] Figure 5 FIG. is an internal structure diagram of a code generation system based on artificial intelligence shown in Embodiment 4 of the present invention.
[0030] Figure 6 FIG. is an internal structure diagram of a code generation system based on artificial intelligence shown in Embodiment 5 of the present invention.
[0031] Figure 7 FIG. is an internal structure diagram of a code generation system based on artificial intelligence shown in Embodiment 6 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0032] As Figure 1 shown, a technical flow chart of a code generation method and system based on artificial intelligence shown in the present invention is given.
[0033] As Figure 1 shown, the specific technical process of the present invention is as follows:
[0034] Technical Process 1: Introduce sufficient and comprehensive multiple basic information for the intelligent analysis of the next function to be written for the latest written function. The multiple basic information includes various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file.
[0035] Specifically, the various function association information of the latest written function of the current executable code file is the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file.
[0036] The introduction of the above sufficient and comprehensive multiple basic information ensures the stability and effectiveness of the intelligent analysis results.
[0037] Inventive Concept B: Introduce an artificial intelligence model with a customized structure for the intelligent analysis of the next function to be written for the latest written function.
[0038] Specifically, the customized structure of the artificial intelligence model is mainly manifested in the following aspects:
[0039] First: The artificial intelligence model is a convolutional neural network model, and the convolutional neural network model is a convolutional neural network after performing multiple training actions.
[0040] Second: The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, so as to customize artificial intelligence models with different structures for different current executable code files.
[0041] Third: In each training action performed on the convolutional neural network, use the function name of the function below a certain written function of a certain executable code file that has been determined in the past as the single output content of the convolutional neural network, and use the various function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file as the multiple input contents of the convolutional neural network to complete the current training action of the convolutional neural network, thus ensuring the training effect of each training action of the convolutional neural network.
[0042] The customized design of all aspects of the above artificial intelligence model further ensures the stability and effectiveness of the intelligent analysis results.
[0043] Technical Process 3: Based on the sufficient and comprehensive multiple basic information introduced in Technical Process 1, the convolutional neural network model with a customized structure designed in Technical Process 2 intelligently analyzes the function name of the next writing function of the latest writing function in the current executable code file;
[0044] Technical Process 4: Automatically generate the function framework corresponding to the function name obtained by intelligent analysis below the latest writing function in the current executable code file;
[0045] Technical Process 5: The programmer confirms whether the function framework automatically generated below the latest writing function in the current executable code file is a function framework that meets the design requirements and helps to complete the execution task corresponding to the current executable code file. After confirmation, fill in the content within the function framework to complete the code input of the function below the latest writing function;
[0046] Next, the automatic generation of the function framework of the function below the function below the latest writing function completed by the redesigned artificial intelligence model can be adopted, and such operations are performed successively until the complete input of the overall code of the current executable code file is completed.
[0047] In this way, after the programmer newly writes a function, there is no need to manually enter the framework of the next function. The framework of the next function is automatically generated, and the programmer can directly fill in the content after confirmation. In this way, the framework generation and content filling of each subsequent function are gradually completed, thus liberating the programmer from the cumbersome code input work and further improving the automation level and intelligence level of code generation.
[0048] The key points of the present invention are: the customized structure design of the artificial intelligence model for intelligent analysis of the next writing function of the latest writing function, the introduction of sufficient and comprehensive multiple basic information, the targeted design of each training action performed by the convolutional neural network, and the semi-automatic input mode of the overall code of the executable code file for successive automatic generation, manual confirmation, and content filling of subsequent function frameworks.
[0049] Next, a code generation method and system based on artificial intelligence of the present invention will be specifically described by way of examples.
[0050] Example 1
[0051] Figure 2 It is a step flow chart of a code generation method based on artificial intelligence shown in Example 1 according to the present invention.
[0052] As Figure 2 shown, the code generation method based on artificial intelligence includes the following steps:
[0053] Step 21: Obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraphs of the current executable code file;
[0054] Exemplarily, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraphs of the current executable code file includes: Multiple content capture components can be used to respectively obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraphs of the current executable code file;
[0055] Step 22: Obtain the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file, and output them as the function association information of the latest written function of the current executable code file;
[0056] Exemplarily, obtaining the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file, and outputting them as the function association information of the latest written function of the current executable code file includes: The function name of the latest written function of the current executable code file can be represented by ASCII codes in binary numerical representation form;
[0057] Specifically, representing the function name of the latest written function of the current executable code file by ASCII codes in binary numerical representation form includes: The ASCII codes in binary numerical representation form are the ASCII codes of the string corresponding to the function name of the latest written function of the current executable code file;
[0058] Step 23: Perform multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and output the convolutional neural network after performing multiple training actions as a convolutional neural network model. The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file;
[0059] Exemplarily, the positive correlation between the number of training actions of the convolutional neural network and the number of variables in the latest written function of the current executable code file includes: when the number of variables in the latest written function of the current executable code file is 1, the number of training actions of the convolutional neural network is 100; when the number of variables in the latest written function of the current executable code file is 2, the number of training actions of the convolutional neural network is 150; when the number of variables in the latest written function of the current executable code file is 3, the number of training actions of the convolutional neural network is 200, and so on;
[0060] Step 24: Use the convolutional neural network model to intelligently analyze the function name of the next written function of the latest written function of the current executable code file according to various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0061] Correspondingly, the function name of the next written function of the latest written function of the current executable code file obtained by intelligent analysis is also the ASCII value of the string corresponding to the function name of the next written function of the latest written function of the current executable code file;
[0062] Step 25: Automatically generate the function framework corresponding to the function name obtained by intelligent analysis below the latest written function of the current executable code file;
[0063] Among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: the binary data stream corresponding to the written code segment of the current executable code file is the binary data stream obtained after compiling a part of the code file from the starting position to the end position of the latest written function of the current executable code file;
[0064] And among them, performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and outputting the convolutional neural network after performing multiple training actions as a convolutional neural network model. The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, including: in each training action performed on the convolutional neural network, taking the function name of the function below a certain written function of a certain executable code file that has been determined in the past as the single output content of the convolutional neural network, and taking various function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file as the multiple input contents of the convolutional neural network to complete the current training action of the convolutional neural network;
[0065] Specifically, a numerical simulation mode can be adopted to implement the test and simulation of each training action performed on the convolutional neural network.
[0066] Embodiment 2
[0067] Figure 3 It is a step flowchart of a code generation method based on artificial intelligence shown in Embodiment 2 of the present invention.
[0068] As Figure 3 shown, after automatically generating the function framework corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file, that is, after step 25, the code generation method based on artificial intelligence further includes:
[0069] Step 31: Receiving a user operation to complete the confirmation of the function framework automatically generated below the latest written function of the current executable code file;
[0070] Exemplarily, receiving a user operation to complete the confirmation of the function framework automatically generated below the latest written function of the current executable code file includes: receiving the user operation through a user input interface.
[0071] Embodiment 3
[0072] Figure 4 It is a step flowchart of a code generation method based on artificial intelligence shown in Embodiment 3 of the present invention.
[0073] As Figure 4As shown, after performing multiple training operations on a convolutional neural network to obtain the convolutional neural network after multiple training operations are completed and outputting the convolutional neural network after multiple training operations are completed as a convolutional neural network model, and after the number of training operations of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, that is, after step 23, the code generation method based on artificial intelligence further includes:
[0074] Step 41: Complete the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model;
[0075] Exemplarily, completing the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model includes: selecting to use an MMC storage chip or a FLASH storage chip to complete the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model.
[0076] Next, the code generation method based on artificial intelligence in each embodiment of the present invention will be further described.
[0077] Optionally, in any one of the above embodiments 1-3, in the code generation method based on artificial intelligence:
[0078] Obtaining the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file as the function association information of the latest written function of the current executable code file for output includes: the binary data stream of the latest written function of the current executable code file is the binary data stream obtained after the latest written function of the current executable code file is separately compiled;
[0079] Specifically, the binary data stream of the latest written function of the current executable code file being the binary data stream obtained after the latest written function of the current executable code file is separately compiled includes: optionally using a compilable tool software to perform monotonic compilation on the latest written function of the current executable code file;
[0080] Among them, in each training action performed on the convolutional neural network, the function name of the function below a certain writing function that has been determined as a certain executable code file in the past is used as the single output content of the convolutional neural network. The various function association information of the certain writing function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file are used as the multiple input contents of the convolutional neural network. Completing the current training action of the convolutional neural network includes: the binary data stream corresponding to the written code segment of the certain executable code file is the binary data stream obtained after compiling the partial code file from the starting position to the end position of the certain writing function of the certain executable code file;
[0081] Among them, using the convolutional neural network model to intelligently analyze the function name of the next writing function of the latest writing function of the current executable code file according to the various function association information of the latest writing function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: inputting the various function association information of the latest writing function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file into the convolutional neural network model, and running the convolutional neural network model to obtain the function name of the next writing function of the latest writing function of the current executable code file output by the convolutional neural network model;
[0082] Among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file further includes: the previous task number of the execution task corresponding to the current executable code file is the task number corresponding to the previous task of the execution task corresponding to the current executable code file;
[0083] And among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file further includes: the subsequent task number of the execution task corresponding to the current executable code file is the task number corresponding to the next task of the execution task corresponding to the current executable code file.
[0084] Example 4
[0085] Figure 5 The internal structure diagram of an artificial intelligence-based code generation system shown in Example 4 according to the present invention.
[0086] As Figure 5 shown, the artificial intelligence-based code generation system includes the following components:
[0087] A content capture device, configured to obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the coded code segment of the current executable code file;
[0088] Exemplarily, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the coded code segment of the current executable code file includes: multiple content capture components can be used to respectively obtain the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the coded code segment of the current executable code file;
[0089] A function parsing device, configured to obtain the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file, and output the function association information of the latest written function of the current executable code file;
[0090] Exemplarily, obtaining the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file, and outputting the function association information of the latest written function of the current executable code file includes: the function name of the latest written function of the current executable code file can be represented by ASCII codes in binary numerical representation form;
[0091] Specifically, representing the function name of the latest written function of the current executable code file by ASCII codes in binary numerical representation form includes: the ASCII codes in binary numerical representation form are the ASCII codes of the string corresponding to the function name of the latest written function of the current executable code file;
[0092] Sequential training device, which is used to perform multiple training operations on a convolutional neural network to obtain the convolutional neural network after the multiple training operations are completed, and output the convolutional neural network after the multiple training operations are completed as a convolutional neural network model. The number of training operations of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file;
[0093] Exemplarily, the fact that the number of training operations of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file includes: when the number of variables of the latest written function of the current executable code file is 1, the number of training operations of the convolutional neural network is 100; when the number of variables of the latest written function of the current executable code file is 2, the number of training operations of the convolutional neural network is 150; when the number of variables of the latest written function of the current executable code file is 3, the number of training operations of the convolutional neural network is 200, and so on;
[0094] Intelligent parsing device, which is respectively connected to the content capture device, the function parsing device and the sequential training device, and is used to intelligently parse the function name of the next written function of the latest written function of the current executable code file by using the convolutional neural network model according to various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file;
[0095] Correspondingly, the function name of the next written function of the latest written function of the current executable code file obtained by intelligent parsing is also the ASCII value of the string corresponding to the function name of the next written function of the latest written function of the current executable code file;
[0096] Framework generation device, which is connected to the intelligent parsing device, and is used to automatically generate the function framework corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file;
[0097] Among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: the binary data stream corresponding to the written code segment of the current executable code file is the binary data stream obtained after the partial code file from the starting position to the end position of the latest written function of the current executable code file is compiled;
[0098] And therein, performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after the multiple training actions are completed, and outputting the convolutional neural network after the multiple training actions are completed as a convolutional neural network model. The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, including: in each training action performed on the convolutional neural network, taking the function name of the function below a certain written function of a certain executable code file that has been determined in the past as the single output content of the convolutional neural network, and taking the various function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file as the multiple input contents of the convolutional neural network to complete the current training action of the convolutional neural network;
[0099] Specifically, a numerical simulation mode can be adopted to implement the test and simulation of each training action performed on the convolutional neural network.
[0100] Embodiment 5
[0101] Figure 6 FIG. 5 shows an internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 5 of the present invention.
[0102] As Figure 6 shown, the artificial intelligence-based code generation system further includes:
[0103] A user confirmation device, connected to the framework generation device, for receiving a user operation to complete the confirmation of the function framework automatically generated below the latest written function of the current executable code file;
[0104] Exemplarily, receiving a user operation to complete the confirmation of the function framework automatically generated below the latest written function of the current executable code file includes: receiving the user operation through a user input interface.
[0105] Embodiment 6
[0106] Figure 7 FIG. 6 shows an internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 6 of the present invention.
[0107] As Figure 7 shown, the artificial intelligence-based code generation system further includes:
[0108] A model storage device, connected to the successive training device, is configured to complete the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model;
[0109] Exemplarily, completing the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model includes: selecting to use an MMC storage chip or a FLASH storage chip to complete the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model.
[0110] Next, a code generation system based on artificial intelligence in each embodiment of the present invention will be further described.
[0111] Optionally, in any one of the above embodiments 4-6, in the code generation system based on artificial intelligence:
[0112] Obtaining the function name, the number of variables, the number of code lines, and the binary data stream of the latest written function of the current executable code file as the function association information of the latest written function of the current executable code file for output includes: the binary data stream of the latest written function of the current executable code file is the binary data stream obtained after the latest written function of the current executable code file is separately compiled;
[0113] Specifically, the binary data stream of the latest written function of the current executable code file being the binary data stream obtained after the latest written function of the current executable code file is separately compiled includes: optionally, a compilable tool software can be selected to perform monotonic compilation on the latest written function of the current executable code file.
[0114] Among them, in each training action performed on the convolutional neural network, taking the function name of the function below the function that has been determined to be a certain written function of a certain executable code file in the past as the single output content of the convolutional neural network, and taking the function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code segment of the certain executable code file as the multiple input contents of the convolutional neural network, completing the current training action of the convolutional neural network includes: the binary data stream corresponding to the written code segment of the certain executable code file is the binary data stream obtained after the partial code file from the starting position to the end position of the certain written function of the certain executable code file is compiled;
[0115] Among them, using a convolutional neural network model to intelligently analyze the function name of the next writing function of the latest writing function of the current executable code file based on various function association information of the latest writing function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: inputting various function association information of the latest writing function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file into the convolutional neural network model, and running the convolutional neural network model to obtain the function name of the next writing function of the latest writing function of the current executable code file output by the convolutional neural network model;
[0116] Among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file further includes: the previous task number of the execution task corresponding to the current executable code file is the task number corresponding to the previous task of the execution task corresponding to the current executable code file;
[0117] And among them, obtaining the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file further includes: the subsequent task number of the execution task corresponding to the current executable code file is the task number corresponding to the next task of the execution task corresponding to the current executable code file.
[0118] In addition, the outstanding features and remarkable progress of an artificial intelligence-based code generation method and system according to the present invention can be further characterized from the following aspects:
[0119] Performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and using the convolutional neural network after performing multiple training actions as the output of the convolutional neural network model. The number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest writing function of the current executable code file further includes: using a numerical mapping function to represent the numerical mapping relationship between the number of training actions of the convolutional neural network and the number of variables of the latest writing function of the current executable code file;
[0120] Exemplarily, the numerical mapping relationship representing the positive correlation between the number of training actions of the convolutional neural network and the number of variables of the latest written function of the current executable code file by using a numerical mapping function includes: in the numerical mapping function, the number of variables of the latest written function of the current executable code file is the input value of the numerical mapping function;
[0121] And exemplarily, the numerical mapping relationship representing the positive correlation between the number of training actions of the convolutional neural network and the number of variables of the latest written function of the current executable code file by using a numerical mapping function includes: in the numerical mapping function, the number of training actions of the convolutional neural network corresponding to the number of variables of the latest written function of the current executable code file is the output value of the numerical mapping function;
[0122] And wherein, performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and taking the convolutional neural network after performing multiple training actions as the output of the convolutional neural network model, the positive correlation between the number of training actions of the convolutional neural network and the number of variables of the latest written function of the current executable code file further includes: using the MATLAB toolbox to complete the simulation and testing of the process of performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing multiple training actions, and taking the convolutional neural network after performing multiple training actions as the output of the convolutional neural network model.
[0123] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present disclosure, and are not intended to limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features therein.
Claims
1. A code generation method based on artificial intelligence, characterized in that: The method comprises: Obtaining the execution task number corresponding to the current executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file; Obtaining the function name, the number of variables, the number of code lines, and the binary data stream of the latest function written in the current executable code file to output as various function-related information of the latest function written in the current executable code file; Performing multiple training actions on the convolutional neural network to obtain a convolutional neural network after performing the multiple training actions, and outputting the convolutional neural network after performing the multiple training actions as a convolutional neural network model, wherein the number of training actions of the convolutional neural network is positively correlated with the number of variables of the most recently written function of the current executable code file; A convolutional neural network model is used to intelligently parse the function name of the next written function of the latest written function of the current executable code file according to the function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code section of the current executable code file; The function frame corresponding to the function name obtained by intelligent parsing is automatically generated below the latest written function in the current executable code file; Among them, performing multiple training actions on the convolutional neural network to obtain a convolutional neural network after performing the multiple training actions, and outputting the convolutional neural network after performing the multiple training actions as a convolutional neural network model, the number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, including: in each training action performed on the convolutional neural network, using the function name of the function below a certain writing function that has been determined in the past as a certain executable code file as a single output content of the convolutional neural network, using various function association information of the certain writing function of the certain executable code file, the execution task number corresponding to the certain executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code paragraph of the certain executable code file as multiple input contents of the convolutional neural network to complete this training action of the convolutional neural network.
2. The method for generating code based on artificial intelligence according to claim 1, characterized in that: Obtaining the execution task number corresponding to the current executable code file, the predecessor task number and the successor task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: the binary data stream corresponding to the written code segment of the current executable code file is the binary data stream obtained after the partial code file of the current executable code file from the starting position to the end position of the latest written function is compiled.
3. The method for generating code based on artificial intelligence as claimed in claim 2, characterized in that: After automatically generating a function frame corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file, the method further includes: A user operation is received to complete confirmation of the function framework automatically generated below the most recently written function of the current executable code file.
4. The method for generating code based on artificial intelligence as claimed in claim 2, characterized in that: After performing a plurality of training actions on the convolutional neural network to obtain a convolutional neural network after performing the plurality of training actions, and outputting the convolutional neural network after performing the plurality of training actions as a convolutional neural network model, wherein the number of training actions of the convolutional neural network is positively correlated with the number of variables of the most recently written function of the current executable code file, the method further comprises: The model storage of the convolutional neural network model is completed by storing various model parameters of the convolutional neural network model.
5. The method for generating code based on artificial intelligence according to any one of claims 2 to 4, characterized in that: Obtaining the function name, number of variables, number of code lines and binary data stream of the latest function written in the current executable code file as the output of various function-related information of the latest function written in the current executable code file includes: the binary data stream of the latest function written in the current executable code file is a binary data stream obtained after the latest function written in the current executable code file is compiled separately; Among them, in each training action performed on the convolutional neural network, the function name of the function below a certain written function of a certain executable code file that has been determined in the past is used as a single output content of the convolutional neural network, and the various function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code section of the certain executable code file are used as multiple input contents of the convolutional neural network, and completing this training action of the convolutional neural network includes: the binary data stream corresponding to the written code section of the certain executable code file is a binary data stream obtained after the part of the code file of the certain executable code file between the starting position and the end position of the certain written function is compiled; Among them, using a convolutional neural network model to intelligently parse the function name of the next written function of the latest written function of the current executable code file according to various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code section of the current executable code file includes: inputting various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code section of the current executable code file into the convolutional neural network model, and running the convolutional neural network model to obtain the function name of the next written function of the latest written function of the current executable code file output by the convolutional neural network model; Wherein, obtaining the execution task number corresponding to the current executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraph of the current executable code file also includes: the preceding task number of the execution task corresponding to the current executable code file is the task number corresponding to the previous task of the execution task corresponding to the current executable code file; Among them, obtaining the execution task number corresponding to the current executable code file, the predecessor task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the code segment written in the current executable code file also includes: the subsequent task number of the execution task corresponding to the current executable code file is the task number corresponding to the next task of the execution task corresponding to the current executable code file.
6. A code generation system based on artificial intelligence, characterized in that: The system comprises: A content capture device, used to obtain the execution task number corresponding to the current executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file; A function parsing device, used for obtaining the function name, the number of variables, the number of code lines and the binary data stream of the latest function written in the current executable code file to output as various function-related information of the latest function written in the current executable code file; A sequential training device, for performing multiple training actions on a convolutional neural network to obtain a convolutional neural network after performing the multiple training actions, and outputting the convolutional neural network after performing the multiple training actions as a convolutional neural network model, wherein the number of training actions of the convolutional neural network is positively correlated with the number of variables of the most recently written function of the current executable code file; An intelligent parsing device, connected to the content capture device, the function parsing device and the successive training device respectively, for using a convolutional neural network model to intelligently parse the function name of the next written function of the latest written function of the current executable code file according to the function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraph of the current executable code file; A framework generating device, connected to the intelligent parsing device, for automatically generating a function framework corresponding to the function name obtained by intelligent parsing below the latest written function of the current executable code file; Among them, performing multiple training actions on the convolutional neural network to obtain a convolutional neural network after performing the multiple training actions, and outputting the convolutional neural network after performing the multiple training actions as a convolutional neural network model, the number of training actions of the convolutional neural network is positively correlated with the number of variables of the latest written function of the current executable code file, including: in each training action performed on the convolutional neural network, using the function name of the function below a certain writing function that has been determined in the past as a certain executable code file as a single output content of the convolutional neural network, using various function association information of the certain writing function of the certain executable code file, the execution task number corresponding to the certain executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code paragraph of the certain executable code file as multiple input contents of the convolutional neural network to complete this training action of the convolutional neural network.
7. The artificial intelligence-based code generation system according to claim 6, characterized in that: Obtaining the execution task number corresponding to the current executable code file, the predecessor task number and the successor task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code segment of the current executable code file includes: the binary data stream corresponding to the written code segment of the current executable code file is the binary data stream obtained after the partial code file of the current executable code file from the starting position to the end position of the latest written function is compiled.
8. The artificial intelligence-based code generation system according to claim 7, characterized in that: The system further comprises: The user confirmation device is used to receive a user operation to complete the confirmation of the function framework automatically generated below the latest written function of the current executable code file.
9. The artificial intelligence-based code generation system according to claim 7, characterized in that: The system further comprises: A model storage device is used to complete the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model.
10. The artificial intelligence-based code generation system according to any one of claims 7 to 9, characterized in that: Obtaining the function name, number of variables, number of code lines and binary data stream of the latest function written in the current executable code file as the output of various function-related information of the latest function written in the current executable code file includes: the binary data stream of the latest function written in the current executable code file is a binary data stream obtained after the latest function written in the current executable code file is compiled separately; Among them, in each training action performed on the convolutional neural network, the function name of the function below a certain written function of a certain executable code file that has been determined in the past is used as a single output content of the convolutional neural network, and the various function association information of the certain written function of the certain executable code file, the execution task number corresponding to the certain executable code file, the previous task number and the subsequent task number of the execution task corresponding to the certain executable code file, and the binary data stream corresponding to the written code section of the certain executable code file are used as multiple input contents of the convolutional neural network, and completing this training action of the convolutional neural network includes: the binary data stream corresponding to the written code section of the certain executable code file is a binary data stream obtained after the part of the code file of the certain executable code file between the starting position and the end position of the certain written function is compiled; Among them, using a convolutional neural network model to intelligently parse the function name of the next written function of the latest written function of the current executable code file according to various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code section of the current executable code file includes: inputting various function association information of the latest written function of the current executable code file, the execution task number corresponding to the current executable code file, the previous task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code section of the current executable code file into the convolutional neural network model, and running the convolutional neural network model to obtain the function name of the next written function of the latest written function of the current executable code file output by the convolutional neural network model; Wherein, obtaining the execution task number corresponding to the current executable code file, the preceding task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the written code paragraph of the current executable code file also includes: the preceding task number of the execution task corresponding to the current executable code file is the task number corresponding to the previous task of the execution task corresponding to the current executable code file; Among them, obtaining the execution task number corresponding to the current executable code file, the predecessor task number and the subsequent task number of the execution task corresponding to the current executable code file, and the binary data stream corresponding to the code segment written in the current executable code file also includes: the subsequent task number of the execution task corresponding to the current executable code file is the task number corresponding to the next task of the execution task corresponding to the current executable code file.
Citation Information
Patent Citations
Method and apparatus for neural network code generation
CN113361704A
Code generation method combining model driving and deep neural network
CN113849162A
Cross-architecture binary function similarity detection method and system based on neural network
CN112308210A
Techniques for defining and executing program code specifying neural network architecture
CN114258547A