CN117311800A - Code reconstruction method, device, electronic equipment and storage medium - Google Patents

Code reconstruction method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117311800A
CN117311800A CN202311204842.4A CN202311204842A CN117311800A CN 117311800 A CN117311800 A CN 117311800A CN 202311204842 A CN202311204842 A CN 202311204842A CN 117311800 A CN117311800 A CN 117311800A
Authority
CN
China
Prior art keywords
code
reconstructed
opinion
model
reconstruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311204842.4A
Other languages
Chinese (zh)
Inventor
盛怿寒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202311204842.4A priority Critical patent/CN117311800A/en
Publication of CN117311800A publication Critical patent/CN117311800A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Stored Programmes (AREA)

Abstract

The method, the device, the electronic equipment and the storage medium for reconstructing the code provided by the embodiment of the invention comprise the steps of obtaining the code to be reconstructed; inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured; and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code. The reconstructed opinion model is a model capable of understanding code semantics, and by inputting the code to be reconstructed into the reconstructed opinion model, the reconstructed opinion model can quickly and automatically give accurate reconstructed opinions according to the semantics of the code to be reconstructed, and provides references for programmers, so that the time and energy of code analysis and reconstruction are reduced, the reconstruction efficiency is improved, and the software online time is greatly shortened.

Description

