Code generation method and apparatus, and storage medium and electronic device
Patent Information
- Application Number
- PCT/CN2025/079118
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-06
- Filing Date
- 2025-02-25
- Publication Date
- 2025-10-02
AI Technical Summary
The code generation model in the existing technology has insufficient application capabilities in vertical fields, and the generation time is long and the accuracy is low, resulting in low work efficiency.
By adjusting the matrix structure of the target code generation model, generating the target matrix using the target parameter matrix and the specified parameter matrix, and combining the preset vector library and the target excitation model to optimize the accuracy of the code generation model, the efficiency and accuracy of code generation are improved.
It reduces the time of code generation, improves work efficiency and accuracy of code generation, and expands the application scope of code generation.
Smart Images

Figure CN2025079118_02102025_PF_FP_ABST
Abstract
Description
Code generation method, device, storage medium and electronic device Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular, to a code generation method, device, storage medium, and electronic device. Background Art
[0002] Dialogue generation involves inputting conversations into a large model, which then generates responses based on its own parameters and historical conversation information. To ensure the model's applicability in a variety of scenarios, it is trained on a corpus encompassing various fields, enabling it to address basic user questions across a range of areas, including information retrieval, academic questions, and programming.
[0003] Code generation is a deep-dive application of dialogue generation to programming, resolving the problem of large models having broad applications but limited specific domain capabilities. However, related technologies only target certain language types, resulting in limited capabilities in specific domains and limited widespread application. Furthermore, code generation is time-consuming, inaccurate, and inefficient. Summary of the Invention
[0004] The present disclosure provides a code generation method, device, storage medium, and electronic device for improving the accuracy of code generation.
[0005] To achieve the above objectives, in a first aspect, the present disclosure provides a method for code generation; the method comprising:
[0006] Get the input statement entered by the user;
[0007] According to the input sentence, obtaining a target code corresponding to the input sentence through a target code generation model;
[0008] The target code generation model is obtained according to a target matrix; the target matrix is obtained according to a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to perform feature extraction on the input sentence.
[0009] Optionally, the target code generation model is generated in the following manner:
[0010] Obtaining the target matrix according to the target parameter matrix and the specified parameter matrix;
[0011] The target code generation model is obtained according to the target matrix.
[0012] Optionally, obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes:
[0013] Multiplying the specified parameter matrix by the target parameter matrix to obtain the target matrix; or,
[0014] The designated parameter matrix and the target parameter matrix are parallelized to obtain the target matrix.
[0015] Optionally, the designated parameter matrix includes a first designated parameter matrix and a second designated parameter matrix; and obtaining the target matrix according to the target parameter matrix and the designated parameter matrix includes:
[0016] Multiplying the first specified parameter matrix by the target parameter matrix to obtain a candidate matrix;
[0017] The candidate matrix and the second specified parameter matrix are parallelized to obtain the target matrix.
[0018] Optionally, obtaining a target code corresponding to the input statement through a target code generation model according to the input statement includes:
[0019] According to the input sentence, determining a target vector corresponding to the input sentence through a preset vector library;
[0020] The target code is obtained by the target code generation model according to the input sentence and the target vector.
[0021] Optionally, the method further includes:
[0022] Adjusting the accuracy of the target code generation model using a target excitation model to obtain the adjusted target code generation model;
[0023] The step of generating a target code corresponding to the input statement through a target code generation model according to the input statement includes:
[0024] According to the input sentence, the target code corresponding to the input sentence is obtained by using the adjusted target code generation model.
[0025] Optionally, adjusting the accuracy of the target code generation model by using a target incentive model to obtain the adjusted target code generation model includes:
[0026] According to the preset statement, a plurality of codes are obtained by the target code generation model;
[0027] Taking the plurality of codes as inputs of the target incentive model to obtain output candidate codes;
[0028] According to the candidate code, the accuracy of the target code generation model is adjusted.
[0029] In a second aspect, the present disclosure provides a device for code generation; the device comprises:
[0030] The acquisition module is used to obtain the input statement entered by the user;
[0031] A determination module, configured to obtain, based on the input statement, a target code corresponding to the input statement through a target code generation model;
[0032] The target code generation model is determined according to a target matrix; the target matrix is obtained according to a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to perform feature extraction on the input sentence.
[0033] Optionally, the target code generation model is generated in the following manner:
[0034] Obtaining the target matrix according to the target parameter matrix and the specified parameter matrix;
[0035] The target code generation model is obtained according to the target matrix.
[0036] Optionally, obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes:
[0037] Multiplying the specified parameter matrix by the target parameter matrix to obtain the target matrix; or,
[0038] The designated parameter matrix and the target parameter matrix are parallelized to obtain the target matrix.
[0039] Optionally, the designated parameter matrix includes a first designated parameter matrix and a second designated parameter matrix; and obtaining the target matrix according to the target parameter matrix and the designated parameter matrix includes:
[0040] Multiplying the first specified parameter matrix by the target parameter matrix to obtain a candidate matrix;
[0041] The candidate matrix and the second specified parameter matrix are parallelized to obtain the target matrix.
[0042] Optionally, the acquisition module is configured to determine, based on the input statement, a target vector corresponding to the input statement through a preset vector library; and obtain the target code through the target code generation model based on the input statement and the target vector.
[0043] Optionally, the device further comprises an adjustment module;
[0044] The adjustment module is used to adjust the accuracy of the target code generation model through the target incentive model to obtain the adjusted target code generation model;
[0045] The determination module is configured to obtain the target code corresponding to the input statement through the adjusted target code generation model according to the input statement.
[0046] Optionally, the adjustment module is used to obtain multiple codes through the target code generation model according to a preset statement; use the multiple codes as input to the target incentive model to obtain output candidate codes; and adjust the accuracy of the target code generation model according to the candidate codes.
[0047] In a third aspect, the present disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the code generation method described in the first aspect above.
[0048] In a fourth aspect, the present disclosure provides an electronic device, comprising:
[0049] a memory having a computer program stored thereon;
[0050] A processor is used to execute the computer program in the memory to implement the steps of the code generation method described in the first aspect above.
[0051] Through the above technical solution, the matrix structure of the target code generation model can be adjusted to reduce the code generation time and improve work efficiency.
[0052] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following detailed description, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. The accompanying drawings are as follows.
[0054] Fig. 1 is a flowchart showing a code generation method according to an exemplary embodiment.
[0055] Fig. 2 is a block diagram showing a target matrix according to an exemplary embodiment.
[0056] FIG. 3 is a flow chart showing a code generation method according to the exemplary embodiment of FIG. 1 .
[0057] FIG. 4 is a flow chart showing a code generation method according to the exemplary embodiment of FIG. 3 .
[0058] FIG. 5 is a flowchart of a code generation method according to the exemplary embodiment of FIG. 4 .
[0059] Fig. 6 is a block diagram showing a device for generating code according to an exemplary embodiment.
[0060] Fig. 7 is a block diagram showing another apparatus for code generation according to an exemplary embodiment.
[0061] FIG8 is a block diagram of a code generating apparatus according to the exemplary embodiment of FIG7 .
[0062] Fig. 9 is a block diagram of an electronic device according to an exemplary embodiment.
[0063] Fig. 10 is a block diagram of another electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0064] The following describes the specific embodiments of the present disclosure in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present disclosure and are not intended to limit the present disclosure.
[0065] First, let's introduce the application scenario of this disclosure, which is to generate software code using a network model. In related technologies, dialog generation can be performed using a large model. A large model refers to a network model with a large number of parameters. This network model can be a deep learning model or a machine learning model, etc., without limitation here.
[0066] Dialogue generation involves inputting conversations into a large model, which then generates responses based on its own parameters and historical conversation information. To ensure the model's applicability in a variety of scenarios, it is trained on a corpus encompassing various fields, enabling it to address basic user questions across a range of areas, including information retrieval, academic questions, and programming.
[0067] Code generation is a deep-dive application of dialogue generation to programming, resolving the problem of large models having broad applications but limited specific domain capabilities. However, code generation is limited to certain language types, resulting in limited capabilities in specific domains and limiting widespread application. Furthermore, code generation is time-consuming and inaccurate, resulting in low efficiency.
[0068] In order to solve the above problems, the present disclosure provides a code generation method, device, storage medium and electronic device; an input statement input by a user is obtained; based on the input statement, a target code corresponding to the input statement is obtained through a target code generation model; wherein the target code generation model is obtained based on a target matrix; the target matrix is obtained based on a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to extract features from the input statement; through the above technical solution, the code generation time can be reduced and work efficiency can be improved by adjusting the matrix structure of the target code generation model.
[0069] Fig. 1 is a flow chart showing a method for code generation according to an exemplary embodiment. As shown in Fig. 1 , the method may include the following steps.
[0070] S101: Obtain an input statement input by a user.
[0071] S102: According to the input statement, a target code corresponding to the input statement is obtained through a target code generation model.
[0072] The target code generation model is obtained according to the target matrix; the target matrix is obtained according to the target parameter matrix and the specified parameter matrix; the target parameter matrix is used to perform feature extraction on the input sentence.
[0073] For example, an input statement may be converted into a corresponding multidimensional input vector; a multidimensional output vector corresponding to the multidimensional input vector may be obtained through a target code generation model based on the multidimensional input vector; and the multidimensional output vector may be converted into a corresponding target code.
[0074] For example, the target matrix in the target code generation model can be operated on the multidimensional input vector to obtain a multidimensional output vector corresponding to the multidimensional input vector; and the multidimensional output vector can be converted into the corresponding target code.
[0075] For example, the target code model can be used to generate Python code to improve the generation capability of the code generation model in the field of Python code and expand the application scope of code generation.
[0076] It should be noted that the cross entropy of the multidimensional output vector and the preset output vector can be calculated, and backpropagation can be performed according to the gradient descent method to update each parameter in the specified parameter matrix. The above steps are repeated until the multidimensional output vector actually output by the target code generation model and the preset output vector are basically fitted, thereby completing the adjustment of the matrix parameters of the target code generation model.
[0077] Through the above technical solution, the matrix structure of the target code generation model can be adjusted to reduce the code generation time and improve work efficiency.
[0078] In some embodiments, the target code generation model may be generated in the following manner: obtaining the target matrix according to the target parameter matrix and the specified parameter matrix; and obtaining the target code generation model according to the target matrix.
[0079] For example, the target code generation model can be derived based on a preset network model, such as the open-source model ChatGLM2. The target parameter matrix can be an intrinsic parameter matrix of the preset network model, used to extract features from input sentences. The specified parameter matrix can be an added parameter matrix used to adjust the model structure. In this way, by adding the specified parameter matrix, the target code generation model can be fine-tuned, thereby reducing the number of parameters in the target code generation model and improving code generation efficiency without reducing runtime.
[0080] In other embodiments, obtaining the target matrix based on the target parameter matrix and the specified parameter matrix may include: multiplying the specified parameter matrix by the target parameter matrix to obtain the target matrix; or, performing parallel multiplication of the specified parameter matrix and the target parameter matrix to obtain the target matrix.
[0081] The target matrix can be obtained by right-multiplying the specified parameter matrix with the target parameter matrix. Matrix right-multiplication refers to multiplying a multidimensional input vector by a matrix to obtain a multidimensional output vector. Multiple matrix parallelism refers to multiplying a multidimensional input vector by each matrix separately to obtain a result, and then linearly adding the results to obtain a multidimensional output vector.
[0082] For example, the multidimensional input vector may be multiplied by the target parameter matrix and the designated parameter matrix to obtain the multidimensional output vector. Alternatively, the multidimensional input vector may be multiplied by the target parameter matrix to obtain a first operation result; the multidimensional input vector may be multiplied by the designated parameter matrix to obtain a second operation result; and the first operation result and the second operation result may be linearly added to obtain the multidimensional output vector.
[0083] For example, assuming that the multidimensional input vector is X and the multidimensional output vector is H; the target parameter matrix includes the W matrix, and the specified parameter matrix includes the B matrix and the A matrix; then when the specified parameter matrix is multiplied by the target parameter matrix, the multidimensional output vector H = WBAX; when the specified parameter matrix and the target parameter matrix are parallel, the multidimensional output vector H = WX + BAX.
[0084] It should be noted that the dimension of the W matrix is W∈R d×k , the B matrix dimension is B∈R d×r , the dimension of A is B∈R r×k , where r is much smaller than min(d, k). In this way, the number of model parameters can be reduced by specifying the parameter matrix, which speeds up the model training.
[0085] In some embodiments, the specified parameter matrix includes a first specified parameter matrix and a second specified parameter matrix; the above-mentioned obtaining of the target matrix based on the target parameter matrix and the specified parameter matrix may include: multiplying the first specified parameter matrix with the target parameter matrix to obtain a candidate matrix; and parallelizing the candidate matrix with the second specified parameter matrix to obtain the target matrix.
[0086] The designated parameter matrix can be right-multiplied by the target parameter matrix to obtain the candidate matrix. For example, the multidimensional input vector can be multiplied by the first designated parameter matrix and the target parameter matrix to obtain a third operation result; the multidimensional input vector can be multiplied by the second designated parameter matrix to obtain a fourth operation result; and the third operation result and the fourth operation result can be linearly added to obtain the multidimensional output vector.
[0087] For example, as shown in Figure 2, assuming that the multidimensional input vector is X and the multidimensional output vector is H; the target parameter matrix includes the W matrix, the first specified parameter matrix may include the D matrix and the C matrix; the second specified parameter matrix may include the B matrix and the A matrix, then the multidimensional output vector H = WDCX + BAX.
[0088] Fig. 3 is a flow chart of a code generation method according to the exemplary embodiment of Fig. 1. As shown in Fig. 3, the above step S101 may include the following steps.
[0089] S1011. According to the input sentence, determine a target vector corresponding to the input sentence through a preset vector library.
[0090] S1012: Obtain the target code through the target code generation model according to the input statement and the target vector.
[0091] For example, the preset vector library can be obtained in the following manner: obtain a document corresponding to a specified type code; split the document into multiple segments; obtain the embedded vector word corresponding to each segment through a preset language model; obtain the corresponding vector based on the embedded vector word through a preset algorithm; the vector is used to represent the content of each segment; and the preset vector library is obtained based on multiple vectors.
[0092] For example, the corresponding target vector may be determined from a preset vector library by using cosine similarity according to the input sentence.
[0093] For example, the specified type of code can be Python code; the preset language model can be a Transformer model; and the preset algorithm can be a Mean Pooling algorithm. The preset vector library can be trained through asymmetric semantic retrieval so that the preset vector library can find corresponding code answers for related questions. In this way, the user's input statement can be analyzed through the preset vector library to obtain the target vector, thereby improving the accuracy of the model's analysis of the input statement, thereby improving the accuracy of code generation and improving work efficiency.
[0094] Fig. 4 is a flow chart of a code generation method according to the exemplary embodiment of Fig. 3. As shown in Fig. 4, the method may further include the following steps.
[0095] S103: Adjust the accuracy of the target code generation model using the target excitation model to obtain the adjusted target code generation model.
[0096] S104: According to the input statement, the target code corresponding to the input statement is obtained by using the adjusted target code generation model.
[0097] For example, the target excitation model can be derived from a GAN generative adversarial network (GAN). This target excitation model can serve as a generator for the GAN, generating code execution results. In this way, the target code generation model can be adjusted using the target excitation model to improve the precision of the code generation model, thereby improving the accuracy of code generation.
[0098] Fig. 5 is a flow chart showing a code generation method according to the exemplary embodiment of Fig. 4. As shown in Fig. 5, the above step S103 may include the following steps.
[0099] S1031. According to the preset statement, a plurality of codes are obtained through the target code generation model.
[0100] S1032: Use the multiple codes as input to the target excitation model to obtain output candidate codes.
[0101] S1033. Adjust the accuracy of the target code generation model according to the candidate code.
[0102] In some embodiments, the above step S1032 may include: determining the first running result of each code through the target incentive model; each first running result corresponds to a preset score; and selecting the code with the highest preset score as the candidate code.
[0103] For example, the target incentive model may include unit tests; the first execution result of each code segment may be determined through the unit tests. The first execution result may include passing all test cases, passing some test cases, a runtime error, or a compilation error. The preset score corresponding to passing all test cases may be 1.0; the preset score corresponding to passing some test cases may be -0.3; the preset score corresponding to a runtime error may be -0.6; and the preset score corresponding to a compilation error may be -1.0. In this way, candidate code can be quickly determined based on the preset scores, thereby improving work efficiency.
[0104] In other embodiments, the target stimulus model can be used to determine multiple codes that pass all test cases and establish a target code set. A specific code in the target code set is used as the candidate code. This allows the accuracy of the target code generation model to be further adjusted using high-quality code, thereby improving work efficiency.
[0105] In some embodiments, the second running result of each code can be determined by a compiler; whether there is a difference between the first running result and the second running result can be determined by a discriminator; when it is determined that there is a difference between the first running result and the second running result, the accuracy of the discriminator is adjusted according to the first running result and the second running result; and the accuracy of the target incentive model is adjusted according to the adjusted discriminator.
[0106] For example, the discriminator can be obtained based on a GAN generative adversarial network, and the discriminator can obtain the GAN generative adversarial network with the target excitation model (generator). The second running result may include passing all test samples, passing some test samples, running errors or compiling errors. Each second running result corresponds to a preset score, wherein the preset score corresponding to passing all test samples may be 1.0; the preset score corresponding to passing some test samples may be -0.3; the preset score corresponding to the running error may be -0.6; and the preset score corresponding to the compiling error may be -1.0. The discriminator can determine whether there is a difference between the first running result and the second running result by the preset score of the first running result and the preset score of the second running result.
[0107] It should be noted that the technical solution for adjusting the accuracy of the discriminator and the technical solution for adjusting the accuracy of the generator (target excitation model) based on the discriminator have been disclosed in relevant technical literature and will not be repeated here.
[0108] In other embodiments, the above-mentioned step S1033 may include: obtaining the target character through the target code generation model according to the candidate code; determining the perplexity of the target code generation model according to the target character; the perplexity represents the accuracy of the target code generation model; the perplexity is negatively correlated with the accuracy of the target code generation model; repeatedly performing the above-mentioned steps of obtaining the target character through the target code generation model according to the candidate code; determining the perplexity of the target code generation model according to the target character, until the perplexity is less than or equal to a preset perplexity threshold, and stopping adjusting the accuracy of the target code generation model according to the candidate code.
[0109] For example, the target character can be obtained through the target code generation model based on the subsequence of the candidate code (from short to long); the target character can be a token; this can simplify the model generation steps and quickly adjust the model accuracy.
[0110] For example, the perplexity can represent the probability of the target code generation model generating a sentence. Assume that a sentence S consists of n words W, that is, S = W1, W2, ..., W n ; Then the probability of generating the sentence through the target code generation model is: P(S)=P(W1,W2,…,W N )=P(W1)P(W2|W1)…P(W n |W1,W2,…,W k-1 );
[0111] The perplexity (PPL) can be determined by the following formula:
[0112] For example, each parameter of the specified parameter matrix of the target code generation model can be updated by backpropagation based on the perplexity until the multi-dimensional output vector actually output by the target code generation model and the preset output vector are basically fitted, thereby completing further adjustment of the matrix parameters of the target code generation model.
[0113] In other embodiments, the target code generation model may include a fused computation module; this fused computation module is obtained by fusing multiple computation modules. For example, the computation module may be an operator (OP) for implementing a computation process; the computation process may be addition, multiplication, or exponentiation, for example. Because each computation requires calling an operator, which occupies video memory read / write space, the computation process results in a significant amount of video memory read / write space being occupied. By fusing multiple computation modules, the number of video memory accesses can be reduced during the computation process, improving the model's operational efficiency.
[0114] Figure 6 is a block diagram of a code generation device according to an exemplary embodiment. As shown in Figure 6, the device may include a preset vector library, a target code generation model, a target incentive model, a compiler, and a discriminator.
[0115] First, the user's input sentence can be obtained; and the target vector corresponding to the input sentence is determined through a preset vector library; according to the input sentence and the target vector, the output code is obtained through the target code generation model.
[0116] Second, a preset sentence can be obtained and a vector corresponding to the preset sentence can be determined using a preset vector library. Based on the input sentence and the vector, the target code generation model is used to obtain the multiple output codes. Next, the multiple codes are used as input to the target stimulus model to obtain candidate output codes. The candidate codes are then input into the target code generation model to adjust the accuracy of the target code generation model.
[0117] Third, a first execution result is obtained using the target excitation model based on the multiple output codes; a second execution result is obtained using a compiler based on the multiple output codes; the first execution result and the second execution result are input into a discriminator, and the discriminator determines whether there is a difference between the first execution result and the second execution result. If a difference is determined between the first execution result and the second execution result, the accuracy of the discriminator is adjusted based on the first execution result and the second execution result. Next, the first execution result and the second execution result are input into the target excitation model to adjust the accuracy of the target excitation model.
[0118] Through the above technical solution, the matrix structure of the target code generation model can be adjusted to reduce the code generation time and improve work efficiency.
[0119] FIG7 is a block diagram of another apparatus for code generation according to an exemplary embodiment. As shown in FIG7 , the apparatus 700 may include an acquisition module 710 and a determination module 720;
[0120] The acquisition module 710 is used to acquire the input sentence input by the user;
[0121] The determination module 720 is used to obtain the target code corresponding to the input sentence through the target code generation model according to the input sentence;
[0122] The target code generation model is determined according to a target matrix; the target matrix is obtained according to a target parameter matrix and a specified parameter matrix; and the target parameter matrix is used to perform feature extraction on the input sentence.
[0123] Through the above technical solution, the matrix structure of the target code generation model can be adjusted to reduce the code generation time and improve work efficiency.
[0124] Optionally, the target code generation model is generated by:
[0125] Obtain the target matrix according to the target parameter matrix and the specified parameter matrix;
[0126] The target code generation model is obtained according to the target matrix.
[0127] Optionally, obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes:
[0128] Multiplying the specified parameter matrix with the target parameter matrix to obtain the target matrix; or,
[0129] The specified parameter matrix and the target parameter matrix are parallelized to obtain the target matrix.
[0130] Optionally, the specified parameter matrix includes a first specified parameter matrix and a second specified parameter matrix; and obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes:
[0131] Multiplying the first specified parameter matrix by the target parameter matrix to obtain a candidate matrix;
[0132] The candidate matrix and the second specified parameter matrix are parallelized to obtain the target matrix.
[0133] Optionally, the acquisition module 710 is configured to determine a target vector corresponding to the input statement through a preset vector library according to the input statement; and obtain the target code through the target code generation model according to the input statement and the target vector.
[0134] Fig. 8 is a block diagram of a code generation apparatus according to the exemplary embodiment of Fig. 7. As shown in Fig. 8, the apparatus 700 may further include an adjustment module 730;
[0135] The adjustment module 730 is used to adjust the accuracy of the target code generation model through the target incentive model to obtain the adjusted target code generation model;
[0136] The determination module 720 is configured to generate the target code corresponding to the input statement through the adjusted target code generation model according to the input statement.
[0137] Optionally, the adjustment module 730 is used to obtain multiple codes through the target code generation model according to a preset statement; use the multiple codes as input to the target excitation model to obtain output candidate codes; and adjust the accuracy of the target code generation model according to the candidate codes.
[0138] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0139] In summary, the present disclosure provides a method, device, storage medium and electronic device for code generation; an input statement input by a user is obtained; based on the input statement, a target code corresponding to the input statement is obtained through a target code generation model; wherein the target code generation model is obtained based on a target matrix; the target matrix is obtained based on a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to extract features from the input statement; through the above technical solution, the code generation time can be reduced and work efficiency can be improved by adjusting the matrix structure of the target code generation model.
[0140] FIG9 is a block diagram of an electronic device 900 according to an exemplary embodiment. As shown in FIG9 , the electronic device 900 may include a processor 901 and a memory 902. The electronic device 900 may also include one or more of a multimedia component 903, an input / output interface 904, and a communication component 905.
[0141] The processor 901 is used to control the overall operation of the electronic device 900 to complete all or part of the steps in the code generation method described above. The memory 902 is used to store various types of data to support the operation of the electronic device 900. For example, these data may include instructions for any application or method operating on the electronic device 900, as well as application-related data, such as contact information, sent and received messages, pictures, audio, video, etc. The memory 902 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. The multimedia component 903 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 902 or sent through the communication component 905. The audio component also includes at least one speaker for outputting audio signals. The input / output interface 904 provides an interface between the processor 901 and other interface modules. The above-mentioned other interface modules may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 905 is used for wired or wireless communication between the electronic device 900 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 905 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0142] In an exemplary embodiment, the electronic device 900 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the above-mentioned code generation method.
[0143] In another exemplary embodiment, a computer-readable storage medium including program instructions is further provided. When the program instructions are executed by a processor, the steps of the above-described code generation method are implemented. For example, the computer-readable storage medium may be the aforementioned memory 902 including the program instructions. The program instructions may be executed by the processor 901 of the electronic device 900 to implement the above-described code generation method.
[0144] Figure 10 is a block diagram of another electronic device 1000 according to an exemplary embodiment. For example, the electronic device 1000 can be provided as a server. Referring to Figure 10, the electronic device 1000 includes a processor 1022, which can be one or more, and a memory 1032 for storing a computer program executable by the processor 1022. The computer program stored in the memory 1032 may include one or more modules, each corresponding to a set of instructions. In addition, the processor 1022 can be configured to execute the computer program to perform the above-mentioned code generation method.
[0145] In addition, the electronic device 1000 may further include a power supply component 1026 and a communication component 1050. The power supply component 1026 may be configured to perform power management of the electronic device 1000, and the communication component 1050 may be configured to implement communication, such as wired or wireless communication, of the electronic device 1000. In addition, the electronic device 1000 may further include an input / output interface 1058. The electronic device 1000 may operate based on an operating system stored in the memory 1032.
[0146] In another exemplary embodiment, a computer-readable storage medium including program instructions is further provided, wherein the program instructions, when executed by a processor, implement the steps of the aforementioned code generation method. For example, the non-transitory computer-readable storage medium may be the aforementioned memory 1032 including the program instructions, and the program instructions may be executed by the processor 1022 of the electronic device 1000 to perform the aforementioned code generation method.
[0147] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned code generation method when executed by the programmable device.
[0148] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments. Within the technical concept of the present disclosure, various simple modifications can be made to the technical solutions of the present disclosure, and these simple modifications all fall within the scope of protection of the present disclosure.
[0149] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any appropriate manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0150] In addition, the various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A code generation method, characterized in that: The method comprises: Get the input statement entered by the user; According to the input sentence, obtaining a target code corresponding to the input sentence through a target code generation model; The target code generation model is obtained according to a target matrix; the target matrix is obtained according to a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to perform feature extraction on the input sentence.
2. The method according to claim 1, characterized in that The target code generation model is generated in the following way: Obtaining the target matrix according to the target parameter matrix and the specified parameter matrix; The target code generation model is obtained according to the target matrix.
3. The method according to claim 2, characterized in that Obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes: Multiplying the specified parameter matrix by the target parameter matrix to obtain the target matrix; or, The designated parameter matrix and the target parameter matrix are parallelized to obtain the target matrix.
4. The method according to claim 2, characterized in that The specified parameter matrix includes a first specified parameter matrix and a second specified parameter matrix; and obtaining the target matrix according to the target parameter matrix and the specified parameter matrix includes: Multiplying the first specified parameter matrix by the target parameter matrix to obtain a candidate matrix; The candidate matrix and the second specified parameter matrix are parallelized to obtain the target matrix.
5. The method according to claim 1, wherein The step of generating a target code corresponding to the input statement through a target code generation model according to the input statement includes: According to the input sentence, determining a target vector corresponding to the input sentence through a preset vector library; The target code is obtained by the target code generation model according to the input sentence and the target vector.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Adjusting the accuracy of the target code generation model using a target excitation model to obtain the adjusted target code generation model; The step of generating a target code corresponding to the input statement through a target code generation model according to the input statement includes: According to the input sentence, the target code corresponding to the input sentence is obtained by using the adjusted target code generation model.
7. The method according to claim 6, characterized in that The step of adjusting the accuracy of the target code generation model by using the target incentive model to obtain the adjusted target code generation model includes: According to the preset statement, a plurality of codes are obtained by the target code generation model; Taking the plurality of codes as inputs of the target incentive model to obtain output candidate codes; According to the candidate code, the accuracy of the target code generation model is adjusted.
8. A code generation device, characterized in that: The device comprises: The acquisition module is used to obtain the input statement entered by the user; A determination module, configured to obtain, based on the input statement, a target code corresponding to the input statement through a target code generation model; The target code generation model is determined according to a target matrix; the target matrix is obtained according to a target parameter matrix and a specified parameter matrix; the target parameter matrix is used to perform feature extraction on the input sentence.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 7.