Code generation method and system based on artificial intelligence
Through the convolutional neural network model, the code file information is intelligently parsed and subsequent function frameworks are automatically generated, which solves the problem that subsequent functions cannot be automatically generated in the existing technology, and achieves higher automation and intelligence of code generation.
Patent Information
- Application Number
- CN202510326400.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-04-18
- 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.
By using the convolutional neural network model, the framework for the next writing function is intelligently parsed and automatically generated based on the overall information of the code file and the association information of the latest written function, so that programmers only need to fill in the content.
It realizes automated code generation without manual input of function frameworks, improves the automation and intelligence level of code generation, and reduces the cumbersome work burden of programmers.
Smart Images

Figure CN119847533A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic digital data processing, and in particular to a code generation method and system based on artificial intelligence. Background Art
[0002] Code generation technology is an important technology at the intersection 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 is usually based on deep learning models, such as recurrent neural networks (RNN), long short-term memory networks (LSTM), Transformers, etc. These models are trained on large-scale code bases to learn the structure, pattern and logic of programming languages. By receiving natural language descriptions, pseudocode, existing code snippets or high-level programming instructions as input, the model can output corresponding code snippets or complete programs.
[0003] For example, Chinese invention patent publication CN113361704A proposes a method and device for neural network code generation, the method comprising: 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 the neural network operations to processing elements that can be used to perform the neural network operations based on the information and the structure of the neural network, and generating code for configuring the hardware to perform the neural network operations based on the target mapping model.
[0004] For example, the Chinese invention patent publication CN113849162A proposes a code generation method that combines model-driven and deep neural network, and the method includes the following steps: after using activity diagrams to model the target requirements, automatically generate logic structure code; use the trained deep neural network model to complete the generation of specific function code from natural language requirement description. The present invention relies on the advantages of the two code generation methods to make up for the shortcomings of each other, that is, using model-driven to solve the problems of long-distance dependency and small code granularity in natural language-based code generation; and based on natural language generation, it solves the problem of insufficient code detail information in model-driven code generation. For complex functional codes, it can not only ensure the correctness of logic and long structure, but also ensure the correctness of code details to a certain extent.
[0005] It can be seen that the above-mentioned prior art only involves the automatic generation process of codes from other languages, but cannot automatically generate subsequent functions that are not manually typed in based on the overall information of the code file and the existing function data. As a result, after the programmer has finished writing a new function, he still needs to manually type in the framework of the next function, and then fill in the content. This cannot free the programmer from the tedious and complicated work of code typing, nor can it further improve the automation and intelligence level of code generation. Summary of the invention
[0006] In order to solve the technical problems in related fields, the present invention provides a code generation method and system based on artificial intelligence. By using an artificial intelligence model, subsequent functions that are not manually typed in are automatically generated according to the overall information of the code file and the existing function data, so that after the programmer finishes writing a new function, the framework of the next function does not need to be manually typed in. 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 freeing the programmer from the tedious and complicated code typing work and further improving the automation and intelligence levels of code generation.
[0007] According to a first aspect of the present invention, there is provided a code generation method based on artificial intelligence, the method comprising:
[0008] 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;
[0009] 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;
[0010] 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;
[0011] 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;
[0012] The function frame corresponding to the function name obtained by intelligent analysis is automatically generated below the latest written function of the current executable code file.
[0013] According to a second aspect of the present invention, there is provided a code generation system based on artificial intelligence, the system comprising:
[0014] 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;
[0015] 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;
[0016] 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;
[0017] 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;
[0018] The framework generation device is connected to the intelligent analysis device and is used to automatically generate a function framework corresponding to the function name obtained by intelligent analysis below the latest written function of the current executable code file.
[0019] It can be seen that the present invention has at least the following four key inventive concepts:
[0020] Inventive concept A: introducing sufficient and comprehensive multiple basic information for intelligent analysis of the next written function of the latest written function, the multiple basic information is 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, wherein the 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: Introducing an artificial intelligence model with a customized structure for intelligent analysis of the next written 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 executing multiple training actions. It is particularly important that 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 that artificial intelligence models with different structures are customized for different current executable code files;
[0022] Inventive concept C: 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 paragraph of the current executable code file, and the function frame corresponding to the function name obtained by the intelligent analysis is automatically generated below the latest written function of the current executable code file, so that after the programmer finishes writing a new function, the framework of the next function can be automatically generated without manually typing in the framework of the next function. The programmer only needs to directly fill in the content after confirmation, and thus gradually completes the framework generation and content filling of each subsequent function, thereby freeing the programmer from the tedious and complicated code typing work, and further improving the automation and intelligence level of code generation;
[0023] Inventive concept D: 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 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 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 segment of the certain executable code file are used as multiple input contents of the convolutional neural network to complete this training action of the convolutional neural network, thereby ensuring the training effect of each training action 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, wherein:
[0025] Figure 1 The present invention is a technical flow chart of an artificial intelligence-based code generation method and system.
[0026] Figure 2 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 1.
[0027] Figure 3 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 2 of the present invention.
[0028] Figure 4 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 3.
[0029] Figure 5 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 4 of the present invention is shown.
[0030] Figure 6 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 5 of the present invention is shown.
[0031] Figure 7 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 6 of the present invention is shown. DETAILED DESCRIPTION
[0032] like Figure 1 As shown, a technical flow chart of an artificial intelligence-based code generation method and system shown in the present invention is given.
[0033] like Figure 1 As shown, the specific technical process of the present invention is as follows:
[0034] Technical process 1: introducing sufficient and comprehensive basic information for intelligent analysis of the next written function of the latest written function, wherein the basic information includes 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;
[0035] Specifically, the various function-related information of the latest function written in 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 function written in the current executable code file;
[0036] The introduction of the above-mentioned sufficient and comprehensive basic information ensures the stability and effectiveness of the intelligent analysis results;
[0037] Inventive concept B: Introducing an artificial intelligence model with a customized structure for intelligent parsing of the next written function of the latest written function;
[0038] Specifically, the structural customization of the artificial intelligence model is mainly reflected 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 executing 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 that artificial intelligence models with different structures can be customized for different current executable code files;
[0041] Third: 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 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 to complete this training action of the convolutional neural network, thereby ensuring the training effect of each training action of the convolutional neural network;
[0042] The customized design of each aspect of the above-mentioned artificial intelligence model further ensures the stability and effectiveness of the intelligent analysis results;
[0043] Technical process three: The convolutional neural network model with customized structure design in technical process two intelligently parses the function name of the next written function of the latest written function of the current executable code file based on the sufficient and comprehensive multiple basic information introduced in technical process one;
[0044] Technical process 4: automatically generate the function frame corresponding to the function name obtained by intelligent analysis below the latest written function in the current executable code file;
[0045] Technical process five: the programmer confirms whether the function framework automatically generated below the latest written function of 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, and after confirmation, fills in the function framework with content to complete the code input of the function below the latest written function;
[0046] Next, the redesigned artificial intelligence model can be used to start automatically generating the function framework of the function below the latest written function, and this operation can be repeated one by one until the entire code of the current executable code file is fully input.
[0047] In this way, after programmers finish writing a new function, they do not need to manually type in the framework of the next function. The framework of the next function will be automatically generated, and the programmers can directly fill in the content after confirmation. In this way, the framework generation and content filling of each subsequent function will be gradually completed, thereby freeing programmers from the tedious and complicated work of code typing, and further improving the automation and intelligence level of code generation.
[0048] The key points of the present invention are: customized structural design of an artificial intelligence model for intelligent analysis of the next written function of the latest written function, introduction of sufficient and comprehensive multiple basic information, targeted design of each training action executed by the convolutional neural network, and semi-automatic input mode of the overall code of the executable code file with subsequent function frameworks automatically generated, manually confirmed and filled in.
[0049] Below, an artificial intelligence-based code generation method and system of the present invention will be specifically described in the form of an embodiment.
[0050] Example 1
[0051] Figure 2 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 1.
[0052] like Figure 2 As 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 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;
[0054] For example, 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 section 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 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 section of the current executable code file;
[0055] Step 22: Obtain 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 to output as various function association information of the latest function written in the current executable code file;
[0056] For example, 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 output of the various function-related 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 an ASCII code in the form of a binary numerical value;
[0057] Specifically, the function name of the latest written function of the current executable code file may be represented by an ASCII code in a binary numerical representation form, including: the ASCII code in a binary numerical representation form is an ASCII code of a string corresponding to the function name of the latest written function of the current executable code file;
[0058] Step 23: 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 latest written function of the current executable code file;
[0059] For example, 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: the number of variables of the latest written function of the current executable code file is 1, the number of training actions of the convolutional neural network is 100, the number of variables of the latest written function of the current executable code file is 2, the number of training actions of the convolutional neural network is 150, the number of variables of 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: 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 section 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 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;
[0062] Step 25: Automatically generate a function frame corresponding to the function name obtained by intelligent analysis below the latest written function of the current executable code file;
[0063] 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 section of the current executable code file includes: the binary data stream corresponding to the written code section of the current executable code file is a binary data stream obtained after the part of the code file between the starting position and the end position of the latest written function of the current executable code file is compiled;
[0064] And wherein, 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 written function of a certain executable code file that has been determined in the past as a single output content of the convolutional neural network, using 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 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 section 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;
[0065] Specifically, a numerical simulation mode can be used to implement testing and simulation of each training action performed by the convolutional neural network.
[0066] Example 2
[0067] Figure 3 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 2 of the present invention.
[0068] like Figure 3 As shown, after the function framework corresponding to the function name obtained by intelligent parsing is automatically generated below the latest written function of the current executable code file, that is, after step 25, the code generation method based on artificial intelligence also includes:
[0069] Step 31: receiving a user operation to complete confirmation of the function framework automatically generated below the most recently written function of the current executable code file;
[0070] Illustratively, receiving a user operation to complete confirmation of the function framework automatically generated below the most recently written function of the current executable code file includes: completing the reception of the user operation through a user input interface.
[0071] Example 3
[0072] Figure 4 The present invention is a flowchart showing a method for generating code based on artificial intelligence according to Embodiment 3.
[0073] like Figure 4As shown, after 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, that is, after step 23, the code generation method based on artificial intelligence also includes:
[0074] Step 41: completing the model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model;
[0075] For example, 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, a code generation method based on artificial intelligence according to various embodiments of the present invention is further described.
[0077] In any of the above embodiments 1-3, optionally, in the artificial intelligence-based code generation method:
[0078] 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;
[0079] Specifically, the binary data stream of the latest written function of the current executable code file is a binary data stream obtained after the latest written function of the current executable code file is separately compiled, including: the latest written function of the current executable code file can be monotonically compiled by using compilable tool software;
[0080] 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;
[0081] 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;
[0082] 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;
[0083] And wherein, 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.
[0084] Example 4
[0085] Figure 5 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 4 of the present invention is shown.
[0086] like Figure 5 As shown, the code generation system based on artificial intelligence includes the following components:
[0087] 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;
[0088] For example, 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 section 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 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 section of the current executable code file;
[0089] 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 various function-related information of the latest function written in the current executable code file;
[0090] For example, 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 output of the various function-related 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 an ASCII code in the form of a binary numerical value;
[0091] Specifically, the function name of the latest written function of the current executable code file may be represented by an ASCII code in a binary numerical representation form, including: the ASCII code in a binary numerical representation form is an ASCII code of a string corresponding to the function name of the latest written function of the current executable code file;
[0092] 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;
[0093] For example, 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: the number of variables of the latest written function of the current executable code file is 1, the number of training actions of the convolutional neural network is 100, the number of variables of the latest written function of the current executable code file is 2, the number of training actions of the convolutional neural network is 150, the number of variables of 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;
[0094] 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;
[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] 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;
[0097] 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 section of the current executable code file includes: the binary data stream corresponding to the written code section of the current executable code file is a binary data stream obtained after the part of the code file between the starting position and the end position of the latest written function of the current executable code file is compiled;
[0098] And wherein, 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 written function of a certain executable code file that has been determined in the past as a single output content of the convolutional neural network, using 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 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 section 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;
[0099] Specifically, a numerical simulation mode can be used to implement testing and simulation of each training action performed by the convolutional neural network.
[0100] Example 5
[0101] Figure 6 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 5 of the present invention is shown.
[0102] like Figure 6 As shown, the code generation system based on artificial intelligence also includes:
[0103] A user confirmation device, connected to the framework generation device, for receiving a user operation to complete confirmation of the function framework automatically generated below the most recently written function of the current executable code file;
[0104] Illustratively, receiving a user operation to complete confirmation of the function framework automatically generated below the most recently written function of the current executable code file includes: completing the reception of the user operation through a user input interface.
[0105] Example 6
[0106] Figure 7 The internal structure diagram of an artificial intelligence-based code generation system according to Embodiment 6 of the present invention is shown.
[0107] like Figure 7 As shown, the code generation system based on artificial intelligence also includes:
[0108] A model storage device, connected to the successive training device, for completing model storage of the convolutional neural network model by storing various model parameters of the convolutional neural network model;
[0109] For example, 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, an artificial intelligence-based code generation system according to various embodiments of the present invention is further described.
[0111] In any of the above embodiments 4-6, optionally, in the artificial intelligence-based code generation system:
[0112] 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;
[0113] Specifically, the binary data stream of the latest written function of the current executable code file is a binary data stream obtained after the latest written function of the current executable code file is separately compiled, including: the latest written function of the current executable code file can be monotonically compiled by using compilable tool software;
[0114] 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;
[0115] 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;
[0116] 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;
[0117] And wherein, 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.
[0118] In addition, the outstanding features and significant progress of the code generation method and system based on artificial intelligence 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 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 latest written function of the current executable code file, further comprising: using a numerical mapping function to represent a numerical mapping relationship that positively correlates the number of training actions of the convolutional neural network with the number of variables of the latest written function of the current executable code file;
[0120] For example, the numerical mapping relationship in which 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 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 an input value of the numerical mapping function;
[0121] And by way of example, the numerical mapping relationship of using a numerical mapping function to represent 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 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 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, and also includes: using the MATLAB toolbox to complete the simulation and testing of the processing process of performing multiple training actions on the convolutional neural network to obtain the convolutional neural network after performing the multiple training actions, and outputting the convolutional neural network after performing the multiple training actions as 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, rather than to limit it. Although the present disclosure has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents.
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 analysis is automatically generated below the latest written function of the current executable code file.
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 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 section of the current executable code file includes: the binary data stream corresponding to the written code section of the current executable code file is a binary data stream obtained after the part of the code file between the starting position and the end position of the latest written function of the current executable code file is compiled; 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.
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; The framework generation device is connected to the intelligent analysis device and is used to automatically generate a function framework corresponding to the function name obtained by intelligent analysis below the latest written function of the current executable code file.
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 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 section of the current executable code file includes: the binary data stream corresponding to the written code section of the current executable code file is a binary data stream obtained after the part of the code file between the starting position and the end position of the latest written function of the current executable code file is compiled; 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.
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
Binary code abstract generation method and system based on BERT model and deep equal-length convolutional neural network
CN115712760A