Code reconstruction method, device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computer data processing, in particular to a method and a device for reconstructing codes, electronic equipment and a storage medium.
Background
Because of the rapid iteration of the software development process, the code is faced with various problems of high code complexity, poor code universality, emerging new technology, difficult code maintenance and the like in the later stage, so in order to improve the quality and maintainability of a software system to meet the increasingly changing requirements and technical environments, the code reconstruction is a necessary link, and the code reconstruction refers to the operations of structural adjustment, rewriting, optimization and the like on the existing code so as to improve the code quality, readability and maintainability and reduce the redundancy and complexity of the code.
At present, code reconstruction mainly depends on manual implementation, and because the existing code structure is complex, programmers need to consume a great deal of time and energy to reconstruct, the code reconstruction efficiency is greatly reduced, and the software online time is increased.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method, an apparatus, an electronic device, and a storage medium for code reconstruction, which can quickly and automatically generate a reconstruction suggestion based on a reconstruction opinion model, and provide a reference for a programmer, so as to reduce time and effort for code analysis and reconstruction, improve reconstruction efficiency, and greatly shorten software online time.
In a first aspect, an embodiment of the present invention provides a method for reconstructing a code, where the method includes:
acquiring a code to be reconstructed;
inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In one possible embodiment, after acquiring the code to be reconstructed, the method further comprises:
performing code format processing on the code to be reconstructed; the code format of the code to be reconstructed after the code format processing accords with the data format of the input reconstruction opinion model.
In one possible implementation, the training process to reconstruct the opinion model includes:
acquiring a training sample set and a code task corresponding to the training sample set; the training sample set comprises a plurality of training samples, each training sample consists of code data and a code label, and the code label is a reconstruction opinion of the code data;
determining diversity parameters of the pre-trained language model based on the code tasks; the diversity parameter is used for controlling the diversity of the generated text;
model training is carried out on the language model comprising the diversity parameters based on the training sample set until the training times reach a preset training times threshold value or the model loss value reaches a preset model loss threshold value, and a reconstruction opinion model is obtained.
In one possible implementation, determining diversity parameters of a pre-trained language model based on code tasks includes:
inquiring target code tasks matched with the code tasks from a diversity parameter inquiry table; the diversity parameter lookup table stores the corresponding relation between the code task and the diversity parameter;
and determining the target diversity parameter corresponding to the target code task as the diversity parameter of the code task.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
inputting the reconstructed code into a code evaluation model, and outputting a code evaluation result by the code evaluation model; the code evaluation result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code evaluation result does not meet the preset evaluation result, carrying out iterative optimization on the reconstruction opinion model based on the code evaluation result.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
comparing the reconstructed code with the manual reconstructed code to obtain a code comparison result; the code comparison result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code comparison result does not meet the preset comparison result, carrying out iterative optimization on the reconstructed opinion model based on the code comparison result.
In one possible embodiment, after acquiring the training sample set and the code task corresponding to the training sample set, the method further comprises:
code format processing is performed on the code data of each training sample in the training sample set.
In a second aspect, an embodiment of the present invention provides an apparatus for reconstructing a code, where the apparatus includes:
the acquisition module is used for acquiring the code to be reconstructed;
the output module is used for inputting the code to be reconstructed into the reconstructed opinion model and outputting the reconstructed opinion by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and the modification optimization module is used for modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In a third aspect, an embodiment of the present invention provides an electronic device, including: the processor is used for executing the code reconstruction program stored in the memory so as to realize the code reconstruction method.
In a fourth aspect, an embodiment of the present invention provides a storage medium, where the storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the method for reconstructing a code described above.
The method, the device, the electronic equipment and the storage medium for reconstructing the code provided by the embodiment of the invention comprise the steps of obtaining the code to be reconstructed; inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured; and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code. The reconstructed opinion model is a model capable of understanding code semantics, and by inputting the code to be reconstructed into the reconstructed opinion model, the reconstructed opinion model can quickly and automatically give accurate reconstructed opinions according to the semantics of the code to be reconstructed, and provides references for programmers, so that the time and energy of code analysis and reconstruction are reduced, the reconstruction efficiency is improved, and the software online time is greatly shortened.
Drawings
Fig. 1 is a flowchart of an embodiment of a method for reconstructing a code according to an embodiment of the present invention;
FIG. 2 is a flowchart of an embodiment of another method for code reconstruction according to an embodiment of the present invention;
FIG. 3 is a block diagram of an embodiment of an apparatus for code reconstruction according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
For the purpose of facilitating an understanding of the embodiments of the present invention, reference will now be made to the following description of specific embodiments, taken in conjunction with the accompanying drawings, which are not intended to limit the embodiments of the invention.
An embodiment of the present invention provides a method for reconstructing a code, referring to fig. 1, and fig. 1 is a flowchart of an embodiment of a method for reconstructing a code provided by an embodiment of the present invention. The flow shown in fig. 1 may include the following steps:
step 101, obtaining a code to be reconstructed;
in general, codes for implementing each code task are stored in a code library, where a code task can be understood as a specific task implemented by a code, and when an update occurs in a library or a framework used in the specific implementation, a code corresponding to the update, that is, a code to be reconstructed, needs to be determined from the code library, and this code needs to be reconstructed to meet the update requirement.
102, inputting a code to be reconstructed into a reconstructed opinion model, and outputting a reconstructed opinion by the reconstructed opinion model;
the reconstructed opinion model is obtained by training with a language model capable of understanding code semantics, and the language model may be a GPT (generated Pre-trained Transformer) model, a large-scale language model, an N-gram language model, or the like, and is not limited herein.
Because the reconstructed opinion model can accurately understand the semantics of the code to be reconstructed, the reconstructed opinion model can rapidly and automatically give out accurate reconstructed opinions according to the semantics of the code to be reconstructed, so that the code to be reconstructed can be conveniently reconstructed.
The reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured, and the reconfiguration content can be content such as code transformation operation, optimization skills, application of design modes and the like, and aims to improve the readability, performance or maintainability of the code to be reconfigured.
And step 103, modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In one embodiment, the reconstructed code to be reconstructed may be modified by using the reconstructed opinion outputted by the reconstructed opinion model, for example, the reconstructed content is a code change operation, and the reconstructed code may be correspondingly operated according to a specific process of the code change operation, so as to obtain the reconstructed code for application.
In another embodiment, the programmer can correspondingly adjust the reconstructed opinion to better meet the reconstruction requirement, so that the reconstructed code is correspondingly modified based on the adjusted reconstructed opinion, and the reconstructed code is more suitable for application.
The code reconstruction method provided by the embodiment of the invention comprises the steps of obtaining a code to be reconstructed; inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured; and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code. The reconstructed opinion model is a model capable of understanding code semantics, and by inputting the code to be reconstructed into the reconstructed opinion model, the reconstructed opinion model can quickly and automatically give accurate reconstructed opinions according to the semantics of the code to be reconstructed, and provides references for programmers, so that the time and energy of code analysis and reconstruction are reduced, the reconstruction efficiency is improved, and the software online time is greatly shortened.
Referring to fig. 2 on the basis of fig. 1, fig. 2 is a flowchart of an embodiment of another method for reconstructing codes according to an embodiment of the present invention. The flow shown in fig. 2 may include the following steps:
step 201, obtaining a code to be reconstructed;
step 202, code format processing is carried out on the code to be reconstructed;
the code format of the code to be reconstructed after the code format processing accords with the data format of the input reconstruction opinion model, and the data formats input to the language model are different because of different language models, so that the mode of carrying out code format processing on the code to be reconstructed is different, and the code format processing on the code to be reconstructed can be specifically carried out by utilizing the existing code analysis tools and technologies, and the details are not described here.
Step 203, inputting a code to be reconstructed into a reconstructed opinion model, and outputting a reconstructed opinion by the reconstructed opinion model;
the training process of the reconstructed opinion model can be realized through steps A1 to A3:
a1, acquiring a training sample set and code tasks corresponding to the training sample set;
the training sample set comprises a plurality of training samples, each training sample consists of code data and a code label, and the code label is a reconstruction opinion of the code data; the code data may be understood as a code to be reconstructed, and may be obtained from an open source item, a code repository, or an internal code repository, which is not limited herein.
The code task corresponding to the training sample set refers to a code task corresponding to each training sample, that is, one training sample corresponds to one code task, which is used for indicating a specific task implemented by the code data, for example, the code task corresponding to the code data 1 is video recommendation, and the code task corresponding to the code data 2 is financial product recommendation.
A2, determining diversity parameters of a pre-trained language model based on the code task;
the diversity parameter is used for controlling the diversity of the generated text; the above-mentioned diversity parameter is a Temperature parameter in the language model, and the value range of the Temperature parameter is usually between 0 and 1. When the value of the Temperature parameter approaches 0, the text generated by the model will be more deterministic and consistent, with a greater likelihood of repeatability, that is, the model will be more prone to select the output with the highest probability. This may make the generated content too fixed and unitary.
As the value of the Temperature parameter approaches 1, the text generated by the model will be more diverse and unordered, that is, the model will consider more possibilities when selecting the next word or phrase, which may make the generated content more diverse and creative.
In particular, when different code tasks select different diversity parameters, that is, the values of the diversity parameters determined by the different code tasks are different, for example, the code tasks are video recommendation, the values of the diversity parameters may be required to be close to 1 in order to recommend various videos to users, if the code tasks are financial product recommendation, the values of the diversity parameters are required to be close to 0 in order to recommend most suitable financial products to users, and therefore, the more flexible the values of the diversity parameters determined by the code tasks are close to 1, and the more strict the values of the diversity parameters determined by the code tasks are close to 0.
The specific process for determining the diversity parameters is as follows: inquiring target code tasks matched with the code tasks from a diversity parameter inquiry table; determining a target diversity parameter corresponding to the target code task as a diversity parameter of the code task;
the corresponding relation between the code tasks and the diversity parameters is stored in the diversity parameter lookup table, so that the values of the diversity parameters corresponding to the code tasks can be understood as the values of the diversity parameters corresponding to the different code tasks, and the values of the diversity parameters corresponding to the code tasks can be accurately queried from the diversity parameter lookup table through the corresponding relation.
And step A3, carrying out model training on the language model comprising the diversity parameters based on the training sample set until the training times reach a preset training times threshold or the model loss value reaches a preset model loss threshold, and obtaining a reconstruction opinion model.
Generally, code format processing is required to be performed on code data of each training sample in the training sample set, the code data is input into a language model after being converted into a data format received by the language model, the language model performs model training based on the code data, and model parameter adjustment is performed by using a reconstructed opinion output by the language model and a code label corresponding to the code data until training times reach a preset training times threshold or a model loss value reaches a preset model loss threshold, so as to obtain a reconstructed opinion model.
Based on the trained reconstructed opinion model, in step 203, the code to be reconstructed may be input into the reconstructed opinion model to obtain the reconstructed opinion of the code to be reconstructed.
And 204, modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In practical application, in order to ensure that the functions and performances of the reconstructed codes are maintained or improved, the reconstructed codes need to be verified, and in one embodiment, the reconstructed codes are input into a code evaluation model, and the code evaluation model outputs code evaluation results; the code evaluation result is used for evaluating the code quality of the reconstructed code; and under the condition that the code evaluation result does not meet the preset evaluation result, carrying out iterative optimization on the reconstruction opinion model based on the code evaluation result.
The code evaluation model is a code quality evaluation model trained on a neural network model by utilizing code data, the code evaluation model can accurately output a code evaluation result representing code quality, the code evaluation result can be represented in the forms of numbers, characters and the like, if the code evaluation result is represented by the numbers, the closer the numbers are to 0, the better the quality of the reconstructed code is represented by the numbers, and the closer the numbers are to 1, the worse the quality of the reconstructed code is represented by the numbers; if the code evaluation result is expressed by text, the code evaluation result can be expressed by a plurality of grades such as poor quality, general quality, good quality and the like, and the expression form of the code evaluation result is not limited.
The preset evaluation result is a result for representing that the quality of the reconstructed code meets the requirement, and when the code evaluation result meets the preset evaluation result, the quality of the reconstructed code is better, the reconstructed code can be suitable for application, and when the code evaluation result does not meet the preset evaluation result, the quality of the reconstructed code is poorer, and the reconstructed code is unsuitable for application, so that iterative optimization can be performed on a reconstructed opinion model according to the code evaluation result, and the model performance and the accuracy of generating the reconstructed opinion can be improved by means of adjusting a model framework, adding training data, adjusting super parameters and the like.
In addition to evaluating the quality of the reconstructed code using a code evaluation model, in another embodiment, the reconstructed code is compared with a manually reconstructed code to obtain a code comparison result; and under the condition that the code comparison result does not meet the preset comparison result, carrying out iterative optimization on the reconstructed opinion model based on the code comparison result.
The code comparison result is used for evaluating the code quality of the reconstructed code, and the code comparison result can be represented by numbers or characters, and is not limited herein.
The preset comparison result is a result for representing that the quality of the reconstructed code meets the requirement, and under the condition that the code comparison result meets the preset comparison result, the quality of the reconstructed code is good, the reconstructed code can be suitable for application, under the condition that the code comparison result does not meet the preset comparison result, the quality of the reconstructed code is poor, the reconstructed code is unsuitable for application, and in the same way, iterative optimization can be carried out on the reconstructed opinion model according to the modes of adjusting the model framework, adding training data, adjusting super parameters and the like according to the code comparison result, so that the model performance and the accuracy of generating the reconstructed opinion are improved.
It should be noted that code reconstruction is a complex and subjective task, and in an automated code reconstruction scheme, model training and model prediction are alternately performed, and the iterative model training and model prediction process can help the automated code reconstruction scheme to continuously improve and promote, so that the automated code reconstruction scheme is better adapted to different types of codes and reconstruction tasks, and more accurate and reliable reconstruction opinions are generated.
Referring to fig. 3, a block diagram of an embodiment of an apparatus for reconstructing a code according to an embodiment of the present invention is provided. As shown in fig. 3, the apparatus includes:
an acquisition module 301, configured to acquire a code to be reconstructed;
the output module 302 is configured to input a code to be reconstructed into a reconstructed opinion model, and the reconstructed opinion model outputs a reconstructed opinion; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and the modification optimization module 303 is configured to modify and optimize the code to be reconstructed based on the reconstruction opinion, so as to obtain a reconstructed code.
The device for reconstructing the code provided by the embodiment of the invention comprises the steps of obtaining the code to be reconstructed; inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured; and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code. The reconstructed opinion model is a model capable of understanding code semantics, and by inputting the code to be reconstructed into the reconstructed opinion model, the reconstructed opinion model can quickly and automatically give accurate reconstructed opinions according to the semantics of the code to be reconstructed, and provides references for programmers, so that the time and energy of code analysis and reconstruction are reduced, the reconstruction efficiency is improved, and the software online time is greatly shortened.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and an electronic device 500 shown in fig. 4 includes: at least one processor 501, memory 502, at least one network interface 504, and other user interfaces 503. The various components in the electronic device 500 are coupled together by a bus system 505. It is understood that bus system 505 is used to enable connected communications between these components. The bus system 505 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various buses are labeled as bus system 505 in fig. 4.
The user interface 503 may include, among other things, a display, a keyboard, or a pointing device (e.g., a mouse, a trackball, a touch pad, or a touch screen, etc.).
It will be appreciated that the memory 502 in embodiments of the invention can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and Direct memory bus RAM (DRRAM). The memory 502 described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and application programs 5022.
The operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks. The application 5022 includes various application programs such as a Media Player (Media Player), a Browser (Browser), and the like for realizing various application services. A program for implementing the method according to the embodiment of the present invention may be included in the application 5022.
In the embodiment of the present invention, the processor 501 is configured to execute the method steps provided by the method embodiments by calling a program or an instruction stored in the memory 502, specifically, a program or an instruction stored in the application 5022, for example, including:
acquiring a code to be reconstructed;
inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In one possible embodiment, after acquiring the code to be reconstructed, the method further comprises:
performing code format processing on the code to be reconstructed; the code format of the code to be reconstructed after the code format processing accords with the data format of the input reconstruction opinion model.
In one possible implementation, the training process to reconstruct the opinion model includes:
acquiring a training sample set and a code task corresponding to the training sample set; the training sample set comprises a plurality of training samples, each training sample consists of code data and a code label, and the code label is a reconstruction opinion of the code data;
determining diversity parameters of the pre-trained language model based on the code tasks; the diversity parameter is used for controlling the diversity of the generated text;
model training is carried out on the language model comprising the diversity parameters based on the training sample set until the training times reach a preset training times threshold value or the model loss value reaches a preset model loss threshold value, and a reconstruction opinion model is obtained.
In one possible implementation, determining diversity parameters of a pre-trained language model based on code tasks includes:
inquiring target code tasks matched with the code tasks from a diversity parameter inquiry table; the diversity parameter lookup table stores the corresponding relation between the code task and the diversity parameter;
and determining the target diversity parameter corresponding to the target code task as the diversity parameter of the code task.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
inputting the reconstructed code into a code evaluation model, and outputting a code evaluation result by the code evaluation model; the code evaluation result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code evaluation result does not meet the preset evaluation result, carrying out iterative optimization on the reconstruction opinion model based on the code evaluation result.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
comparing the reconstructed code with the manual reconstructed code to obtain a code comparison result; the code comparison result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code comparison result does not meet the preset comparison result, carrying out iterative optimization on the reconstructed opinion model based on the code comparison result.
In one possible embodiment, after acquiring the training sample set and the code corresponding to the training sample set performs the task, the method further comprises:
code format processing is performed on the code data of each training sample in the training sample set.
The method disclosed in the above embodiment of the present invention may be applied to the processor 501 or implemented by the processor 501. The processor 501 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuitry in hardware or instructions in software in the processor 501. The processor 501 may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software elements in a decoding processor. The software elements may be located in a random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 502, and the processor 501 reads information in the memory 502 and, in combination with its hardware, performs the steps of the method described above.
It is to be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For a hardware implementation, the processing units may be implemented within one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processors (Digital Signal Processing, DSP), digital signal processing devices (dspev, DSPD), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA), general purpose processors, controllers, micro-controllers, microprocessors, other electronic units designed to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented by means of units that perform the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
The electronic device provided in this embodiment may be an electronic device as shown in fig. 4, and may perform all steps of the method for reconstructing a code as shown in fig. 1-2, so as to achieve the technical effects of the method for reconstructing a code as shown in fig. 1-2, and the detailed description with reference to fig. 1-2 is omitted herein for brevity.
The embodiment of the invention also provides a storage medium (computer readable storage medium). The storage medium here stores one or more programs. Wherein the storage medium may comprise volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid state disk; the memory may also comprise a combination of the above types of memories.
When one or more programs are executed by one or more processors in a storage medium, the above-described method of code reconstruction is implemented.
The processor is configured to execute a code reconstruction program stored in the memory, so as to implement the following steps of a method for code reconstruction:
acquiring a code to be reconstructed;
inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain the reconstructed code.
In one possible embodiment, after acquiring the code to be reconstructed, the method further comprises:
performing code format processing on the code to be reconstructed; the code format of the code to be reconstructed after the code format processing accords with the data format of the input reconstruction opinion model.
In one possible implementation, the training process to reconstruct the opinion model includes:
acquiring a training sample set and a code task corresponding to the training sample set; the training sample set comprises a plurality of training samples, each training sample consists of code data and a code label, and the code label is a reconstruction opinion of the code data;
determining diversity parameters of the pre-trained language model based on the code tasks; the diversity parameter is used for controlling the diversity of the generated text;
model training is carried out on the language model comprising the diversity parameters based on the training sample set until the training times reach a preset training times threshold value or the model loss value reaches a preset model loss threshold value, and a reconstruction opinion model is obtained.
In one possible implementation, determining diversity parameters of a pre-trained language model based on code tasks includes:
inquiring target code tasks matched with the code tasks from a diversity parameter inquiry table; the diversity parameter lookup table stores the corresponding relation between the code task and the diversity parameter;
and determining the target diversity parameter corresponding to the target code task as the diversity parameter of the code task.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
inputting the reconstructed code into a code evaluation model, and outputting a code evaluation result by the code evaluation model; the code evaluation result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code evaluation result does not meet the preset evaluation result, carrying out iterative optimization on the reconstruction opinion model based on the code evaluation result.
In one possible embodiment, after modifying and optimizing the code to be reconstructed based on the reconstruction opinion, the method further includes:
comparing the reconstructed code with the manual reconstructed code to obtain a code comparison result; the code comparison result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code comparison result does not meet the preset comparison result, carrying out iterative optimization on the reconstructed opinion model based on the code comparison result.
In one possible embodiment, after acquiring the training sample set and the code corresponding to the training sample set performs the task, the method further comprises:
code format processing is performed on the code data of each training sample in the training sample set.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of function in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.

Claims (10)

1. A method of code reconstruction, the method comprising:
acquiring a code to be reconstructed;
inputting the code to be reconstructed into a reconstructed opinion model, and outputting reconstructed opinions by the reconstructed opinion model; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain a reconstruction code.
2. The method of claim 1, wherein after the acquiring the code to be reconstructed, the method further comprises:
performing code format processing on the code to be reconstructed; the code format of the code to be reconstructed after the code format processing accords with the data format of the reconstructed opinion model.
3. The method of claim 1, wherein the training process for reconstructing the opinion model comprises:
acquiring a training sample set and a code task corresponding to the training sample set; the training sample set comprises a plurality of training samples, each training sample consists of code data and a code label, and the code label is a reconstruction opinion of the code data;
determining diversity parameters of a pre-trained language model based on the code tasks; the diversity parameter is used for controlling the diversity of the generated text;
and carrying out model training on the language model comprising the diversity parameters based on the training sample set until the training times reach a preset training times threshold or the model loss value reaches a preset model loss threshold, so as to obtain the reconstruction opinion model.
4. The method of claim 3, wherein the determining diversity parameters of a pre-trained language model based on the code task comprises:
querying an object code task matched with the code task from a diversity parameter lookup table; wherein, the diversity parameter lookup table stores the corresponding relation between the code task and the diversity parameter;
and determining the target diversity parameter corresponding to the target code task as the diversity parameter of the code task.
5. The method according to claim 1, wherein after said modifying and optimizing said code to be reconstructed based on said reconstruction opinion, said method further comprises:
inputting the reconstruction code into a code evaluation model, wherein the code evaluation model outputs a code evaluation result; the code evaluation result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code evaluation result does not meet a preset evaluation result, carrying out iterative optimization on the reconstructed opinion model based on the code evaluation result.
6. The method according to claim 1, wherein after said modifying and optimizing said code to be reconstructed based on said reconstruction opinion, said method further comprises:
comparing the reconstructed code with a manual reconstructed code to obtain a code comparison result; the code comparison result is used for evaluating the code quality of the reconstructed code;
and under the condition that the code comparison result does not meet the preset comparison result, carrying out iterative optimization on the reconstructed opinion model based on the code comparison result.
7. A method according to claim 3, wherein after the acquiring a training sample set and the code tasks corresponding to the training sample set, the method further comprises:
and carrying out code format processing on the code data of each training sample in the training sample set.
8. An apparatus for code reconstruction, the apparatus comprising:
the acquisition module is used for acquiring the code to be reconstructed;
the output module is used for inputting the code to be reconstructed into a reconstructed opinion model, and the reconstructed opinion model outputs reconstructed opinions; the reconfiguration opinion is reconfiguration content for modifying and optimizing the code to be reconfigured;
and the modification optimization module is used for modifying and optimizing the code to be reconstructed based on the reconstruction opinion to obtain a reconstructed code.
9. An electronic device, comprising: a processor and a memory for executing a program of code reconstruction stored in the memory to implement the method of code reconstruction of any one of claims 1 to 7.
10. A storage medium storing one or more programs executable by one or more processors to implement the method of code reconstruction of any one of claims 1-7.
CN202311204842.4A 2023-09-18 2023-09-18 Code reconstruction method, device, electronic equipment and storage medium Pending CN117311800A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311204842.4A CN117311800A (en) 2023-09-18 2023-09-18 Code reconstruction method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311204842.4A CN117311800A (en) 2023-09-18 2023-09-18 Code reconstruction method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117311800A true CN117311800A (en) 2023-12-29

Family

ID=89296366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311204842.4A Pending CN117311800A (en) 2023-09-18 2023-09-18 Code reconstruction method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117311800A (en)

Similar Documents

Publication Publication Date Title
US11816442B2 (en) Multi-turn dialogue response generation with autoregressive transformer models
WO2022095682A1 (en) Text classification model training method, text classification method and apparatus, device, storage medium, and computer program product
CN113641701B (en) Data query method, system, heterogeneous acceleration platform and storage medium
JP2021190124A (en) Method for obtaining word vectors based on language model, apparatus, device, and storage medium
CN112084752B (en) Sentence marking method, device, equipment and storage medium based on natural language
CN114138244A (en) Method and device for automatically generating model files, storage medium and electronic equipment
US20240129567A1 (en) Hub device, multi-device system including the hub device and plurality of devices, and operating method of the hub device and multi-device system
CN116266114A (en) Method, system, article of manufacture and apparatus to identify code semantics
CN111723550A (en) Statement rewriting method, device, electronic device, and computer storage medium
CN110991193A (en) Translation matrix model selection system based on OpenKiwi
CN113344218A (en) Deployment method and device of machine learning model, electronic equipment and storage medium
CN117311800A (en) Code reconstruction method, device, electronic equipment and storage medium
CN112416333A (en) Software model training method, device, system, equipment and storage medium
US11669307B2 (en) Code injection from natural language derived intent
CN116975635A (en) Training method of parameter prediction model, parameter prediction method and device
CN116187353A (en) Translation method, translation device, computer equipment and storage medium thereof
EP4145361A1 (en) Augmentation of machine learning pipeline corpus for synthesizing new machine learning pipelines
CN116306672A (en) Data processing method and device
CN112799658B (en) Model training method, model training platform, electronic device, and storage medium
CN115099249B (en) Intelligent optimization method and system based on translation result and storage medium thereof
CN116860641A (en) Target object testing method, device and equipment
CN117193850A (en) Method, device, electronic equipment and storage medium for generating interface document
CN117132367B (en) Service processing method, device, computer equipment, storage medium and program product
Reyer Comparison of AutoML solutions Auto-PyTorch and AutoCVE
CN104813257A (en) Browsing history language model for input method editor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination